Repository navigation
Include a zpk2tf function #749
Description
Activity
Hi @ovega14 I agree it would be very nice to have this functionality outside of the matlab module.
Its not clear to me how we could implement that functionality inside
TransferFunctionbecause the three-argument case is already taken byTransferFunction(num, den, dt). Might be possible to include a keyword to make it explicit likeTransferFunction(zeros, poles, gain, [dt,] usezpk=True), but implementing that logic seems like it would be awkward.Probably most expedient is to just move the import of scipy's
zpk2tf(and might as well bring inzpk2sswhile you're at it) into theLTImodule rather than the matlab module, and then they will be available everywhere, including the matlab module.This might be an opportunity to also invent a more pythonic additional long name for them as well, e.g.
zeros_poles_gain_to_tf, but they are so apt and convenient I am not sure that is necessary.Feel free to contribute a pull request.
Reacted by Ben GreinerWhoever takes on implementing this should make sure that
zpk2tfandzpk2sseventually create aNamedIOSystem, versus a lower levelTransferFunctionorStateSpaceobject. That will allow the output system to be compatible with the I/O system functionality (including named input/output signals for connecting things together). A diagram of the dependencies can be found here.Reacted by Ben GreinerShould we import
zpk2tfandzpk2ssfromscipyinto theLTImodule? If so, then these functions will not directly return aNamedIOSystem, nor aTransferFunctionorStateSpaceobject. As a reminder, these functions return numerator and denominator coefficient arrays of a transfer function given zeroes, poles, and gain. Should we then redefine the two functions (zpk2tfandzpk2ss) to conform to this expectedpython-controlbehavior?Yes functions in the
controlnamespace should return a python-control conforming system. Hence @murrayrm's request to returnNamedIOSystem. This requires a wrapper rather than a simple import.
As it stands, a function that takes zeroes, poles, gain into numerator, denominator transfer function coefficient arrays only lives in
scipy.signalor can be imported fromcontrol.matlab, and used to create a transfer functionmy_tfas follows:my_tf= tf(*zpk2tf(...))Why not instead can
python-controlhave a method that directly takes zeroes, poles, gain into a transfer function, i.e.my_tf=zpk2tf(..)?