state_space¶
- class nfoursid.state_space.StateSpace(a: numpy.ndarray, b: numpy.ndarray, c: numpy.ndarray, d: numpy.ndarray, k: Optional[numpy.ndarray] = None, x_init: Optional[numpy.ndarray] = None, y_column_names: Optional[List[str]] = None, u_column_names: Optional[List[str]] = None)¶
Bases:
object
A state-space model defined by the following equations:
The shapes of the matrices are checked for consistency and will raise if inconsistent. If a matrix does not exist in the model representation, the corresponding
np.ndarray
should have dimension zero along that axis. See the example below.An autonomous state-space model has no matrices and . An autonomous model with a one-dimensional internal state and output, can be represented as follows:
>>> model = StateSpace( >>> np.ones((1, 1)), >>> np.ones((1, 0)), >>> np.ones((1, 1)), >>> np.ones((1, 0)) >>> )
- Parameters
a – matrix
b – matrix
c – matrix
d – matrix
k – matrix , optional
x_init – initial state of the model, optional
y_column_names – list of output column names, optional
u_column_names – list of input column names, optional
- output(x: numpy.ndarray, u: Optional[numpy.ndarray] = None, e: Optional[numpy.ndarray] = None)¶
Calculate the output of the state-space model. This function calculates the updated of the state-space model in the class description. The current state
x
is required. Providing an inputu
is optional. Providing a noise terme
to be added is optional as well.
- plot_input_output(fig: matplotlib.figure.Figure)¶
Given a matplotlib figure
fig
, plot the inputs and outputs of the state-space model.
- step(u: Optional[numpy.ndarray] = None, e: Optional[numpy.ndarray] = None) numpy.ndarray ¶
Calculates the output of the state-space model and returns it. Updates the internal state of the model as well. The input
u
is optional, as is the noisee
.
- to_dataframe() pandas.core.frame.DataFrame ¶
Return the inputs and outputs of the state-space model as a dataframe, where the columns are the input- and output-columns.