@@ -714,41 +714,47 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
714
714
if np.any(omega_sys * sys.dt > np.pi) and warn_nyquist:
715
715
warnings.warn("evaluation above Nyquist frequency")
716
716
717
- # Transform frequencies to continuous domain
718
- contour = np.exp(1j * omega * sys.dt)
719
- else:
720
- contour = 1j * omega_sys
717
+ # do indentations in s-plane where it is more convenient
718
+ splane_contour = 1j * omega_sys
721
719
722
720
# Bend the contour around any poles on/near the imaginary axis
723
721
if isinstance(sys, (StateSpace, TransferFunction)) \
724
- and sys.isctime() and indent_direction != 'none':
725
- poles = sys.pole()
726
- if contour[1].imag > indent_radius \
727
- and 0. in poles and not omega_range_given:
722
+ and indent_direction != 'none':
723
+ if sys.isctime():
724
+ splane_poles = sys.pole()
725
+ else:
726
+ # map z-plane poles to s-plane
727
+ splane_poles = np.log(sys.pole())/sys.dt
728
+
729
+ if splane_contour[1].imag > indent_radius \
730
+ and 0. in splane_poles and not omega_range_given:
728
731
# add some points for quarter circle around poles at origin
729
- contour = np.concatenate(
732
+ splane_contour = np.concatenate(
730
733
(1j * np.linspace(0., indent_radius, 50),
731
- contour [1:]))
732
- for i, s in enumerate(contour ):
734
+ splane_contour [1:]))
735
+ for i, s in enumerate(splane_contour ):
733
736
# Find the nearest pole
734
- p = poles[(np.abs(poles - s)).argmin()]
735
-
737
+ p = splane_poles[(np.abs(splane_poles - s)).argmin()]
736
738
# See if we need to indent around it
737
739
if abs(s - p) < indent_radius:
738
740
if p.real < 0 or \
739
741
(p.real == 0 and indent_direction == 'right'):
740
742
# Indent to the right
741
- contour [i] += \
743
+ splane_contour [i] += \
742
744
np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)
743
745
elif p.real > 0 or \
744
746
(p.real == 0 and indent_direction == 'left'):
745
747
# Indent to the left
746
- contour [i] -= \
748
+ splane_contour [i] -= \
747
749
np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)
748
750
else:
749
751
ValueError("unknown value for indent_direction")
750
752
751
- # TODO: add code to indent around discrete poles on unit circle
753
+ # change contour to z-plane if necessary
754
+ if sys.isctime():
755
+ contour = splane_contour
756
+ else:
757
+ contour = np.exp(splane_contour * sys.dt)
752
758
753
759
# Compute the primary curve
754
760
resp = sys(contour)
0 commit comments