49
49
#
50
50
# $Id: freqplot.py 139 2011-03-30 16:19:59Z murrayrm $
51
51
52
- import scipy as sp
53
52
import numpy as np
54
53
import matplotlib .pyplot as plt
55
54
from .ctrlutil import unwrap
@@ -102,8 +101,8 @@ def nichols_plot(sys_list, omega=None, grid=None):
102
101
103
102
# Convert to Nichols-plot format (phase in degrees,
104
103
# and magnitude in dB)
105
- x = unwrap (sp .degrees (phase ), 360 )
106
- y = 20 * sp .log10 (mag )
104
+ x = unwrap (np .degrees (phase ), 360 )
105
+ y = 20 * np .log10 (mag )
107
106
108
107
# Generate the plot
109
108
plt .plot (x , y )
@@ -183,13 +182,13 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
183
182
# Find the M-contours
184
183
m = m_circles (cl_mags , phase_min = np .min (cl_phases ),
185
184
phase_max = np .max (cl_phases ))
186
- m_mag = 20 * sp .log10 (np .abs (m ))
187
- m_phase = sp .mod (sp .degrees (sp .angle (m )), - 360.0 ) # Unwrap
185
+ m_mag = 20 * np .log10 (np .abs (m ))
186
+ m_phase = np .mod (np .degrees (np .angle (m )), - 360.0 ) # Unwrap
188
187
189
188
# Find the N-contours
190
189
n = n_circles (cl_phases , mag_min = np .min (cl_mags ), mag_max = np .max (cl_mags ))
191
- n_mag = 20 * sp .log10 (np .abs (n ))
192
- n_phase = sp .mod (sp .degrees (sp .angle (n )), - 360.0 ) # Unwrap
190
+ n_mag = 20 * np .log10 (np .abs (n ))
191
+ n_phase = np .mod (np .degrees (np .angle (n )), - 360.0 ) # Unwrap
193
192
194
193
# Plot the contours behind other plot elements.
195
194
# The "phase offset" is used to produce copies of the chart that cover
@@ -247,7 +246,7 @@ def closed_loop_contours(Gcl_mags, Gcl_phases):
247
246
# Compute the contours in Gcl-space. Since we're given closed-loop
248
247
# magnitudes and phases, this is just a case of converting them into
249
248
# a complex number.
250
- Gcl = Gcl_mags * sp .exp (1.j * Gcl_phases )
249
+ Gcl = Gcl_mags * np .exp (1.j * Gcl_phases )
251
250
252
251
# Invert Gcl = Gol/(1+Gol) to map the contours into the open-loop space
253
252
return Gcl / (1.0 - Gcl )
@@ -274,8 +273,8 @@ def m_circles(mags, phase_min=-359.75, phase_max=-0.25):
274
273
"""
275
274
# Convert magnitudes and phase range into a grid suitable for
276
275
# building contours
277
- phases = sp .radians (sp .linspace (phase_min , phase_max , 2000 ))
278
- Gcl_mags , Gcl_phases = sp .meshgrid (10.0 ** (mags / 20.0 ), phases )
276
+ phases = np .radians (np .linspace (phase_min , phase_max , 2000 ))
277
+ Gcl_mags , Gcl_phases = np .meshgrid (10.0 ** (mags / 20.0 ), phases )
279
278
return closed_loop_contours (Gcl_mags , Gcl_phases )
280
279
281
280
@@ -300,8 +299,8 @@ def n_circles(phases, mag_min=-40.0, mag_max=12.0):
300
299
"""
301
300
# Convert phases and magnitude range into a grid suitable for
302
301
# building contours
303
- mags = sp .linspace (10 ** (mag_min / 20.0 ), 10 ** (mag_max / 20.0 ), 2000 )
304
- Gcl_phases , Gcl_mags = sp .meshgrid (sp .radians (phases ), mags )
302
+ mags = np .linspace (10 ** (mag_min / 20.0 ), 10 ** (mag_max / 20.0 ), 2000 )
303
+ Gcl_phases , Gcl_mags = np .meshgrid (np .radians (phases ), mags )
305
304
return closed_loop_contours (Gcl_mags , Gcl_phases )
306
305
307
306
0 commit comments