Skip to content

Commit 9c68f44

Browse files
committed
* Changed function names to be more consistent with python coding
standards (PEP 8): StepReponse is now step_response, etc. No changes in control.matlab interface. * Changed version number (for next release) to 0.5a due to changes in call signatures.
1 parent a7aed0a commit 9c68f44

21 files changed

Lines changed: 172 additions & 138 deletions

ChangeLog

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
2011-08-07 Richard Murray <murray@malabar.local>
2+
3+
* examples/secord-matlab.py, examples/pvtol-nested-ss.py,
4+
examples/test-response.py, examples/pvtol-nested.py: fixed small bug
5+
in order of output arguments for step command
6+
7+
2011-08-06 Richard Murray <murray@malabar.local>
8+
9+
* src/matlab.py (ngrid): copy documentation from nichols_grid
10+
11+
* src/__init__.py: changed import commands to import specific
12+
functions rather than '*' (better modularity)
13+
14+
* src/freqplot.py: default function names are now bode_plot,
15+
nyquist_plot and gangof4_plot (still with aliases to non-"_plot"
16+
versions)
17+
18+
* src/nichols.py (nichols_plot): updated nichols to nichols_plot for
19+
consistency with other python-control plotting functions. Set up
20+
alias for original name
21+
22+
* src/margins.py: StabilityMargins, PhaseCrossoverFrequencies ->
23+
stability_margins, phase_crossover_frequencies
24+
25+
* src/phaseplot.py: changed PhasePlot and boxgrid to phase_plot,
26+
box_grid
27+
28+
* src/timeresp.py: changed ForcedReponse, InitialReponse,
29+
ImpulseReponse and StepResponse to forced_response,
30+
initial_response, impulse_response and step_response.
31+
32+
* src/rlocus.py: changed RootLocus to root_locus for better
33+
compatability with PEP 8. Also updated unit tests and examples.
34+
135
2011-07-25 Richard Murray <murray@malabar.local>
236

337
* tests/phaseplot_test.py: updated unit tests to use new call

examples/genswitch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import matplotlib.pyplot as mpl
1010
from scipy.integrate import odeint
1111
from matplotlib.mlab import frange
12-
from control import PhasePlot, boxgrid
12+
from control import phase_plot, box_grid
1313

1414
# Simple model of a genetic switch
1515
#
@@ -68,7 +68,7 @@ def genswitch(y, t, mu=4, n=2):
6868
# Phase portrait
6969
mpl.figure(2); mpl.clf(); # subplot(221);
7070
mpl.axis([0, 5, 0, 5]); # set(gca, 'DataAspectRatio', [1, 1, 1]);
71-
PhasePlot(genswitch, X0 = boxgrid([0, 5, 6], [0, 5, 6]), T = 10,
71+
phase_plot(genswitch, X0 = box_grid([0, 5, 6], [0, 5, 6]), T = 10,
7272
timepts = [0.2, 0.6, 1.2])
7373

7474
# Add the stable equilibrium points

examples/phaseplots.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import numpy as np
88
import matplotlib.pyplot as mpl
9-
from control.phaseplot import PhasePlot
9+
from control.phaseplot import phase_plot
1010
from numpy import pi
1111

1212
# Clear out any figures that are present
@@ -26,7 +26,7 @@ def invpend_ode(x, t, m=1., l=1., b=0.2, g=1):
2626
mpl.title('Inverted pendlum')
2727

2828
# Outer trajectories
29-
PhasePlot(invpend_ode,
29+
phase_plot(invpend_ode,
3030
X0 = [ [-2*pi, 1.6], [-2*pi, 0.5], [-1.8, 2.1],
3131
[-1, 2.1], [4.2, 2.1], [5, 2.1],
3232
[2*pi, -1.6], [2*pi, -0.5], [1.8, -2.1],
@@ -36,7 +36,7 @@ def invpend_ode(x, t, m=1., l=1., b=0.2, g=1):
3636

3737
# Separatrices
3838
mpl.hold(True);
39-
PhasePlot(invpend_ode, X0 = [[-2.3056, 2.1], [2.3056, -2.1]], T=6, lingrid=0)
39+
phase_plot(invpend_ode, X0 = [[-2.3056, 2.1], [2.3056, -2.1]], T=6, lingrid=0)
4040
mpl.show();
4141

4242
#
@@ -48,15 +48,15 @@ def oscillator_ode(x, t, m=1., b=1, k=1):
4848

4949
# Generate a vector plot for the damped oscillator
5050
mpl.figure(); mpl.clf();
51-
PhasePlot(oscillator_ode, [-1, 1, 10], [-1, 1, 10], 0.15);
51+
phase_plot(oscillator_ode, [-1, 1, 10], [-1, 1, 10], 0.15);
5252
mpl.hold(True); mpl.plot([0], [0], '.');
5353
# a=gca; set(a,'FontSize',20); set(a,'DataAspectRatio',[1,1,1]);
5454
mpl.xlabel('x1'); mpl.ylabel('x2');
5555

5656
# Generate a phase plot for the damped oscillator
5757
mpl.figure(); mpl.clf();
5858
mpl.axis([-1, 1, -1, 1]); # set(gca, 'DataAspectRatio', [1, 1, 1]);
59-
PhasePlot(oscillator_ode,
59+
phase_plot(oscillator_ode,
6060
X0 = [
6161
[-1, 1], [-0.3, 1], [0, 1], [0.25, 1], [0.5, 1], [0.75, 1], [1, 1],
6262
[1, -1], [0.3, -1], [0, -1], [-0.25, -1], [-0.5, -1], [-0.75, -1], [-1, -1]
@@ -81,7 +81,7 @@ def saddle_ode(x, t):
8181
m = 1; b = 1; k = 1; # default values
8282
mpl.figure(); mpl.clf();
8383
mpl.axis([-1, 1, -1, 1]); # set(gca, 'DataAspectRatio', [1 1 1]);
84-
PhasePlot(oscillator_ode,
84+
phase_plot(oscillator_ode,
8585
X0 = [
8686
[-1,1], [-0.3,1], [0,1], [0.25,1], [0.5,1], [0.7,1], [1,1], [1.3,1],
8787
[1,-1], [0.3,-1], [0,-1], [-0.25,-1], [-0.5,-1], [-0.7,-1], [-1,-1],
@@ -95,7 +95,7 @@ def saddle_ode(x, t):
9595
# Saddle
9696
mpl.figure(); mpl.clf();
9797
mpl.axis([-1, 1, -1, 1]); # set(gca, 'DataAspectRatio', [1 1 1]);
98-
PhasePlot(saddle_ode, scale = 2, timepts = [0.2, 0.5, 0.8], X0 =
98+
phase_plot(saddle_ode, scale = 2, timepts = [0.2, 0.5, 0.8], X0 =
9999
[ [-1, -1], [1, 1],
100100
[-1, -0.95], [-1, -0.9], [-1, -0.8], [-1, -0.6], [-1, -0.4], [-1, -0.2],
101101
[-0.95, -1], [-0.9, -1], [-0.8, -1], [-0.6, -1], [-0.4, -1], [-0.2, -1],
@@ -111,7 +111,7 @@ def saddle_ode(x, t):
111111
m = 1; b = 0; k = 1; # zero damping
112112
mpl.figure(); mpl.clf();
113113
mpl.axis([-1, 1, -1, 1]); # set(gca, 'DataAspectRatio', [1 1 1]);
114-
PhasePlot(oscillator_ode, timepts =
114+
phase_plot(oscillator_ode, timepts =
115115
[pi/6, pi/3, pi/2, 2*pi/3, 5*pi/6, pi, 7*pi/6, 4*pi/3, 9*pi/6, 5*pi/3, 11*pi/6, 2*pi],
116116
X0 = [ [0.2,0], [0.4,0], [0.6,0], [0.8,0], [1,0], [1.2,0], [1.4,0] ],
117117
T = np.linspace(0, 20, 200), parms = (m, b, k));

examples/pvtol-lqr.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@
111111

112112
# Step response for the first input
113113
H1ax = ss(Ax - Bx*K1a[0,lat], Bx*K1a[0,lat]*xd[lat,:], Cx, Dx);
114-
(Tx, Yx) = step(H1ax, T=linspace(0,10,100));
114+
(Yx, Tx) = step(H1ax, T=linspace(0,10,100));
115115

116116
# Step response for the second input
117117
H1ay = ss(Ay - By*K1a[1,alt], By*K1a[1,alt]*yd[alt,:], Cy, Dy);
118-
(Ty, Yy) = step(H1ay, T=linspace(0,10,100));
118+
(Yy, Ty) = step(H1ay, T=linspace(0,10,100));
119119

120120
subplot(221); title("Identity weights")
121121
# plot(T, Y[:,1, 1], '-', T, Y[:,2, 2], '--'); hold(True);
@@ -136,9 +136,9 @@
136136
Qu1c = (200**2)*diag([1, 1]); (K1c, X, E) = lqr(A, B, Qx1, Qu1c);
137137
H1cx = ss(Ax - Bx*K1c[0,lat], Bx*K1c[0,lat]*xd[lat,:],Cx, Dx);
138138

139-
[T1, Y1] = step(H1ax, T=linspace(0,10,100));
140-
[T2, Y2] = step(H1bx, T=linspace(0,10,100));
141-
[T3, Y3] = step(H1cx, T=linspace(0,10,100));
139+
[Y1, T1] = step(H1ax, T=linspace(0,10,100));
140+
[Y2, T2] = step(H1bx, T=linspace(0,10,100));
141+
[Y3, T3] = step(H1cx, T=linspace(0,10,100));
142142

143143
subplot(222); title("Effect of input weights")
144144
plot(T1.T, Y1.T, 'b-'); hold(True);
@@ -160,8 +160,8 @@
160160
H2y = ss(Ay - By*K2[1,alt], By*K2[1,alt]*yd[alt,:], Cy, Dy);
161161

162162
subplot(223); title("Output weighting")
163-
[T2x, Y2x] = step(H2x, T=linspace(0,10,100));
164-
[T2y, Y2y] = step(H2y, T=linspace(0,10,100));
163+
[Y2x, T2x] = step(H2x, T=linspace(0,10,100));
164+
[Y2y, T2y] = step(H2y, T=linspace(0,10,100));
165165
plot(T2x.T, Y2x.T, T2y.T, Y2y.T)
166166
ylabel('position');
167167
xlabel('time'); ylabel('position');
@@ -183,8 +183,8 @@
183183
H3y = ss(Ay - By*K3[1,alt], By*K3[1,alt]*yd[alt,:], Cy, Dy);
184184
subplot(224)
185185
# step(H3x, H3y, 10);
186-
[T3x, Y3x] = step(H3x, T=linspace(0,10,100));
187-
[T3y, Y3y] = step(H3y, T=linspace(0,10,100));
186+
[Y3x, T3x] = step(H3x, T=linspace(0,10,100));
187+
[Y3y, T3y] = step(H3y, T=linspace(0,10,100));
188188
plot(T3x.T, Y3x.T, T3y.T, Y3y.T)
189189
title("Physically motivated weights")
190190
xlabel('time');

examples/pvtol-nested-ss.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@
144144
# 'EdgeColor', color, 'FaceColor', color);
145145

146146
figure(9);
147-
(Tvec, Yvec) = step(T, linspace(1, 20));
147+
(Yvec, Tvec) = step(T, linspace(1, 20));
148148
plot(Tvec.T, Yvec.T); hold(True);
149149

150-
(Tvec, Yvec) = step(Co*S, linspace(1, 20));
150+
(Yvec, Tvec) = step(Co*S, linspace(1, 20));
151151
plot(Tvec.T, Yvec.T);
152152

153153
#TODO: PZmap for statespace systems has not yet been implemented.

examples/pvtol-nested.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@
134134
# 'EdgeColor', color, 'FaceColor', color);
135135

136136
figure(9);
137-
(Tvec, Yvec) = step(T, linspace(1, 20));
137+
(Yvec, Tvec) = step(T, linspace(0, 20));
138138
plot(Tvec.T, Yvec.T); hold(True);
139139

140-
(Tvec, Yvec) = step(Co*S, linspace(1, 20));
140+
(Yvec, Tvec) = step(Co*S, linspace(0, 20));
141141
plot(Tvec.T, Yvec.T);
142142

143143
figure(10); clf();

examples/secord-matlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
# Step response for the system
1919
figure(1)
20-
T, yout = step(sys)
20+
yout, T = step(sys)
2121
plot(T.T, yout.T)
2222

2323
# Bode plot for the system

examples/test-response.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
sys2 = tf([1, 1], [1, 1, 0])
1111

1212
# Generate step responses
13-
(T1a, y1a) = step(sys1)
14-
(T1b, y1b) = step(sys1, T = arange(0, 10, 0.1))
15-
(T1c, y1c) = step(sys1, X0 = [1, 0])
16-
(T2a, y2a) = step(sys2, T = arange(0, 10, 0.1))
13+
(y1a, T1a) = step(sys1)
14+
(y1b, T1b) = step(sys1, T = arange(0, 10, 0.1))
15+
(y1c, T1c) = step(sys1, X0 = [1, 0])
16+
(y2a, T2a) = step(sys2, T = arange(0, 10, 0.1))
1717

1818
plot(T1a, y1a, T1b, y1b, T1c, y1c, T2a, y2a)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup
55

66
setup(name = 'control',
7-
version = '0.4d',
7+
version = '0.5a',
88
description = 'Python Control Systems Library',
99
author = 'Richard Murray',
1010
author_email = 'murray@cds.caltech.edu',

src/__init__.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,18 @@
5757

5858
# Import functions from within the control system library
5959
#! Should probably only import the exact functions we use...
60-
from bdalg import *
61-
from delay import *
62-
from freqplot import *
63-
from margins import *
64-
from mateqn import *
65-
from modelsimp import *
66-
from nichols import *
67-
from phaseplot import PhasePlot, boxgrid
68-
from rlocus import *
69-
from statefbk import *
70-
from statesp import *
71-
from timeresp import ForcedResponse, InitialResponse, StepResponse, \
72-
ImpulseResponse
73-
from xferfcn import *
60+
from bdalg import series, parallel, negate, feedback
61+
from delay import pade
62+
from freqplot import bode_plot, nyquist_plot, gangof4_plot
63+
from freqplot import bode, nyquist, gangof4
64+
from margins import stability_margins, phase_crossover_frequencies
65+
from mateqn import lyap, dlyap, care, dare
66+
from modelsimp import hsvd, modred, balred, era, markov
67+
from nichols import nichols_plot, nichols
68+
from phaseplot import phase_plot, box_grid
69+
from rlocus import root_locus
70+
from statefbk import place, lqr, ctrb, obsv, gram
71+
from statesp import StateSpace
72+
from timeresp import forced_response, initial_response, step_response, \
73+
impulse_response
74+
from xferfcn import TransferFunction

0 commit comments

Comments
 (0)