51
51
$Id$
52
52
"""
53
53
54
+ import math
54
55
import numpy as np
55
56
from numpy import all , angle , any , array , asarray , concatenate , cos , delete , \
56
- dot , empty , exp , eye , matrix , ones , pi , poly , poly1d , roots , shape , sin , \
57
+ dot , empty , exp , eye , matrix , ones , poly , poly1d , roots , shape , sin , \
57
58
zeros , squeeze
58
59
from numpy .random import rand , randn
59
60
from numpy .linalg import solve , eigvals , matrix_rank
69
70
__all__ = ['StateSpace' , 'ss' , 'rss' , 'drss' , 'tf2ss' , 'ssdata' ]
70
71
71
72
class StateSpace (LTI ):
72
- """A class for representing state-space models
73
+ """StateSpace(A, B, C, D[, dt])
74
+
75
+ A class for representing state-space models
73
76
74
77
The StateSpace class is used to represent state-space realizations of linear
75
78
time-invariant (LTI) systems:
@@ -89,15 +92,19 @@ class StateSpace(LTI):
89
92
means the system timebase is not specified. If 'dt' is set to True, the
90
93
system will be treated as a discrete time system with unspecified
91
94
sampling time.
92
-
93
95
"""
94
96
95
97
def __init__ (self , * args ):
96
- """Construct a state space object.
98
+ """
99
+ StateSpace(A, B, C, D[, dt])
100
+
101
+ Construct a state space object.
97
102
98
- The default constructor is StateSpace(A, B, C, D), where A, B, C, D are
99
- matrices or equivalent objects. To call the copy constructor, call
100
- StateSpace(sys), where sys is a StateSpace object.
103
+ The default constructor is StateSpace(A, B, C, D), where A, B, C, D
104
+ are matrices or equivalent objects. To create a discrete time system,
105
+ use StateSpace(A, B, C, D, dt) where 'dt' is the sampling time (or
106
+ True for unspecified sampling time). To call the copy constructor,
107
+ call StateSpace(sys), where sys is a StateSpace object.
101
108
102
109
"""
103
110
@@ -111,8 +118,7 @@ def __init__(self, *args):
111
118
elif len (args ) == 1 :
112
119
# Use the copy constructor.
113
120
if not isinstance (args [0 ], StateSpace ):
114
- raise TypeError ("The one-argument constructor can only take in \
115
- a StateSpace object. Recived %s." % type (args [0 ]))
121
+ raise TypeError ("The one-argument constructor can only take in a StateSpace object. Received %s." % type (args [0 ]))
116
122
A = args [0 ].A
117
123
B = args [0 ].B
118
124
C = args [0 ].C
@@ -363,7 +369,7 @@ def evalfr(self, omega):
363
369
if isdtime (self , strict = True ):
364
370
dt = timebase (self )
365
371
s = exp (1.j * omega * dt )
366
- if (omega * dt > pi ):
372
+ if (omega * dt > math . pi ):
367
373
warnings .warn ("evalfr: frequency evaluation above Nyquist frequency" )
368
374
else :
369
375
s = omega * 1.j
@@ -793,7 +799,7 @@ def _rss_generate(states, inputs, outputs, type):
793
799
poles [i ] = complex (- exp (randn ()), 3. * exp (randn ()))
794
800
elif type == 'd' :
795
801
mag = rand ()
796
- phase = 2. * pi * rand ()
802
+ phase = 2. * math . pi * rand ()
797
803
poles [i ] = complex (mag * cos (phase ),
798
804
mag * sin (phase ))
799
805
poles [i + 1 ] = complex (poles [i ].real , - poles [i ].imag )
@@ -956,7 +962,8 @@ def _mimo2simo(sys, input, warn_conversion=False):
956
962
return sys
957
963
958
964
def ss (* args ):
959
- """
965
+ """ss(A, B, C, D[, dt])
966
+
960
967
Create a state space system.
961
968
962
969
The function accepts either 1, 4 or 5 parameters:
@@ -1014,6 +1021,7 @@ def ss(*args):
1014
1021
1015
1022
See Also
1016
1023
--------
1024
+ StateSpace
1017
1025
tf
1018
1026
ss2tf
1019
1027
tf2ss
@@ -1045,7 +1053,8 @@ def ss(*args):
1045
1053
raise ValueError ("Needs 1 or 4 arguments; received %i." % len (args ))
1046
1054
1047
1055
def tf2ss (* args ):
1048
- """
1056
+ """tf2ss(sys)
1057
+
1049
1058
Transform a transfer function to a state space system.
1050
1059
1051
1060
The function accepts either 1 or 2 parameters:
0 commit comments