I am giving a try to your control-0.3 python-control package. I use latest
pythonxy distribution and install your control-0.3 on a top of it. I tried
secord-matlab.py with following message:
C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221:
BadCoefficients: Badly conditionned filter coefficients (numerator): the
results may be meaningless
"results may be meaningless", BadCoefficients)
Do I anything missing (package)?
Thanks.
Best regards,
Peter
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Peter, I looked a little while through the scipy.lti code today, and I found
where that warning comes from. It's the "normalize" function in
/usr/share/pyshared/scipy/signal/filter_design.py
(at least that's where it lives in ubuntu linux). That function just looks for
any coefficients in the numerator of a transfer function that are really small
(< 1e-14), including zero, and removes them, giving this warning. So indeed,
it is a benign warning.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And here's update on the "Index out of bounds" error when using lsim (or step
or impulse) on a transfer function with an integrator (such as a PI
controllers) that comes from having the final coefficient in the denominator
equal to zero.
For
step
the problem comes when scipy.signal.step tries to automatically calcuate how
long to run the simulation for. It looks at the smallest eigenvalue and takes
its inverse, leading to an inf.
And for lsim, the problem is that it looks for an analytical solution that
assumes the A matrix is nonsingular. More here: http://projects.scipy.org/sci
py/ticket/577 . The interim
solution seems to be to use
fromscipy.signalimportlsim2
and use lsim2 on it instead of lsim. The next version of scipy has
corresponding step2 and impulse2 commands.
Here's a possible solution that would live in matlab.py that checks if the
denominator has a trailing zero coefficient and calls the corresponding lsim:
def lsim(*args, **kwargs):
sys = args[0]
if isinstance(sys,scipy.signal.lti)):
den = sys.den
else:
sys = scipy.signal.lti(sys)
den = sys.den
if den[-1] < 1e-14:
# integrator, have to use lsim2
return scipy.signal.lsim2(*args, **kwargs)
else:
return scipy.signal.lsim(*args, **kwargs)
Corresponding step2 and impulse2 could be added in when those are available in
scipy.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
def lsim(*args, **kwargs):
system = args[0]
if isinstance(system, scipy.signal.lti):
sys = system
else:
sys = scipy.signal.lti(*system)
den = sys.den
if den[-1] < 1e-14:
# integrator, have to use lsim2
return scipy.signal.lsim2(*args, **kwargs)
else:
return scipy.signal.lsim(*args, **kwargs)
Any idea how to edit posts?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looking through the scipy.signal documentation, it looks like lsim() is just
doing a simple linear or ZOH interpolation. The lsim2() function uses an
actual ODE solver (adaptive step size, etc). I don't see any advantage to
using lsim(), so my inclination is to just follow Sawyer's suggestion and add
functions lsim, step, impulse in matlab.py that call lsim2() etc out of the
scipy.signal module. I'll implement in the next release unless someone seems
some flaws.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello from Czech rep.,
I am giving a try to your control-0.3 python-control package. I use latest
pythonxy distribution and install your control-0.3 on a top of it. I tried
secord-matlab.py with following message:
C:\Python26\lib\site-packages\scipy\signal\filter_design.py:221:
BadCoefficients: Badly conditionned filter coefficients (numerator): the
results may be meaningless
"results may be meaningless", BadCoefficients)
Do I anything missing (package)?
Thanks.
Best regards,
Peter
Yeah, I get those messages too, but sometimes they are benign.
I wanted to add that along the same lines,
, that is, an integrator, does not seem to work. That is, when I try to take
the step function of it I get an "
" error from scipy.lti. Something nearby, eg.,
works fine.
In a similar vein,
does not work either, but this might be an easier fix by simply stripping off
any leading zeros before passing the arguments to scipy.lti
Sawyer
Peter, I looked a little while through the scipy.lti code today, and I found
where that warning comes from. It's the "normalize" function in
(at least that's where it lives in ubuntu linux). That function just looks for
any coefficients in the numerator of a transfer function that are really small
(< 1e-14), including zero, and removes them, giving this warning. So indeed,
it is a benign warning.
And here's update on the "Index out of bounds" error when using lsim (or step
or impulse) on a transfer function with an integrator (such as a PI
controllers) that comes from having the final coefficient in the denominator
equal to zero.
For
the problem comes when scipy.signal.step tries to automatically calcuate how
long to run the simulation for. It looks at the smallest eigenvalue and takes
its inverse, leading to an inf.
And for lsim, the problem is that it looks for an analytical solution that
assumes the A matrix is nonsingular. More here: http://projects.scipy.org/sci
py/ticket/577 . The interim
solution seems to be to use
and use lsim2 on it instead of lsim. The next version of scipy has
corresponding step2 and impulse2 commands.
Here's a possible solution that would live in matlab.py that checks if the
denominator has a trailing zero coefficient and calls the corresponding lsim:
Corresponding step2 and impulse2 could be added in when those are available in
scipy.
Hm, that version had bugs. Try:
Any idea how to edit posts?
Looking through the scipy.signal documentation, it looks like lsim() is just
doing a simple linear or ZOH interpolation. The lsim2() function uses an
actual ODE solver (adaptive step size, etc). I don't see any advantage to
using lsim(), so my inclination is to just follow Sawyer's suggestion and add
functions lsim, step, impulse in matlab.py that call lsim2() etc out of the
scipy.signal module. I'll implement in the next release unless someone seems
some flaws.