25
25
from .iosys import isdtime
26
26
from .xferfcn import _convert_to_transfer_function
27
27
from .exception import ControlMIMONotImplemented
28
- from .sisotool import _SisotoolUpdate
29
28
from .grid import sgrid , zgrid
30
29
from . import config
31
30
import warnings
@@ -76,7 +75,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
76
75
ax : :class:`matplotlib.axes.Axes`
77
76
Axes on which to create root locus plot
78
77
initial_gain : float, optional
79
- Used by :func:`sisotool` to indicate initial gain.
78
+ Specify the initial gain to use when marking current gain. [TODO: update]
80
79
81
80
Returns
82
81
-------
@@ -100,17 +99,12 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
100
99
print_gain = config ._get_param (
101
100
'rlocus' , 'print_gain' , print_gain , _rlocus_defaults )
102
101
103
- # Check for sisotool mode
104
- sisotool = kwargs .get ('sisotool' , False )
105
-
106
- # make sure siso. sisotool has different requirements
107
- if not sys .issiso () and not sisotool :
102
+ if not sys .issiso ():
108
103
raise ControlMIMONotImplemented (
109
104
'sys must be single-input single-output (SISO)' )
110
105
111
- sys_loop = sys [0 ,0 ]
112
106
# Convert numerator and denominator to polynomials if they aren't
113
- ( nump , denp ) = _systopoly1d (sys_loop )
107
+ nump , denp = _systopoly1d (sys )
114
108
115
109
# if discrete-time system and if xlim and ylim are not given,
116
110
# that we a view of the unit circle
@@ -128,31 +122,30 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
128
122
root_array = _RLSortRoots (root_array )
129
123
recompute_on_zoom = False
130
124
131
- if sisotool :
132
- start_roots = _RLFindRoots (nump , denp , initial_gain )
133
-
134
125
# Make sure there were no extraneous keywords
135
- if not sisotool and kwargs :
126
+ if kwargs :
136
127
raise TypeError ("unrecognized keywords: " , str (kwargs ))
137
128
138
129
# Create the Plot
139
130
if plot :
140
- if sisotool :
141
- fig = kwargs ['fig' ]
142
- ax = fig .axes [1 ]
143
- else :
144
- if ax is None :
145
- ax = plt .gca ()
146
- fig = ax .figure
131
+ if ax is None :
132
+ ax = plt .gca ()
147
133
ax .set_title ('Root Locus' )
134
+ fig = ax .figure
135
+
136
+ # TODO: get rid of extra variable start_roots
137
+ if initial_gain is not None :
138
+ start_roots = _RLFindRoots (nump , denp , initial_gain )
139
+ else :
140
+ start_roots = None
148
141
149
- if print_gain and not sisotool :
142
+ if print_gain and start_roots is None :
150
143
fig .canvas .mpl_connect (
151
144
'button_release_event' ,
152
145
partial (_RLClickDispatcher , sys = sys , fig = fig ,
153
- ax_rlocus = fig . axes [ 0 ] , plotstr = plotstr ))
154
- elif sisotool :
155
- fig . axes [ 1 ] .plot (
146
+ ax_rlocus = ax , plotstr = plotstr ))
147
+ elif start_roots is not None :
148
+ ax .plot (
156
149
[root .real for root in start_roots ],
157
150
[root .imag for root in start_roots ],
158
151
marker = 's' , markersize = 6 , zorder = 20 , color = 'k' , label = 'gain_point' )
@@ -165,14 +158,6 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
165
158
"Clicked at: %10.4g%+10.4gj gain: %10.4g damp: %10.4g" %
166
159
(s .real , s .imag , initial_gain , zeta ),
167
160
fontsize = 12 if int (mpl .__version__ [0 ]) == 1 else 10 )
168
- fig .canvas .mpl_connect (
169
- 'button_release_event' ,
170
- partial (_RLClickDispatcher , sys = sys , fig = fig ,
171
- ax_rlocus = fig .axes [1 ], plotstr = plotstr ,
172
- sisotool = sisotool ,
173
- bode_plot_params = kwargs ['bode_plot_params' ],
174
- tvect = kwargs ['tvect' ]))
175
-
176
161
177
162
if recompute_on_zoom :
178
163
# update gains and roots when xlim/ylim change. Only then are
@@ -526,7 +511,7 @@ def _RLZoomDispatcher(event, sys, ax_rlocus, plotstr):
526
511
scalex = False , scaley = False )
527
512
528
513
529
- def _RLClickDispatcher (event , sys , fig , ax_rlocus , plotstr , sisotool = False ,
514
+ def _RLClickDispatcher (event , sys , fig , ax_rlocus , plotstr ,
530
515
bode_plot_params = None , tvect = None ):
531
516
"""Rootlocus plot click dispatcher"""
532
517
@@ -536,15 +521,14 @@ def _RLClickDispatcher(event, sys, fig, ax_rlocus, plotstr, sisotool=False,
536
521
{'zoom rect' , 'pan/zoom' }:
537
522
538
523
# if a point is clicked on the rootlocus plot visually emphasize it
539
- K = _RLFeedbackClicksPoint (event , sys , fig , ax_rlocus , sisotool )
540
- if sisotool and K is not None :
541
- _SisotoolUpdate (sys , fig , K , bode_plot_params , tvect )
524
+ K = _RLFeedbackClicksPoint (
525
+ event , sys , fig , ax_rlocus , show_clicked = False )
542
526
543
527
# Update the canvas
544
528
fig .canvas .draw ()
545
529
546
530
547
- def _RLFeedbackClicksPoint (event , sys , fig , ax_rlocus , sisotool = False ):
531
+ def _RLFeedbackClicksPoint (event , sys , fig , ax_rlocus , show_clicked = False ):
548
532
"""Display root-locus gain feedback point for clicks on root-locus plot"""
549
533
sys_loop = sys [0 ,0 ]
550
534
(nump , denp ) = _systopoly1d (sys_loop )
@@ -591,16 +575,20 @@ def _RLFeedbackClicksPoint(event, sys, fig, ax_rlocus, sisotool=False):
591
575
# Remove the previous line
592
576
_removeLine (label = 'gain_point' , ax = ax_rlocus )
593
577
594
- # Visualise clicked point, display all roots for sisotool mode
595
- if sisotool :
578
+ if show_clicked :
579
+ # Visualise clicked point, display all roots
596
580
root_array = _RLFindRoots (nump , denp , K .real )
597
581
ax_rlocus .plot (
598
582
[root .real for root in root_array ],
599
583
[root .imag for root in root_array ],
600
- marker = 's' , markersize = 6 , zorder = 20 , label = 'gain_point' , color = 'k' )
584
+ marker = 's' , markersize = 6 , zorder = 20 , label = 'gain_point' ,
585
+ color = 'k' )
601
586
else :
602
- ax_rlocus .plot (s .real , s .imag , 'k.' , marker = 's' , markersize = 8 ,
603
- zorder = 20 , label = 'gain_point' )
587
+ # Just show the clicked point
588
+ # TODO: should we keep this?
589
+ ax_rlocus .plot (
590
+ s .real , s .imag , 'k.' , marker = 's' , markersize = 8 , zorder = 20 ,
591
+ label = 'gain_point' )
604
592
605
593
return K .real
606
594
0 commit comments