4949#
5050# $Id: freqplot.py 139 2011-03-30 16:19:59Z murrayrm $
5151
52- import scipy as sp
5352import numpy as np
5453import matplotlib .pyplot as plt
5554from .ctrlutil import unwrap
@@ -102,8 +101,8 @@ def nichols_plot(sys_list, omega=None, grid=None):
102101
103102 # Convert to Nichols-plot format (phase in degrees,
104103 # 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 )
107106
108107 # Generate the plot
109108 plt .plot (x , y )
@@ -183,13 +182,13 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
183182 # Find the M-contours
184183 m = m_circles (cl_mags , phase_min = np .min (cl_phases ),
185184 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
188187
189188 # Find the N-contours
190189 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
193192
194193 # Plot the contours behind other plot elements.
195194 # 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):
247246 # Compute the contours in Gcl-space. Since we're given closed-loop
248247 # magnitudes and phases, this is just a case of converting them into
249248 # a complex number.
250- Gcl = Gcl_mags * sp .exp (1.j * Gcl_phases )
249+ Gcl = Gcl_mags * np .exp (1.j * Gcl_phases )
251250
252251 # Invert Gcl = Gol/(1+Gol) to map the contours into the open-loop space
253252 return Gcl / (1.0 - Gcl )
@@ -274,8 +273,8 @@ def m_circles(mags, phase_min=-359.75, phase_max=-0.25):
274273 """
275274 # Convert magnitudes and phase range into a grid suitable for
276275 # 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 )
279278 return closed_loop_contours (Gcl_mags , Gcl_phases )
280279
281280
@@ -300,8 +299,8 @@ def n_circles(phases, mag_min=-40.0, mag_max=12.0):
300299 """
301300 # Convert phases and magnitude range into a grid suitable for
302301 # 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 )
305304 return closed_loop_contours (Gcl_mags , Gcl_phases )
306305
307306
0 commit comments