control.FrequencyResponseData
- class control.FrequencyResponseData(d, w[, smooth])[source]
A class for models defined by frequency response data (FRD).
The FrequencyResponseData (FRD) class is used to represent systems in frequency response data form. It can be created manually using the class constructor, using the :func:~~control.frd` factory function (preferred), or via the
frequency_response()
function.- 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.
sysname (str or None) – Name of the system that generated the data.
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
- dt
System timebase.
- Type
float, True, or None
See also
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.- __init__(*args, **kwargs)[source]
Construct an FRD object.
The default constructor is FRD(d, w), where w is an iterable of frequency points, and d is the matching frequency data.
If d is a single list, 1D array, or tuple, a SISO system description is assumed. d can also be
To call the copy constructor, call FRD(sys), where sys is a FRD object.
To construct frequency response data for an existing LTI object, other than an FRD, call FRD(sys, omega).
Methods
__init__
(*args, **kwargs)Construct an FRD object.
bandwidth
([dbdrop])Evaluate the bandwidth of the LTI system for a given dB drop.
copy
([name, use_prefix_suffix])Make a copy of an input/output system
damp
()Natural frequency, damping ratio of system poles
dcgain
()Return the zero-frequency gain
eval
(omega[, squeeze])Evaluate a transfer function at angular frequency omega.
feedback
([other, sign])Feedback interconnection between two FRD objects.
find_input
(name)Find the index for an input given its name (None if not found)
find_inputs
(name_list)Return list of indices matching input spec (None if not found)
find_output
(name)Find the index for an output given its name (None if not found)
find_outputs
(name_list)Return list of indices matching output spec (None if not found)
find_state
(name)Find the index for a state given its name (None if not found)
find_states
(name_list)Return list of indices matching state spec (None if not found)
freqresp
(omega)(deprecated) Evaluate transfer function at complex frequencies.
frequency_response
([omega, squeeze])Evaluate the linear time-invariant system at an array of angular frequencies.
isctime
([strict])Check to see if a system is a continuous-time system.
isdtime
([strict])Check to see if a system is a discrete-time system
ispassive
()issiso
()Check to see if a system is single input, single output.
plot
([plot_type])Plot the frequency response using a Bode plot.
set_inputs
(inputs[, prefix])Set the number/names of the system inputs.
set_outputs
(outputs[, prefix])Set the number/names of the system outputs.
set_states
(states[, prefix])Set the number/names of the system states.
Convert response data to pandas data frame.
update_names
([name, inputs, outputs, states])Update signal and system names for an I/O system.
Attributes
frequency
input_labels
kwargs_list
magnitude
Number of system inputs.
Number of system outputs.
Number of system states.
output_labels
phase
response
state_labels
- bandwidth(dbdrop=-3)[source]
Evaluate the bandwidth of the LTI system for a given dB drop.
Evaluate the first frequency that the response magnitude is lower than DC gain by dbdrop dB.
- Parameters
dpdrop (float, optional) – A strictly negative scalar in dB (default = -3) defines the amount of gain drop for deciding bandwidth.
- Returns
bandwidth – The first frequency (rad/time-unit) where the gain drops below dbdrop of the dc gain of the system, or nan if the system has infinite dc gain, inf if the gain does not drop for all frequency
- Return type
ndarray
- Raises
TypeError – if ‘sys’ is not an SISO LTI instance
ValueError – if ‘dbdrop’ is not a negative scalar
- copy(name=None, use_prefix_suffix=True)[source]
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()[source]
Natural frequency, damping ratio of system poles
- Returns
wn (array) – Natural frequency for each system pole
zeta (array) – Damping ratio for each system pole
poles (array) – System pole locations
- eval(omega, squeeze=None)[source]
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
- frequency_response(omega=None, squeeze=None)[source]
Evaluate the linear time-invariant system at an array of angular frequencies.
For continuous time systems, computes the frequency response as
G(j*omega) = mag * exp(j*phase)
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, if omega is array_like, frequency. Ifsqueeze
is True then single-dimensional axes are removed.- Return type
- isctime(strict=False)[source]
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)[source]
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.
- ninputs
Number of system inputs.
- noutputs
Number of system outputs.
- nstates
Number of system states.
- plot(plot_type=None, *args, **kwargs)[source]
Plot the frequency response using a Bode plot.
Plot the frequency response using either a standard Bode plot (default) or using a singular values plot (by setting plot_type to ‘svplot’). See
bode_plot()
andsingular_values_plot()
for more detailed descriptions.
- set_inputs(inputs, prefix='u')[source]
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')[source]
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')[source]
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].
- to_pandas()[source]
Convert response data to pandas data frame.
Creates a pandas data frame for the value of the frequency response at each omega. The frequency response values are labeled in the form “H_{<out>, <in>}” where “<out>” and “<in>” are replaced with the output and input labels for the system.
- update_names([name, inputs, outputs, states])[source]
Update signal and system names for an I/O system.
- Parameters
name (str, optional) – New system name.
inputs (list of str, int, or None, optional) – List of strings that name the individual input signals. If given as an integer or None, signal names default to the form u[i]. See
InputOutputSystem
for more information.outputs (list of str, int, or None, optional) – Description of output signals; defaults to y[i].
states (int, list of str, int, or None, optional) – Description of system states; defaults to x[i].