z-to-s plane mapping results in small numerical errors so assume s-pl… · python-control/python-control@a948186
@@ -718,16 +718,22 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
718718splane_contour = 1j * omega_sys
719719720720# 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.
721723if isinstance(sys, (StateSpace, TransferFunction)) \
722724and indent_direction != 'none':
723725if sys.isctime():
724726splane_poles = sys.pole()
725727else:
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
728733729734if 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:
731737# add some points for quarter circle around poles at origin
732738splane_contour = np.concatenate(
733739 (1j * np.linspace(0., indent_radius, 50),
@@ -737,13 +743,13 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
737743p = splane_poles[(np.abs(splane_poles - s)).argmin()]
738744# See if we need to indent around it
739745if 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'):
742748# Indent to the right
743749splane_contour[i] += \
744750np.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'):
747753# Indent to the left
748754splane_contour[i] -= \
749755np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)