`signal.lti_conversion`¶

ltisys – a collection of functions to convert linear time invariant systems from one representation to another.

Module Contents¶

Functions¶

 `tf2ss`(num,den) rTransfer function to state-space representation. `_none_to_empty_2d`(arg) `_atleast_2d_or_none`(arg) `_shape_or_none`(M) `_choice_not_none`(*args) `_restore`(M,shape) `abcd_normalize`(A=None,B=None,C=None,D=None) Check state-space matrices and ensure they are two-dimensional. `ss2tf`(A,B,C,D,input=0) rState-space to transfer function. `zpk2ss`(z,p,k) Zero-pole-gain representation to state-space representation `ss2zpk`(A,B,C,D,input=0) State-space representation to zero-pole-gain representation. `cont2discrete`(system,dt,method=”zoh”,alpha=None) Transform a continuous to a discrete state-space system.
`tf2ss`(num, den)

rTransfer function to state-space representation.

num, den : array_like
Sequences representing the coefficients of the numerator and denominator polynomials, in order of descending degree. The denominator needs to be at least as long as the numerator.
A, B, C, D : ndarray
State space representation of the system, in controller canonical form.

Convert the transfer function:

```>>> num = [1, 3, 3]
>>> den = [1, 2, 1]
```

to the state-space representation:

```>>> from scipy.signal import tf2ss
>>> A, B, C, D = tf2ss(num, den)
>>> A
array([[-2., -1.],
[ 1.,  0.]])
>>> B
array([[ 1.],
[ 0.]])
>>> C
array([[ 1.,  2.]])
>>> D
array([[ 1.]])
```
`_none_to_empty_2d`(arg)
`_atleast_2d_or_none`(arg)
`_shape_or_none`(M)
`_choice_not_none`(*args)
`_restore`(M, shape)
`abcd_normalize`(A=None, B=None, C=None, D=None)

Check state-space matrices and ensure they are two-dimensional.

If enough information on the system is provided, that is, enough properly-shaped arrays are passed to the function, the missing ones are built from this information, ensuring the correct number of rows and columns. Otherwise a ValueError is raised.

A, B, C, D : array_like, optional
State-space matrices. All of them are None (missing) by default. See ss2tf for format.
A, B, C, D : array
Properly shaped state-space matrices.
ValueError
If not enough information on the system was provided.
`ss2tf`(A, B, C, D, input=0)

rState-space to transfer function.

A, B, C, D defines a linear state-space system with p inputs, q outputs, and n state variables.

A : array_like
State (or system) matrix of shape `(n, n)`
B : array_like
Input matrix of shape `(n, p)`
C : array_like
Output matrix of shape `(q, n)`
D : array_like
Feedthrough (or feedforward) matrix of shape `(q, p)`
input : int, optional
For multiple-input systems, the index of the input to use.
num : 2-D ndarray
Numerator(s) of the resulting transfer function(s). num has one row for each of the system’s outputs. Each row is a sequence representation of the numerator polynomial.
den : 1-D ndarray
Denominator of the resulting transfer function(s). den is a sequence representation of the denominator polynomial.

Convert the state-space representation:

```>>> A = [[-2, -1], [1, 0]]
>>> B = [[1], [0]]  # 2-dimensional column vector
>>> C = [[1, 2]]    # 2-dimensional row vector
>>> D = 1
```

to the transfer function:

```>>> from scipy.signal import ss2tf
>>> ss2tf(A, B, C, D)
(array([[1, 3, 3]]), array([ 1.,  2.,  1.]))
```
`zpk2ss`(z, p, k)

Zero-pole-gain representation to state-space representation

z, p : sequence
Zeros and poles.
k : float
System gain.
A, B, C, D : ndarray
State space representation of the system, in controller canonical form.
`ss2zpk`(A, B, C, D, input=0)

State-space representation to zero-pole-gain representation.

A, B, C, D defines a linear state-space system with p inputs, q outputs, and n state variables.

A : array_like
State (or system) matrix of shape `(n, n)`
B : array_like
Input matrix of shape `(n, p)`
C : array_like
Output matrix of shape `(q, n)`
D : array_like
Feedthrough (or feedforward) matrix of shape `(q, p)`
input : int, optional
For multiple-input systems, the index of the input to use.
z, p : sequence
Zeros and poles.
k : float
System gain.
`cont2discrete`(system, dt, method="zoh", alpha=None)

Transform a continuous to a discrete state-space system.

system : a tuple describing the system or an instance of lti

The following gives the number of elements in the tuple and the interpretation:

• 1: (instance of lti)
• 2: (num, den)
• 3: (zeros, poles, gain)
• 4: (A, B, C, D)
dt : float
The discretization time step.
method : {“gbt”, “bilinear”, “euler”, “backward_diff”, “zoh”}, optional

Which method to use:

• gbt: generalized bilinear transformation
• bilinear: Tustin’s approximation (“gbt” with alpha=0.5)
• euler: Euler (or forward differencing) method (“gbt” with alpha=0)
• backward_diff: Backwards differencing (“gbt” with alpha=1.0)
• zoh: zero-order hold (default)
alpha : float within [0, 1], optional
The generalized bilinear transformation weighting parameter, which should only be specified with method=”gbt”, and is ignored otherwise
sysd : tuple containing the discrete system

Based on the input type, the output will be of the form

• (num, den, dt) for transfer function input
• (zeros, poles, gain, dt) for zeros-poles-gain input
• (A, B, C, D, dt) for state-space system input

By default, the routine uses a Zero-Order Hold (zoh) method to perform the transformation. Alternatively, a generalized bilinear transformation may be used, which includes the common Tustin’s bilinear approximation, an Euler’s method technique, or a backwards differencing technique.

The Zero-Order Hold (zoh) method is based on [1], the generalized bilinear approximation is based on [2] and [3].

 [3] G. Zhang, X. Chen, and T. Chen, Digital redesign via the generalized bilinear transformation, Int. J. Control, vol. 82, no. 4, pp. 741-754, 2009. (http://www.mypolyuweb.hk/~magzhang/Research/ZCC09_IJC.pdf)