@@ -593,66 +593,59 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
593593 np .log10 (omega_limits [1 ]), num = num ,
594594 endpoint = True )
595595
596- # Interpolate between wmin and wmax if a tuple or list are provided
597- elif isinstance (omega , list ) or isinstance (omega , tuple ):
598- # Only accept tuple or list of length 2
599- if len (omega ) != 2 :
600- raise ValueError ("Supported frequency arguments are (wmin,wmax)"
601- "tuple or list, or frequency vector. " )
602- omega = np .logspace (np .log10 (omega [0 ]), np .log10 (omega [1 ]),
603- num = 500 , endpoint = True , base = 10.0 )
604596
605597 for sys in syslist :
606598 if not sys .issiso ():
607599 # TODO: Add MIMO nyquist plots.
608600 raise ControlMIMONotImplemented (
609601 "Nyquist is currently only implemented for SISO systems." )
602+ else :
603+ # Get the magnitude and phase of the system
604+ mag , phase , omega = sys .frequency_response (omega )
610605
611- # Get the magnitude and phase of the system
612- mag , phase , omega = sys .frequency_response (omega )
613-
614- # Compute the primary curve
615- x = mag * np .cos (phase )
616- y = mag * np .sin (phase )
617-
618- if plot :
619- # Plot the primary curve and mirror image
620- p = plt .plot (np .hstack ((x ,x )), np .hstack ((y ,- y )),
621- '-' , color = color , * args , ** kwargs )
622- c = p [0 ].get_color ()
623- ax = plt .gca ()
624- # Plot arrow to indicate Nyquist encirclement orientation
625- ax .arrow (x [0 ], y [0 ], (x [1 ]- x [0 ])/ 2 , (y [1 ]- y [0 ])/ 2 ,
626- fc = c , ec = c , head_width = arrowhead_width ,
627- head_length = arrowhead_length , label = None )
628- ax .arrow (x [- 1 ], - y [- 1 ], (x [- 1 ]- x [- 2 ])/ 2 , (y [- 1 ]- y [- 2 ])/ 2 ,
629- fc = c , ec = c , head_width = arrowhead_width ,
630- head_length = arrowhead_length , label = None )
631-
632- # Mark the -1 point
633- plt .plot ([- 1 ], [0 ], 'r+' )
634-
635- # Label the frequencies of the points
636- if label_freq :
637- ind = slice (None , None , label_freq )
638- for xpt , ypt , omegapt in zip (x [ind ], y [ind ], omega [ind ]):
639- # Convert to Hz
640- f = omegapt / (2 * np .pi )
641-
642- # Factor out multiples of 1000 and limit the
643- # result to the range [-8, 8].
644- pow1000 = max (min (get_pow1000 (f ), 8 ), - 8 )
645-
646- # Get the SI prefix.
647- prefix = gen_prefix (pow1000 )
648-
649- # Apply the text. (Use a space before the text to
650- # prevent overlap with the data.)
651- #
652- # np.round() is used because 0.99... appears
653- # instead of 1.0, and this would otherwise be
654- # truncated to 0.
655- plt .text (xpt , ypt , ' ' +
606+ # Compute the primary curve
607+ x = mag * np .cos (phase )
608+ y = mag * np .sin (phase )
609+
610+ if plot :
611+ # Plot the primary curve and mirror image
612+ p = plt .plot (x , y , '-' , color = color , * args , ** kwargs )
613+ c = p [0 ].get_color ()
614+ ax = plt .gca ()
615+ # Plot arrow to indicate Nyquist encirclement orientation
616+ ax .arrow (x [0 ], y [0 ], (x [1 ]- x [0 ])/ 2 , (y [1 ]- y [0 ])/ 2 , fc = c , ec = c ,
617+ head_width = arrowhead_width ,
618+ head_length = arrowhead_length )
619+
620+ plt .plot (x , - y , '-' , color = c , * args , ** kwargs )
621+ ax .arrow (
622+ x [- 1 ], - y [- 1 ], (x [- 1 ]- x [- 2 ])/ 2 , (y [- 1 ]- y [- 2 ])/ 2 ,
623+ fc = c , ec = c , head_width = arrowhead_width ,
624+ head_length = arrowhead_length )
625+ # Mark the -1 point
626+ plt .plot ([- 1 ], [0 ], 'r+' )
627+
628+ # Label the frequencies of the points
629+ if label_freq :
630+ ind = slice (None , None , label_freq )
631+ for xpt , ypt , omegapt in zip (x [ind ], y [ind ], omega [ind ]):
632+ # Convert to Hz
633+ f = omegapt / (2 * np .pi )
634+
635+ # Factor out multiples of 1000 and limit the
636+ # result to the range [-8, 8].
637+ pow1000 = max (min (get_pow1000 (f ), 8 ), - 8 )
638+
639+ # Get the SI prefix.
640+ prefix = gen_prefix (pow1000 )
641+
642+ # Apply the text. (Use a space before the text to
643+ # prevent overlap with the data.)
644+ #
645+ # np.round() is used because 0.99... appears
646+ # instead of 1.0, and this would otherwise be
647+ # truncated to 0.
648+ plt .text (xpt , ypt , ' ' +
656649 str (int (np .round (f / 1000 ** pow1000 , 0 ))) + ' ' +
657650 prefix + 'Hz' )
658651
0 commit comments