control.TimeResponseData¶
- class control.TimeResponseData(time, outputs, states=None, inputs=None, issiso=None, output_labels=None, state_labels=None, input_labels=None, transpose=False, return_x=False, squeeze=None, multi_trace=False)[source]¶
Bases:
object
A class for returning time responses.
This class maintains and manipulates the data corresponding to the temporal response of an input/output system. It is used as the return type for time domain simulations (step response, input/output response, etc).
A time response consists of a time vector, an output vector, and optionally an input vector and/or state vector. Inputs and outputs can be 1D (scalar input/output) or 2D (vector input/output).
A time response can be stored for multiple input signals (called traces), with the output and state indexed by the trace number. This allows for input/output response matrices, which is mainly useful for impulse and step responses for linear systems. For multi-trace responses, the same time vector must be used for all traces.
Time responses are accessed through either the raw data, stored as
t
,y
,x
,u
, or using a set of propertiestime
,outputs
,states
,inputs
. When accessing time responses via their properties, squeeze processing is applied so that (by default) single-input, single-output systems will have the output and input indices supressed. This behavior is set using thesqueeze
keyword.- t¶
Time values of the input/output response(s). This attribute is normally accessed via the
time
property.- Type
1D array
- y¶
Output response data, indexed either by output index and time (for single trace responses) or output, trace, and time (for multi-trace responses). These data are normally accessed via the
outputs
property, which performs squeeze processing.- Type
2D or 3D array
- x¶
State space data, indexed either by output number and time (for single trace responses) or output, trace, and time (for multi-trace responses). If no state data are present, value is
None
. These data are normally accessed via thestates
property, which performs squeeze processing.- Type
2D or 3D array, or None
- u¶
Input signal data, indexed either by input index and time (for single trace responses) or input, trace, and time (for multi-trace responses). If no input data are present, value is
None
. These data are normally accessed via theinputs
property, which performs squeeze processing.- Type
2D or 3D array, or None
- squeeze¶
By default, if a system is single-input, single-output (SISO) then the outputs (and inputs) are returned as a 1D array (indexed by time) and if a system is multi-input or multi-output, then the outputs are returned as a 2D array (indexed by output and time) or a 3D array (indexed by output, trace, and time). If
squeeze=True
, access to the output response will remove single-dimensional entries from the shape of the inputs and outputs even if the system is not SISO. Ifsqueeze=False
, the output is returned as a 2D or 3D array (indexed by the output [if multi-input], trace [if multi-trace] and time) even if the system is SISO. The default value can be set using config.defaults[‘control.squeeze_time_response’].- Type
bool, optional
- transpose¶
If True, transpose all input and output arrays (for backward compatibility with MATLAB and
scipy.signal.lsim()
). Default value is False.- Type
bool, optional
- issiso¶
Set to
True
if the system generating the data is single-input, single-output. If passed asNone
(default), the input data will be used to set the value.- Type
bool, optional
- ninputs, noutputs, nstates
Number of inputs, outputs, and states of the underlying system.
- Type
int
- input_labels, output_labels, state_labels
Names for the input, output, and state variables.
- Type
array of str
- ntraces¶
Number of independent traces represented in the input/output response. If ntraces is 0 then the data represents a single trace with the trace index surpressed in the data.
- Type
int
Notes
For backward compatibility with earlier versions of python-control, this class has an
__iter__
method that allows it to be assigned to a tuple with a variable number of elements. This allows the following patterns to work:t, y = step_response(sys) t, y, x = step_response(sys, return_x=True)
When using this (legacy) interface, the state vector is not affected by the squeeze parameter.
For backward compatibility with earlier version of python-control, this class has
__getitem__
and__len__
methods that allow the return value to be indexed:response[0]: returns the time vector response[1]: returns the output vector response[2]: returns the state vector
When using this (legacy) interface, the state vector is not affected by the squeeze parameter.
The default settings for
return_x
,squeeze
andtranspose
can be changed by calling the class instance and passing new values:response(tranpose=True).input
See
TimeResponseData.__call__()
for more information.
Methods
to_pandas
- __call__(**kwargs)[source]¶
Change value of processing keywords.
Calling the time response object will create a copy of the object and change the values of the keywords used to control the
outputs
,states
, andinputs
properties.- Parameters
squeeze (bool, optional) – If squeeze=True, access to the output response will remove single-dimensional entries from the shape of the inputs, outputs, and states even if the system is not SISO. If squeeze=False, keep the input as a 2D or 3D array (indexed by the input (if multi-input), trace (if single input) and time) and the output and states as a 3D array (indexed by the output/state, trace, and time) even if the system is SISO.
transpose (bool, optional) – If True, transpose all input and output arrays (for backward compatibility with MATLAB and
scipy.signal.lsim()
). Default value is False.return_x (bool, optional) – If True, return the state vector when enumerating result by assigning to a tuple (default = False).
input_labels (array of str) – Labels for the inputs, outputs, and states, given as a list of strings matching the appropriate signal dimension.
output_labels (array of str) – Labels for the inputs, outputs, and states, given as a list of strings matching the appropriate signal dimension.
state_labels (array of str) – Labels for the inputs, outputs, and states, given as a list of strings matching the appropriate signal dimension.
- property inputs¶
Time response input vector.
Input(s) to the system, indexed by input (optiona), trace (optional), and time. If a 1D vector is passed, the input corresponds to a scalar-valued input. If a 2D vector is passed, then it can either represent multiple single-input traces or a single multi-input trace. The optional
multi_trace
keyword should be used to disambiguate the two. If a 3D vector is passed, then it represents a multi-trace, multi-input signal, indexed by input, trace, and time.See
TimeResponseData.squeeze
for a description of how the dimensions of the input vector can be modified using the squeeze keyword.- Type
1D or 2D array
- property outputs¶
Time response output vector.
Output response of the system, indexed by either the output and time (if only a single input is given) or the output, trace, and time (for multiple traces). See
TimeResponseData.squeeze
for a description of how this can be modified using the squeeze keyword.- Type
1D, 2D, or 3D array
- property states¶
Time response state vector.
Time evolution of the state vector, indexed indexed by either the state and time (if only a single trace is given) or the state, trace, and time (for multiple traces). See
TimeResponseData.squeeze
for a description of how this can be modified using the squeeze keyword.- Type
2D or 3D array
- property time¶
Time vector.
Time values of the input/output response(s).
- Type
1D array