You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to get the "absolute" phase of the transfer function ? If not, i would suggest that control.matlab.bode be corrected as to reflect the behavior of matlab's bode
My (limited) understanding of the function is that bode uses freqresp which uses evalfr and then numpy.angle. Since evalfr returns a complex number it isn't directly possible to get the "absolute" angle so the issue i'm reporting seems to require a dedicated code to determine a "reference phase" of some sort.
My excuses for my current level of python (or gitHub) doesn't lead me much further than that
The phase correction is only possible when you have the pole-zero structure and the behavior w->0, so you have to compute the initial phase to get the right amount of shift which is typically done with a decision of adding a minus sign attached to the atan2 computation.
When you supply a custom frequency grid then it is trickier to snap to the correct phase since then you have to evaluate more stuff to get to that grid from the pole-zero structure (if there is any, say FRD objects don't have it).
It seems to work with poles, but it does not with zeros.
For a single zero a constant phase of 90º would be expected, it gives -270º instead.
from matplotlib import pyplot as plt
from control.matlab import * # MATLAB-like functions
%matplotlib widget
s = tf('s')
G = (s)
plt.figure()
bode(G, wrap_phase = False)
plt.show()
Activity
SebastienDeriaz commentedon Nov 10, 2020
My (limited) understanding of the function is that bode uses freqresp which uses evalfr and then numpy.angle. Since evalfr returns a complex number it isn't directly possible to get the "absolute" angle so the issue i'm reporting seems to require a dedicated code to determine a "reference phase" of some sort.
My excuses for my current level of python (or gitHub) doesn't lead me much further than that
bnavigator commentedon Nov 10, 2020
Thanks, for bringing this up.
Related issue: #388
You are nevertheless very welcome to practice your Python and GitHub skills by trying to fix the issue and submitting a pull request 🧑🎓
ilayn commentedon Nov 10, 2020
The phase correction is only possible when you have the pole-zero structure and the behavior
w->0, so you have to compute the initial phase to get the right amount of shift which is typically done with a decision of adding a minus sign attached to theatan2computation.When you supply a custom frequency grid then it is trickier to snap to the correct phase since then you have to evaluate more stuff to get to that grid from the pole-zero structure (if there is any, say FRD objects don't have it).
bnavigator commentedon Jan 3, 2021
Resolved in #494. If you think this is not solved, please reopen.
Juan-Gg commentedon Aug 9, 2023
It seems to work with poles, but it does not with zeros.
For a single zero a constant phase of 90º would be expected, it gives -270º instead.