Skip to content

Commit aa92e43

Browse files
committed
initial commit that performs indents in the z-plane
1 parent b61f58d commit aa92e43

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

control/freqplot.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -714,41 +714,47 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
714714
if np.any(omega_sys * sys.dt > np.pi) and warn_nyquist:
715715
warnings.warn("evaluation above Nyquist frequency")
716716

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
721719

722720
# Bend the contour around any poles on/near the imaginary axis
723721
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:
728731
# add some points for quarter circle around poles at origin
729-
contour = np.concatenate(
732+
splane_contour = np.concatenate(
730733
(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):
733736
# Find the nearest pole
734-
p = poles[(np.abs(poles - s)).argmin()]
735-
737+
p = splane_poles[(np.abs(splane_poles - s)).argmin()]
736738
# See if we need to indent around it
737739
if abs(s - p) < indent_radius:
738740
if p.real < 0 or \
739741
(p.real == 0 and indent_direction == 'right'):
740742
# Indent to the right
741-
contour[i] += \
743+
splane_contour[i] += \
742744
np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)
743745
elif p.real > 0 or \
744746
(p.real == 0 and indent_direction == 'left'):
745747
# Indent to the left
746-
contour[i] -= \
748+
splane_contour[i] -= \
747749
np.sqrt(indent_radius ** 2 - (s-p).imag ** 2)
748750
else:
749751
ValueError("unknown value for indent_direction")
750752

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)
752758

753759
# Compute the primary curve
754760
resp = sys(contour)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy