5151$Id$
5252"""
5353
54+ import math
5455import numpy as np
5556from 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 , \
5758 zeros , squeeze
5859from numpy .random import rand , randn
5960from numpy .linalg import solve , eigvals , matrix_rank
6970__all__ = ['StateSpace' , 'ss' , 'rss' , 'drss' , 'tf2ss' , 'ssdata' ]
7071
7172class 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
7376
7477 The StateSpace class is used to represent state-space realizations of linear
7578 time-invariant (LTI) systems:
@@ -89,15 +92,19 @@ class StateSpace(LTI):
8992 means the system timebase is not specified. If 'dt' is set to True, the
9093 system will be treated as a discrete time system with unspecified
9194 sampling time.
92-
9395 """
9496
9597 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.
97102
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.
101108
102109 """
103110
@@ -111,8 +118,7 @@ def __init__(self, *args):
111118 elif len (args ) == 1 :
112119 # Use the copy constructor.
113120 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 ]))
116122 A = args [0 ].A
117123 B = args [0 ].B
118124 C = args [0 ].C
@@ -363,7 +369,7 @@ def evalfr(self, omega):
363369 if isdtime (self , strict = True ):
364370 dt = timebase (self )
365371 s = exp (1.j * omega * dt )
366- if (omega * dt > pi ):
372+ if (omega * dt > math . pi ):
367373 warnings .warn ("evalfr: frequency evaluation above Nyquist frequency" )
368374 else :
369375 s = omega * 1.j
@@ -793,7 +799,7 @@ def _rss_generate(states, inputs, outputs, type):
793799 poles [i ] = complex (- exp (randn ()), 3. * exp (randn ()))
794800 elif type == 'd' :
795801 mag = rand ()
796- phase = 2. * pi * rand ()
802+ phase = 2. * math . pi * rand ()
797803 poles [i ] = complex (mag * cos (phase ),
798804 mag * sin (phase ))
799805 poles [i + 1 ] = complex (poles [i ].real , - poles [i ].imag )
@@ -956,7 +962,8 @@ def _mimo2simo(sys, input, warn_conversion=False):
956962 return sys
957963
958964def ss (* args ):
959- """
965+ """ss(A, B, C, D[, dt])
966+
960967 Create a state space system.
961968
962969 The function accepts either 1, 4 or 5 parameters:
@@ -1014,6 +1021,7 @@ def ss(*args):
10141021
10151022 See Also
10161023 --------
1024+ StateSpace
10171025 tf
10181026 ss2tf
10191027 tf2ss
@@ -1045,7 +1053,8 @@ def ss(*args):
10451053 raise ValueError ("Needs 1 or 4 arguments; received %i." % len (args ))
10461054
10471055def tf2ss (* args ):
1048- """
1056+ """tf2ss(sys)
1057+
10491058 Transform a transfer function to a state space system.
10501059
10511060 The function accepts either 1 or 2 parameters:
0 commit comments