Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2016386

Browse files
committed
get rid of deprecated scipy calls
1 parentb743fb8 commit2016386

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

‎control/freqplot.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@
4040
# SUCH DAMAGE.
4141
#
4242
# $Id$
43+
44+
importmath
45+
4346
importmatplotlibasmpl
4447
importmatplotlib.pyplotasplt
45-
importscipyassp
4648
importnumpyasnp
47-
importmath
49+
4850
from .ctrlutilimportunwrap
4951
from .bdalgimportfeedback
5052
from .marginsimportstability_margins
@@ -184,12 +186,12 @@ def bode_plot(syslist, omega=None,
184186
ifHz:
185187
omega_limits*=2.*math.pi
186188
ifomega_num:
187-
omega=sp.logspace(np.log10(omega_limits[0]),
189+
omega=np.logspace(np.log10(omega_limits[0]),
188190
np.log10(omega_limits[1]),
189191
num=omega_num,
190192
endpoint=True)
191193
else:
192-
omega=sp.logspace(np.log10(omega_limits[0]),
194+
omega=np.logspace(np.log10(omega_limits[0]),
193195
np.log10(omega_limits[1]),
194196
endpoint=True)
195197

@@ -530,8 +532,8 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
530532
phase=np.squeeze(phase_tmp)
531533

532534
# Compute the primary curve
533-
x=sp.multiply(mag,sp.cos(phase))
534-
y=sp.multiply(mag,sp.sin(phase))
535+
x=np.multiply(mag,np.cos(phase))
536+
y=np.multiply(mag,np.sin(phase))
535537

536538
ifplot:
537539
# Plot the primary curve and mirror image
@@ -557,7 +559,7 @@ def nyquist_plot(syslist, omega=None, plot=True, label_freq=0,
557559
ind=slice(None,None,label_freq)
558560
forxpt,ypt,omegaptinzip(x[ind],y[ind],omega[ind]):
559561
# Convert to Hz
560-
f=omegapt/ (2*sp.pi)
562+
f=omegapt/ (2*np.pi)
561563

562564
# Factor out multiples of 1000 and limit the
563565
# result to the range [-8, 8].

‎control/nichols.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#
5050
# $Id: freqplot.py 139 2011-03-30 16:19:59Z murrayrm $
5151

52-
importscipyassp
5352
importnumpyasnp
5453
importmatplotlib.pyplotasplt
5554
from .ctrlutilimportunwrap
@@ -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
returnGcl/(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
returnclosed_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
returnclosed_loop_contours(Gcl_mags,Gcl_phases)
306305

307306

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp