5959from numpy .linalg import solve , eigvals , matrix_rank
6060from numpy .linalg .linalg import LinAlgError
6161import scipy as sp
62- from scipy .signal import lti , cont2discrete
62+ from scipy .signal import cont2discrete
63+ from scipy .signal import StateSpace as signalStateSpace
6364from warnings import warn
6465from .lti import LTI , timebase , timebaseEqual , isdtime
6566from . import config
@@ -200,7 +201,7 @@ def __init__(self, *args, **kw):
200201 raise ValueError ("Needs 1 or 4 arguments; received %i." % len (args ))
201202
202203 # Process keyword arguments
203- remove_useless = kw .get ('remove_useless' ,
204+ remove_useless = kw .get ('remove_useless' ,
204205 config .defaults ['statesp.remove_useless_states' ])
205206
206207 # Convert all matrices to standard form
@@ -798,9 +799,7 @@ def minreal(self, tol=0.0):
798799 else :
799800 return StateSpace (self )
800801
801-
802- # TODO: add discrete time check
803- def returnScipySignalLTI (self ):
802+ def returnScipySignalLTI (self , strict = True ):
804803 """Return a list of a list of :class:`scipy.signal.lti` objects.
805804
806805 For instance,
@@ -809,15 +808,45 @@ def returnScipySignalLTI(self):
809808 >>> out[3][5]
810809
811810 is a :class:`scipy.signal.lti` object corresponding to the transfer
812- function from the 6th input to the 4th output."""
811+ function from the 6th input to the 4th output.
812+
813+ Parameters
814+ ----------
815+ strict : bool, optional
816+ True (default):
817+ The timebase `ssobject.dt` cannot be None; it must
818+ be continuous (0) or discrete (True or > 0).
819+ False:
820+ If `ssobject.dt` is None, continuous time
821+ :class:`scipy.signal.lti` objects are returned.
822+
823+ Returns
824+ -------
825+ out : list of list of :class:`scipy.signal.StateSpace`
826+ continuous time (inheriting from :class:`scipy.signal.lti`)
827+ or discrete time (inheriting from :class:`scipy.signal.dlti`)
828+ SISO objects
829+ """
830+ if strict and self .dt is None :
831+ raise ValueError ("with strict=True, dt cannot be None" )
832+
833+ if self .dt :
834+ kwdt = {'dt' : self .dt }
835+ else :
836+ # scipy convention for continuous time lti systems: call without
837+ # dt keyword argument
838+ kwdt = {}
813839
814840 # Preallocate the output.
815841 out = [[[] for _ in range (self .inputs )] for _ in range (self .outputs )]
816842
817843 for i in range (self .outputs ):
818844 for j in range (self .inputs ):
819- out [i ][j ] = lti (asarray (self .A ), asarray (self .B [:, j ]),
820- asarray (self .C [i , :]), self .D [i , j ])
845+ out [i ][j ] = signalStateSpace (asarray (self .A ),
846+ asarray (self .B [:, j :j + 1 ]),
847+ asarray (self .C [i :i + 1 , :]),
848+ asarray (self .D [i :i + 1 , j :j + 1 ]),
849+ ** kwdt )
821850
822851 return out
823852
0 commit comments