@@ -718,16 +718,22 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
718
718
splane_contour = 1j * omega_sys
719
719
720
720
# Bend the contour around any poles on/near the imaginary axis
721
+ # TODO: smarter indent radius that depends on dcgain of system
722
+ # and timebase of discrete system.
721
723
if isinstance (sys , (StateSpace , TransferFunction )) \
722
724
and indent_direction != 'none' :
723
725
if sys .isctime ():
724
726
splane_poles = sys .pole ()
725
727
else :
726
- # map z-plane poles to s-plane
727
- splane_poles = np .log (sys .pole ())/ sys .dt
728
+ # map z-plane poles to s-plane, ignoring any at the origin
729
+ # because we don't need to indent for them
730
+ zplane_poles = sys .pole ()
731
+ zplane_poles = zplane_poles [~ np .isclose (abs (zplane_poles ), 0. )]
732
+ splane_poles = np .log (zplane_poles )/ sys .dt
728
733
729
734
if splane_contour [1 ].imag > indent_radius \
730
- and 0. in splane_poles and not omega_range_given :
735
+ and np .any (np .isclose (abs (splane_poles ), 0 )) \
736
+ and not omega_range_given :
731
737
# add some points for quarter circle around poles at origin
732
738
splane_contour = np .concatenate (
733
739
(1j * np .linspace (0. , indent_radius , 50 ),
@@ -737,13 +743,13 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
737
743
p = splane_poles [(np .abs (splane_poles - s )).argmin ()]
738
744
# See if we need to indent around it
739
745
if abs (s - p ) < indent_radius :
740
- if p .real < 0 or \
741
- ( p . real == 0 and indent_direction == 'right' ):
746
+ if p .real < 0 or ( np . isclose ( p . real , 0 ) \
747
+ and indent_direction == 'right' ):
742
748
# Indent to the right
743
749
splane_contour [i ] += \
744
750
np .sqrt (indent_radius ** 2 - (s - p ).imag ** 2 )
745
- elif p .real > 0 or \
746
- ( p . real == 0 and indent_direction == 'left' ):
751
+ elif p .real > 0 or ( np . isclose ( p . real , 0 ) \
752
+ and indent_direction == 'left' ):
747
753
# Indent to the left
748
754
splane_contour [i ] -= \
749
755
np .sqrt (indent_radius ** 2 - (s - p ).imag ** 2 )
0 commit comments