control.FrequencyResponseData¶
- class control.FrequencyResponseData(d, w[, smooth])¶
Bases:
LTI
A class for models defined by frequency response data (FRD).
The FrequencyResponseData (FRD) class is used to represent systems in frequency response data form.
- Parameters
d (1D or 3D complex array_like) – The frequency response at each frequency point. If 1D, the system is assumed to be SISO. If 3D, the system is MIMO, with the first dimension corresponding to the output index of the FRD, the second dimension corresponding to the input index, and the 3rd dimension corresponding to the frequency points in omega
w (iterable of real frequencies) – List of frequency points for which data are available.
smooth (bool, optional) – If
True
, create an interpolation function that allows the frequency response to be computed at any frequency within the range of frequencies give inw
. IfFalse
(default), frequency response can only be obtained at the frequencies specified inw
.
- ninputs, noutputs
Number of input and output variables.
- Type
int
- omega¶
Frequency points of the response.
- Type
1D array
- fresp¶
Frequency response, indexed by output index, input index, and frequency point.
- Type
3D array
Notes
The main data members are ‘omega’ and ‘fresp’, where ‘omega’ is a 1D array of frequency points and and ‘fresp’ is a 3D array of frequency responses, with the first dimension corresponding to the output index of the FRD, the second dimension corresponding to the input index, and the 3rd dimension corresponding to the frequency points in omega. For example,
>>> frdata[2,5,:] = numpy.array([1., 0.8-0.2j, 0.2-0.8j])
means that the frequency response from the 6th input to the 3rd output at the frequencies defined in omega is set to the array above, i.e. the rows represent the outputs and the columns represent the inputs.
A frequency response data object is callable and returns the value of the transfer function evaluated at a point in the complex plane (must be on the imaginary access). See
__call__()
for a more detailed description.Methods
Make a copy of an input/output system
Natural frequency, damping ratio of system poles
Return the zero-frequency gain
Evaluate a transfer function at angular frequency omega.
Feedback interconnection between two FRD objects.
Find the index for an input given its name (None if not found)
Find the index for an output given its name (None if not found)
Find the index for a state given its name (None if not found)
(deprecated) Evaluate transfer function at complex frequencies.
Evaluate the linear time-invariant system at an array of angular frequencies.
Check to see if a system is a continuous-time system
Check to see if a system is a discrete-time system
Check to see if a system is single input, single output
pole
Set the number/names of the system inputs.
Set the number/names of the system outputs.
Set the number/names of the system states.
to_pandas
zero
- __add__(other)¶
Add two LTI objects (parallel connection).
- __call__(s=None, squeeze=None, return_magphase=None)¶
Evaluate system’s transfer function at complex frequencies.
Returns the complex frequency response sys(s) of system sys with m = sys.ninputs number of inputs and p = sys.noutputs number of outputs.
To evaluate at a frequency omega in radians per second, enter
s = omega * 1j
or usesys.eval(omega)
For a frequency response data object, the argument must be an imaginary number (since only the frequency response is defined).
If
s
is not given, this function creates a copy of a frequency response data object with a different set of output settings.- Parameters
s (complex scalar or 1D array_like) – Complex frequencies. If not specified, return a copy of the frequency response data object with updated settings for output processing (
squeeze
,return_magphase
).squeeze (bool, optional) – If squeeze=True, remove single-dimensional entries from the shape of the output even if the system is not SISO. If squeeze=False, keep all indices (output, input and, if omega is array_like, frequency) even if the system is SISO. The default value can be set using config.defaults[‘control.squeeze_frequency_response’].
return_magphase (bool, optional) – If True, then a frequency response data object will enumerate as a tuple of the form (mag, phase, omega) where where
mag
is the magnitude (absolute value, not dB or log10) of the system frequency response,phase
is the wrapped phase in radians of the system frequency response, andomega
is the (sorted) frequencies at which the response was evaluated.
- Returns
fresp – The frequency response of the system. If the system is SISO and squeeze is not True, the shape of the array matches the shape of omega. If the system is not SISO or squeeze is False, the first two dimensions of the array are indices for the output and input and the remaining dimensions match omega. If
squeeze
is True then single-dimensional axes are removed.- Return type
complex ndarray
- Raises
ValueError – If s is not purely imaginary, because
FrequencyDomainData
systems are only defined at imaginary frequency values.
- __mul__(other)¶
Multiply two LTI objects (serial connection).
- __neg__()¶
Negate a transfer function.
- __radd__(other)¶
Right add two LTI objects (parallel connection).
- __rmul__(other)¶
Right Multiply two LTI objects (serial connection).
- __rsub__(other)¶
Right subtract two LTI objects.
- __rtruediv__(other)¶
Right divide two LTI objects.
- __sub__(other)¶
Subtract two LTI objects.
- __truediv__(other)¶
Divide two LTI objects.
- copy(name=None, use_prefix_suffix=True)¶
Make a copy of an input/output system
A copy of the system is made, with a new name. The name keyword can be used to specify a specific name for the system. If no name is given and use_prefix_suffix is True, the name is constructed by prepending config.defaults[‘iosys.duplicate_system_name_prefix’] and appending config.defaults[‘iosys.duplicate_system_name_suffix’]. Otherwise, a generic system name of the form sys[<id>] is used, where <id> is based on an internal counter.
- damp()¶
Natural frequency, damping ratio of system poles
- Returns
wn (array) – Natural frequencies for each system pole
zeta (array) – Damping ratio for each system pole
poles (array) – Array of system poles
- dcgain()¶
Return the zero-frequency gain
- eval(omega, squeeze=None)¶
Evaluate a transfer function at angular frequency omega.
Note that a “normal” FRD only returns values for which there is an entry in the omega vector. An interpolating FRD can return intermediate values.
- Parameters
omega (float or 1D array_like) – Frequencies in radians per second
squeeze (bool, optional) – If squeeze=True, remove single-dimensional entries from the shape of the output even if the system is not SISO. If squeeze=False, keep all indices (output, input and, if omega is array_like, frequency) even if the system is SISO. The default value can be set using config.defaults[‘control.squeeze_frequency_response’].
- Returns
fresp – The frequency response of the system. If the system is SISO and squeeze is not True, the shape of the array matches the shape of omega. If the system is not SISO or squeeze is False, the first two dimensions of the array are indices for the output and input and the remaining dimensions match omega. If
squeeze
is True then single-dimensional axes are removed.- Return type
complex ndarray
- feedback(other=1, sign=-1)¶
Feedback interconnection between two FRD objects.
- find_input(name)¶
Find the index for an input given its name (None if not found)
- find_output(name)¶
Find the index for an output given its name (None if not found)
- find_state(name)¶
Find the index for a state given its name (None if not found)
- freqresp(omega)¶
(deprecated) Evaluate transfer function at complex frequencies.
- frequency_response(omega, squeeze=None)¶
Evaluate the linear time-invariant system at an array of angular frequencies.
Reports the frequency response of the system,
G(j*omega) = mag * exp(j*phase)
for continuous time systems. For discrete time systems, the response is evaluated around the unit circle such that
G(exp(j*omega*dt)) = mag * exp(j*phase).
In general the system may be multiple input, multiple output (MIMO), where m = self.ninputs number of inputs and p = self.noutputs number of outputs.
- Parameters
omega (float or 1D array_like) – A list, tuple, array, or scalar value of frequencies in radians/sec at which the system will be evaluated.
squeeze (bool, optional) – If squeeze=True, remove single-dimensional entries from the shape of the output even if the system is not SISO. If squeeze=False, keep all indices (output, input and, if omega is array_like, frequency) even if the system is SISO. The default value can be set using config.defaults[‘control.squeeze_frequency_response’].
- Returns
response – Frequency response data object representing the frequency response. This object can be assigned to a tuple using
mag, phase, omega = response
where
mag
is the magnitude (absolute value, not dB or log10) of the system frequency response,phase
is the wrapped phase in radians of the system frequency response, andomega
is the (sorted) frequencies at which the response was evaluated. If the system is SISO and squeeze is not True,magnitude
andphase
are 1D, indexed by frequency. If the system is not SISO or squeeze is False, the array is 3D, indexed by the output, input, and frequency. Ifsqueeze
is True then single-dimensional axes are removed.- Return type
FrequencyReponseData
- property inputs¶
Deprecated attribute; use
ninputs
instead.The
inputs
attribute was used to store the number of system inputs. It is no longer used. If you need access to the number of inputs for an LTI system, useninputs
.
- isctime(strict=False)¶
Check to see if a system is a continuous-time system
- Parameters
sys (Named I/O system) – System to be checked
strict (bool, optional) – If strict is True, make sure that timebase is not None. Default is False.
- isdtime(strict=False)¶
Check to see if a system is a discrete-time system
- Parameters
strict (bool, optional) – If strict is True, make sure that timebase is not None. Default is False.
- issiso()¶
Check to see if a system is single input, single output
- ninputs¶
Number of system inputs.
- noutputs¶
Number of system outputs.
- nstates¶
Number of system states.
- property outputs¶
Deprecated attribute; use
noutputs
instead.The
outputs
attribute was used to store the number of system outputs. It is no longer used. If you need access to the number of outputs for an LTI system, usenoutputs
.
- set_inputs(inputs, prefix='u')¶
Set the number/names of the system inputs.
- Parameters
inputs (int, list of str, or None) – Description of the system inputs. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form u[i] (where the prefix u can be changed using the optional prefix parameter).
prefix (string, optional) – If inputs is an integer, create the names of the states using the given prefix (default = ‘u’). The names of the input will be of the form prefix[i].
- set_outputs(outputs, prefix='y')¶
Set the number/names of the system outputs.
- Parameters
outputs (int, list of str, or None) – Description of the system outputs. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form u[i] (where the prefix u can be changed using the optional prefix parameter).
prefix (string, optional) – If outputs is an integer, create the names of the states using the given prefix (default = ‘y’). The names of the input will be of the form prefix[i].
- set_states(states, prefix='x')¶
Set the number/names of the system states.
- Parameters
states (int, list of str, or None) – Description of the system states. This can be given as an integer count or as a list of strings that name the individual signals. If an integer count is specified, the names of the signal will be of the form u[i] (where the prefix u can be changed using the optional prefix parameter).
prefix (string, optional) – If states is an integer, create the names of the states using the given prefix (default = ‘x’). The names of the input will be of the form prefix[i].