Skip to content

Commit 72bb295

Browse files
author
Kevin Chen
committed
Modified docstrings for h2syn, hinfsyn, ctrb, obsv, gram, era, markov, step, impulse, initial, bode
Steven Brunton <sbrunton@princeton.edu>
1 parent 3797c1b commit 72bb295

4 files changed

Lines changed: 195 additions & 129 deletions

File tree

src/matlab.py

Lines changed: 73 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -685,13 +685,13 @@ def freqresp(sys, omega):
685685
def bode(*args, **keywords):
686686
"""Bode plot of the frequency response
687687
688-
Usage
689-
=====
690-
bode(sys)
691-
bode(sys, w)
692-
bode(sys1, sys2, ..., sysN)
693-
bode(sys1, sys2, ..., sysN, w)
694-
bode(sys1, 'plotstyle1', ..., sysN, 'plotstyleN')
688+
Examples
689+
--------
690+
>>> bode(sys)
691+
>>> bode(sys, w)
692+
>>> bode(sys1, sys2, ..., sysN)
693+
>>> bode(sys1, sys2, ..., sysN, w)
694+
>>> bode(sys1, 'plotstyle1', ..., sysN, 'plotstyleN')
695695
"""
696696

697697
# If the first argument is a list, then assume python-control calling format
@@ -749,20 +749,23 @@ def bode(*args, **keywords):
749749
def lsim(*args, **keywords):
750750
"""Simulate the output of a linear system
751751
752-
Usage
753-
=====
754-
(T, yout, xout) = lsim(sys, u, T, X0)
752+
Examples
753+
--------
754+
>>> T, yout, xout = lsim(sys, u, T, X0)
755755
756-
Inputs:
757-
sys LTI system
758-
u input array giving input at each time T
759-
T time steps at which the input is defined
760-
X0 initial condition (optional, default = 0)
756+
Parameters
757+
----------
758+
sys: StateSpace, or TransferFunction
759+
LTI system to simulate
760+
u: input array giving input at each time T
761+
T: time steps at which the input is defined
762+
X0: initial condition (optional, default = 0)
761763
762-
Outputs:
763-
T time values of the output
764-
yout response of the system
765-
xout time evolution of the state vector
764+
Returns
765+
-------
766+
T: time values of the output
767+
yout: response of the system
768+
xout: time evolution of the state vector
766769
"""
767770
sys = args[0]
768771
ltiobjs = sys.returnScipySignalLti()
@@ -775,18 +778,24 @@ def lsim(*args, **keywords):
775778
def step(*args, **keywords):
776779
"""Step response of a linear system
777780
778-
Usage
779-
=====
780-
(T, yout) = step(sys, T, X0)
781+
Examples
782+
--------
783+
>>> T, yout = step(sys, T, X0)
781784
782-
Inputs:
783-
sys LTI system
784-
T time steps (optional; autocomputed if not gien)
785-
X0 initial condition (optional, default = 0)
785+
Parameters
786+
----------
787+
sys: StateSpace, or TransferFunction
788+
T: array
789+
T is the time vector (optional; autocomputed if not given)
790+
X0: array
791+
X0 is the initial condition (optional; default = 0)
786792
787-
Outputs:
788-
T time values of the output
789-
yout response of the system
793+
Returns
794+
-------
795+
T: array
796+
Time values of the output
797+
yout: array
798+
response of the system
790799
"""
791800
sys = args[0]
792801
ltiobjs = sys.returnScipySignalLti()
@@ -804,18 +813,25 @@ def step(*args, **keywords):
804813
def initial(*args, **keywords):
805814
"""Initial condition response of a linear system
806815
807-
Usage
808-
=====
809-
(T, yout) = initial(sys, T, X0)
816+
Examples
817+
--------
818+
>>> T, yout = initial(sys, T, X0)
810819
811-
Inputs:
812-
sys LTI system
813-
T time steps (optional; autocomputed if not gien)
814-
X0 initial condition (optional, default = 0)
820+
Parameters
821+
----------
822+
sys: StateSpace, or TransferFunction
823+
T: array
824+
T is the time vector (optional; autocomputed if not given)
825+
X0: array
826+
X0 is the initial condition (optional; default = 0)
815827
816-
Outputs:
817-
T time values of the output
818-
yout response of the system
828+
Returns
829+
-------
830+
T: array
831+
Time values of the output
832+
yout: array
833+
response of the system
834+
819835
"""
820836
sys = args[0]
821837
ltiobjs = sys.returnScipySignalLti()
@@ -827,20 +843,27 @@ def initial(*args, **keywords):
827843
# Redefine impulse to use initial()
828844
#! Not yet implemented (uses impulse for now)
829845
def impulse(*args, **keywords):
830-
"""Step response of a linear system
846+
"""Impulse response of a linear system
831847
832-
Usage
833-
=====
834-
(T, yout) = impulse(sys, T, X0)
848+
Examples
849+
--------
850+
>>> T, yout = impulse(sys, T, X0)
835851
836-
Inputs:
837-
sys LTI system
838-
T time steps (optional; autocomputed if not gien)
839-
X0 initial condition (optional, default = 0)
852+
Parameters
853+
----------
854+
sys: StateSpace, or TransferFunction
855+
T: array
856+
T is the time vector (optional; autocomputed if not given)
857+
X0: array
858+
X0 is the initial condition (optional; default = 0)
840859
841-
Outputs:
842-
T time values of the output
843-
yout response of the system
860+
Returns
861+
-------
862+
T: array
863+
Time values of the output
864+
yout: array
865+
response of the system
866+
844867
"""
845868
sys = args[0]
846869
ltiobjs = sys.returnScipySignalLti()

src/modelsimp.py

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def hsvd(sys):
6969
7070
Examples
7171
--------
72-
H = hsvd(sys)
72+
>>> H = hsvd(sys)
7373
7474
"""
7575

@@ -107,7 +107,7 @@ def modred(sys,ELIM,method):
107107
108108
Examples
109109
--------
110-
rsys = modred(sys,ELIM,method)
110+
>>> rsys = modred(sys,ELIM,method='truncate')
111111
112112
"""
113113

@@ -193,7 +193,7 @@ def balred(sys,orders,method='truncate'):
193193
194194
Examples
195195
--------
196-
rsys = balred(sys,order,elimination,method)
196+
>>> rsys = balred(sys,order,method='truncate')
197197
198198
"""
199199

@@ -245,41 +245,44 @@ def balred(sys,orders,method='truncate'):
245245
def era(YY,m,n,nin,nout,r):
246246
"""Calculate an ERA model of order r based on the impulse-response data YY
247247
248-
Usage
249-
=====
250-
sys = era(YY,m,n,nin,nout,r)
248+
Parameters
249+
----------
250+
YY: nout x nin dimensional impulse-response data
251+
m: number of rows in Hankel matrix
252+
n: number of columns in Hankel matrix
253+
nin: number of input variables
254+
nout: number of output variables
255+
r: order of model
251256
252-
Inputs
253-
------
254-
YY : nout x nin dimensional impulse-response data
255-
m : number of rows in Hankel matrix
256-
n : number of columns in Hankel matrix
257-
nin : number of input variables
258-
nout : number of output variables
259-
r : order of model
260-
261-
Outputs
257+
Returns
262258
-------
263-
sys : a reduced order model sys=ss(Ar,Br,Cr,Dr)
259+
sys: a reduced order model sys=ss(Ar,Br,Cr,Dr)
260+
261+
Examples
262+
--------
263+
>>> rsys = era(YY,m,n,nin,nout,r)
264264
265265
"""
266266
def markov(Y,U,M):
267267
"""Calculate the first M Markov parameters [D CB CAB ...] from input U, output Y
268268
269-
Usage
270-
=====
271-
H = markov(Y,U,M)
272-
Currently only works for SISO
273-
274-
Inputs
275-
------
276-
Y : output data
277-
U : input data
278-
M : number of Markov parameters to output
269+
Parameters
270+
----------
271+
Y: output data
272+
U: input data
273+
M: number of Markov parameters to output
279274
280-
Outputs
275+
Returns
281276
-------
282-
H : first M Markov parameters
277+
H: first M Markov parameters
278+
279+
Notes
280+
-----
281+
Currently only works for SISO
282+
283+
Examples
284+
--------
285+
>>> H = markov(Y,U,M)
283286
284287
"""
285288

src/robust.py

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,29 @@
4949
def h2syn(P,nmeas,ncon):
5050
"""H_2 control synthesis for plant P.
5151
52-
Usage
53-
=====
54-
K = h2syn(P,nmeas,ncon)
55-
56-
Inputs
57-
======
58-
P : partitioned lti plant
59-
nmeas : number of measurements (input to controller)
60-
ncon : number of control inputs (output from controller)
61-
62-
Outputs
63-
=======
64-
K : controller to stabilize P
52+
Parameters
53+
----------
54+
P: partitioned lti plant (State-space sys)
55+
nmeas: number of measurements (input to controller)
56+
ncon: number of control inputs (output from controller)
57+
58+
Returns
59+
-------
60+
K: controller to stabilize P (State-space sys)
61+
62+
Raises
63+
------
64+
ImportError
65+
if slycot routine sb10hd is not loaded
66+
67+
See Also
68+
--------
69+
StateSpace
70+
71+
Examples
72+
--------
73+
>>> K = h2syn(P,nmeas,ncon)
74+
6575
"""
6676

6777
#Check for ss system object, need a utility for this?
@@ -95,22 +105,32 @@ def h2syn(P,nmeas,ncon):
95105
def hinfsyn(P,nmeas,ncon):
96106
"""H_{inf} control synthesis for plant P.
97107
98-
Usage
99-
=====
100-
K, CL, gam, info = hinfsyn(P,nmeas,ncon)
101-
102-
Inputs
103-
======
104-
P : partitioned lti plant
105-
nmeas : number of measurements (input to controller)
106-
ncon : number of control inputs (output from controller)
107-
108-
Outputs
109-
=======
110-
K : controller to stabilize P
111-
CL : closed loop system
112-
gam : infinity norm of closed loop system
113-
info : info returned from siycot routine
108+
Parameters
109+
----------
110+
P: partitioned lti plant
111+
nmeas: number of measurements (input to controller)
112+
ncon: number of control inputs (output from controller)
113+
114+
Returns
115+
-------
116+
K: controller to stabilize P (State-space sys)
117+
CL: closed loop system (State-space sys)
118+
gam: infinity norm of closed loop system
119+
info: info returned from siycot routine
120+
121+
Raises
122+
------
123+
ImportError
124+
if slycot routine sb10ad is not loaded
125+
126+
See Also
127+
--------
128+
StateSpace
129+
130+
Examples
131+
--------
132+
>>> K, CL, gam, info = hinfsyn(P,nmeas,ncon)
133+
114134
"""
115135

116136
#Check for ss system object, need a utility for this?

0 commit comments

Comments
 (0)