How to create a scipy.lti object for a discrete LTI system?

Like the subject, I use python / numpy / scipy to do some data analysis, and I would like to create an object of the LTI class for a discrete system, specifying (num, den, dt) or (zeros, poles, gain, dt) or even (A, B, C, D, dt), but the documentation never mentions how to do this.

There are, however, functions, such as dsim / dstep / dimpulse, that will take an LTI object and do something with it, so I assume this is possible. As soon as I do this, I would like to do something like conversion from one representation to another (num / den β†’ zpk β†’ A, B, C, D), build a Bode diagram, etc.

In addition, it is completely incomprehensible to me if the representation (num, den, dt) used the coefficient for z or z ^ -1, since I do not think that there is a clear standard.

+4
source share
2 answers

It seems that the class scipy.signal.lti is only for continuous time systems. By checking the documentation, for example scipy.signal.dstep , you get:

 system : a tuple describing the system. The following gives the number of elements in the tuple and the interpretation. * 3: (num, den, dt) * 4: (zeros, poles, gain, dt) * 5: (A, B, C, D, dt) 

Thus, the system argument cannot be an object of class lti . Although the scipy.signal.dlsim documentation states that it accepts LTI instances, I think this is wrong. At least with scipy 0.10.0, I get:

 TypeError: object of type 'lti' has no len() 

Thus, it is obvious that dlsim expects the system argument to be a tuple.

+2
source

I think there is a little inconsistency in scipy. For one thing, you can define an lti system using something like:

 >> sys = sig.lti([1],[1,1]) 

Type of this system:

 >> type(sys) scipy.signal.ltisys.lti 

Many of the analog system procedures that are under scipy.signal.ltisys work well for these types of systems, but this is not the case you will find in flat scipy. There you can also define the system in different ways:

 sys_ss = scipy.signal.tf2ss([1],[1,2]) sysd_ss = scipy.signal.cont2discrete(sys_ss,1.0/10) t,y = scipy.signal.dstep(sysd_ss) 

and to build it you can do something like:

 plt.plot(t,y[0]) 

The object created by signal.tf2ss is just a tuple with a state-space matrix. Either I don’t understand this well (I happen to have not much experience in python), or it is pretty dirty.

0
source

Source: https://habr.com/ru/post/1497906/


All Articles