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

Commit17c4a95

Browse files
committed
fixed issues identified in review
1 parent03f87a3 commit17c4a95

File tree

3 files changed

+81
-43
lines changed

3 files changed

+81
-43
lines changed

‎control/freqplot.py

Lines changed: 73 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,19 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
217217
# If no axes present, create them from scratch
218218
ifax_magisNoneorax_phaseisNone:
219219
plt.clf()
220-
ax_mag=plt.subplot(211,label='control-bode-magnitude')
221-
ax_phase=plt.subplot(212,label='control-bode-phase',
220+
ax_mag=plt.subplot(211,
221+
label='control-bode-magnitude')
222+
ax_phase=plt.subplot(212,
223+
label='control-bode-phase',
222224
sharex=ax_mag)
223225

224226
# Magnitude plot
225227
ifdB:
226228
pltline=ax_mag.semilogx(omega_plot,20*np.log10(mag),
227229
*args,**kwargs)
228230
else:
229-
230231
pltline=ax_mag.loglog(omega_plot,mag,*args,**kwargs)
231232

232-
233233
ifnyquistfrq_plot:
234234
ax_mag.axvline(nyquistfrq_plot,
235235
color=pltline[0].get_color())
@@ -259,69 +259,96 @@ def bode_plot(syslist, omega=None, dB=None, Hz=None, deg=None,
259259
ifHz:
260260
Wcg,Wcp=Wcg/(2*math.pi),Wcp/(2*math.pi)
261261

262-
ax_mag.axhline(y=0ifdBelse1,color='k',linestyle=':',zorder=-20)
262+
ax_mag.axhline(y=0ifdBelse1,color='k',linestyle=':',
263+
zorder=-20)
263264
ax_phase.axhline(y=phase_limitifdegelsemath.radians(phase_limit),
264265
color='k',linestyle=':',zorder=-20)
265266
mag_ylim=ax_mag.get_ylim()
266267
phase_ylim=ax_phase.get_ylim()
267268

268269
ifpm!=float('inf')andWcp!=float('nan'):
269270
ifdB:
270-
ax_mag.semilogx([Wcp,Wcp], [0.,-1e5],color='k',linestyle=':',zorder=-20)
271+
ax_mag.semilogx([Wcp,Wcp], [0.,-1e5],
272+
color='k',linestyle=':',
273+
zorder=-20)
271274
else:
272-
ax_mag.loglog([Wcp,Wcp], [1.,1e-8],color='k',linestyle=':',zorder=-20)
275+
ax_mag.loglog([Wcp,Wcp], [1.,1e-8],color='k',
276+
linestyle=':',zorder=-20)
273277

274278
ifdeg:
275-
ax_phase.semilogx([Wcp,Wcp], [1e5,phase_limit+pm],
276-
color='k',linestyle=':',zorder=-20)
277-
ax_phase.semilogx([Wcp,Wcp], [phase_limit+pm,phase_limit],
279+
ax_phase.semilogx([Wcp,Wcp],
280+
[1e5,phase_limit+pm],
281+
color='k',linestyle=':',
282+
zorder=-20)
283+
ax_phase.semilogx([Wcp,Wcp],
284+
[phase_limit+pm,phase_limit],
278285
color='k',zorder=-20)
279286
else:
280-
ax_phase.semilogx([Wcp,Wcp], [1e5,math.radians(phase_limit)+
281-
math.radians(pm)],
282-
color='k',linestyle=':',zorder=-20)
283-
ax_phase.semilogx([Wcp,Wcp], [math.radians(phase_limit)+math.radians(pm),
284-
math.radians(phase_limit)],
287+
ax_phase.semilogx([Wcp,Wcp],
288+
[1e5,math.radians(phase_limit)+
289+
math.radians(pm)],
290+
color='k',linestyle=':',
291+
zorder=-20)
292+
ax_phase.semilogx([Wcp,Wcp],
293+
[math.radians(phase_limit)+
294+
math.radians(pm),
295+
math.radians(phase_limit)],
285296
color='k',zorder=-20)
286297

287298
ifgm!=float('inf')andWcg!=float('nan'):
288299
ifdB:
289-
ax_mag.semilogx([Wcg,Wcg], [-20.*np.log10(gm),-1e5],
290-
color='k',linestyle=':',zorder=-20)
300+
ax_mag.semilogx([Wcg,Wcg],
301+
[-20.*np.log10(gm),-1e5],
302+
color='k',linestyle=':',
303+
zorder=-20)
291304
ax_mag.semilogx([Wcg,Wcg], [0,-20*np.log10(gm)],
292305
color='k',zorder=-20)
293306
else:
294-
ax_mag.loglog([Wcg,Wcg], [1./gm,1e-8],color='k',linestyle=':',zorder=-20)
295-
ax_mag.loglog([Wcg,Wcg], [1.,1./gm],color='k',zorder=-20)
307+
ax_mag.loglog([Wcg,Wcg],
308+
[1./gm,1e-8],color='k',
309+
linestyle=':',zorder=-20)
310+
ax_mag.loglog([Wcg,Wcg],
311+
[1.,1./gm],color='k',zorder=-20)
296312

297313
ifdeg:
298314
ax_phase.semilogx([Wcg,Wcg], [1e-8,phase_limit],
299-
color='k',linestyle=':',zorder=-20)
315+
color='k',linestyle=':',
316+
zorder=-20)
300317
else:
301-
ax_phase.semilogx([Wcg,Wcg], [1e-8,math.radians(phase_limit)],
302-
color='k',linestyle=':',zorder=-20)
318+
ax_phase.semilogx([Wcg,Wcg],
319+
[1e-8,math.radians(phase_limit)],
320+
color='k',linestyle=':',
321+
zorder=-20)
303322

304323
ax_mag.set_ylim(mag_ylim)
305324
ax_phase.set_ylim(phase_ylim)
306325

307326
ifsisotool:
308-
ax_mag.text(0.04,0.06,'G.M.: %.2f %s\nFreq: %.2f %s'%
327+
ax_mag.text(0.04,0.06,
328+
'G.M.: %.2f %s\nFreq: %.2f %s'%
309329
(20*np.log10(gm)ifdBelsegm,
310-
'dB 'ifdBelse'',Wcg,'Hz'ifHzelse'rad/s'),
311-
horizontalalignment='left',verticalalignment='bottom',
330+
'dB 'ifdBelse'',
331+
Wcg,'Hz'ifHzelse'rad/s'),
332+
horizontalalignment='left',
333+
verticalalignment='bottom',
312334
transform=ax_mag.transAxes,
313335
fontsize=8ifint(matplotlib.__version__[0])==1else6)
314-
ax_phase.text(0.04,0.06,'P.M.: %.2f %s\nFreq: %.2f %s'%
336+
ax_phase.text(0.04,0.06,
337+
'P.M.: %.2f %s\nFreq: %.2f %s'%
315338
(pmifdegelsemath.radians(pm),
316-
'deg'ifdegelse'rad',Wcp,'Hz'ifHzelse'rad/s'),
317-
horizontalalignment='left',verticalalignment='bottom',
318-
transform=ax_phase.transAxes,
339+
'deg'ifdegelse'rad',
340+
Wcp,'Hz'ifHzelse'rad/s'),
341+
horizontalalignment='left',
342+
verticalalignment='bottom',
343+
transform=ax_phase.transAxes,
319344
fontsize=8ifint(matplotlib.__version__[0])==1else6)
320345
else:
321346
plt.suptitle('Gm = %.2f %s(at %.2f %s), Pm = %.2f %s (at %.2f %s)'%
322347
(20*np.log10(gm)ifdBelsegm,
323-
'dB 'ifdBelse'\b',Wcg,'Hz'ifHzelse'rad/s',
324-
pmifdegelsemath.radians(pm),'deg'ifdegelse'rad',
348+
'dB 'ifdBelse'\b',
349+
Wcg,'Hz'ifHzelse'rad/s',
350+
pmifdegelsemath.radians(pm),
351+
'deg'ifdegelse'rad',
325352
Wcp,'Hz'ifHzelse'rad/s'))
326353

327354
ifnyquistfrq_plot:
@@ -336,12 +363,19 @@ def gen_zero_centered_series(val_min, val_max, period):
336363
returnnp.arange(v1,v2+1)*period
337364
ifdeg:
338365
ylim=ax_phase.get_ylim()
339-
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],ylim[1],45.))
340-
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],ylim[1],15.),minor=True)
366+
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],
367+
ylim[1],45.))
368+
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],
369+
ylim[1],15.),
370+
minor=True)
341371
else:
342372
ylim=ax_phase.get_ylim()
343-
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],ylim[1],math.pi/4.))
344-
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],ylim[1],math.pi/12.),
373+
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],
374+
ylim[1],
375+
math.pi/4.))
376+
ax_phase.set_yticks(gen_zero_centered_series(ylim[0],
377+
ylim[1],
378+
math.pi/12.),
345379
minor=True)
346380
ax_phase.grid(FalseifmarginselseTrue,which='both')
347381
# ax_mag.grid(which='minor', alpha=0.3)
@@ -350,15 +384,17 @@ def gen_zero_centered_series(val_min, val_max, period):
350384
# ax_phase.grid(which='major', alpha=0.9)
351385

352386
# Label the frequency axis
353-
ax_phase.set_xlabel("Frequency (Hz)"ifHzelse"Frequency (rad/sec)")
387+
ax_phase.set_xlabel("Frequency (Hz)"ifHz
388+
else"Frequency (rad/sec)")
354389

355390
iflen(syslist)==1:
356391
returnmags[0],phases[0],omegas[0]
357392
else:
358393
returnmags,phases,omegas
359394

360395

361-
defnyquist_plot(syslist,omega=None,Plot=True,color=None,labelFreq=0,*args,**kwargs):
396+
defnyquist_plot(syslist,omega=None,Plot=True,color=None,
397+
labelFreq=0,*args,**kwargs):
362398
"""
363399
Nyquist plot for a system
364400

‎control/sisotool.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
importmatplotlib.pyplotasplt
88
importwarnings
99

10-
defsisotool(sys,kvect=None,xlim_rlocus=None,ylim_rlocus=None,plotstr_rlocus='b'ifint(matplotlib.__version__[0])==1else'C0',rlocus_grid=False,omega=None,dB=None,Hz=None,deg=None,omega_limits=None,omega_num=None,margins_bode=True,tvect=None):
11-
12-
"""Sisotool
13-
14-
Sisotool style collection of plots inspired by the matlab sisotool.
10+
defsisotool(sys,kvect=None,xlim_rlocus=None,ylim_rlocus=None,
11+
plotstr_rlocus='b'ifint(matplotlib.__version__[0])==1else'C0',
12+
rlocus_grid=False,omega=None,dB=None,Hz=None,
13+
deg=None,omega_limits=None,omega_num=None,
14+
margins_bode=True,tvect=None):
15+
"""
16+
Sisotool style collection of plots inspired by MATLAB's sisotool.
1517
The left two plots contain the bode magnitude and phase diagrams.
1618
The top right plot is a clickable root locus plot, clicking on the
1719
root locus will change the gain of the system. The bottom left plot

‎control/timeresp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def forced_response(sys, T=None, U=0., X0=0., transpose=False,
375375
def_get_ss_simo(sys,input=None,output=None):
376376
"""Return a SISO or SIMO state-space version of sys
377377
378-
If input is notsfpecified, select first input and issue warning
378+
If input is notspecified, select first input and issue warning
379379
"""
380380
sys_ss=_convertToStateSpace(sys)
381381
ifsys_ss.issiso():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp