- Notifications
You must be signed in to change notification settings - Fork445
Update pole/zero and root locus plots to use _map/_plot pattern#953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
coveralls commentedDec 29, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
control/sisotool.py Outdated
| importnumpyasnp | ||
| importmatplotlib.pyplotasplt | ||
| importwarnings | ||
| fromfunctoolsimportpartial |
bnavigatorJan 10, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Worth running this throughisort?
warnings andfunctools are stdlib, Numpy and Pyplot external.
control/tests/pzmap_test.py Outdated
| # Legacy return format | ||
| withpytest.warns(DeprecationWarning,match=".* values .* deprecated"): | ||
| poles,zeros=ct.pole_zero_plot(pzdata,plot=False) | ||
| np.testing.assert_equal(poles,sys.poles()) | ||
| np.testing.assert_equal(zeros,sys.zeros()) | ||
| withpytest.warns(DeprecationWarning,match=".* values .* deprecated"): | ||
| poles,zeros=ct.pole_zero_plot(pzdata,plot=True) | ||
| np.testing.assert_equal(poles,sys.poles()) | ||
| np.testing.assert_equal(zeros,sys.zeros()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Parametrize?
bnavigator left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is large, without too extensive review, I would say LGTM.
Uh oh!
There was an error while loading.Please reload this page.
This PR updates pole/zero and root locus plots to use the _map/_plot calling pattern described in#645. The following patterns will work:
Everything is mostly backwards compatible except that the outputs from a _plot function are now an array of Line2D objects instead of the roots and gains. You can still get the original data using the _map function and there is some legacy processing if you used the
plotkeyword to try let some code work without changes.Summary of changes:
_mapfunction and a_plotfunction. You can access the latter via the.plot()method on the response._plotfunctions accept either the output of the_mapfunction or a list of systems (in which case the_mapfunction is called internally). This allows the common pattern ofpole_zero_plot(sys),root_locus_plot(sys)to work as expected.sisotool). Clicking on a portion of the root locus diagram will generate markers at the locations on the loci corresponding to that gain and add a message above the plot giving the frequency and damping ratio for the point that was clicked.print_gainkeyword is replaced withinteractive.Plotkeyword is nowplot(and generates a warning, since it triggers the legacy return values).pzmapandrlocusare still there.control.matlabversion ofrlocusreturnsroots, gains(compatible with MATLAB)This PR is going to break existing code. It would be great if a few people could try this out so that we can make sure we are OK with the changes here.
Examples (from the user documentation):
Pole/zero maps and root locus diagrams provide insights into system response based on the locations of system poles and zeros in the complex plane. The
pole_zero_map()function returns the poles and zeros and can be used to generate a pole/zero plot:A root locus plot shows the location of the closed loop poles of a system as a function of the loop gain:
The grid in the left hand plane shows lines of constant damping ratio as well as arcs corresponding to the frequency of the complex pole. The grid can be turned off using the
gridkeyword. Setting grid toFalse will turn off the grid but show the real and imaginary axis. To completely remove all lines except the root loci, usegrid=’empty’.On systems that support interactive plots, clicking on a location on the root locus diagram will mark the pole locations on all branches of the diagram and display the gain and damping ratio below the plot title:
Root locus diagrams are also supported for discrete time systems, in which case the grid is show inside the unit circle:
Lists of systems can also be given, in which case the root locus diagram for each system is plotted in different colors: