@@ -1519,7 +1519,7 @@ def output(self, t, x, u=None, params=None):
1519
1519
1520
1520
1521
1521
# TODO: add discrete time check
1522
- def _convert_to_statespace (sys ):
1522
+ def _convert_to_statespace (sys , use_prefix_suffix = False ):
1523
1523
"""Convert a system to state space form (if needed).
1524
1524
1525
1525
If sys is already a state space, then it is returned. If sys is a
@@ -1556,11 +1556,10 @@ def _convert_to_statespace(sys):
1556
1556
denorder , den , num , tol = 0 )
1557
1557
1558
1558
states = ssout [0 ]
1559
- return StateSpace (
1559
+ newsys = StateSpace (
1560
1560
ssout [1 ][:states , :states ], ssout [2 ][:states , :sys .ninputs ],
1561
- ssout [3 ][:sys .noutputs , :states ], ssout [4 ], sys .dt ,
1562
- inputs = sys .input_labels , outputs = sys .output_labels ,
1563
- name = sys .name )
1561
+ ssout [3 ][:sys .noutputs , :states ], ssout [4 ], sys .dt )
1562
+
1564
1563
except ImportError :
1565
1564
# No Slycot. Scipy tf->ss can't handle MIMO, but static
1566
1565
# MIMO is an easy special case we can check for here
@@ -1585,9 +1584,13 @@ def _convert_to_statespace(sys):
1585
1584
# the squeeze
1586
1585
A , B , C , D = \
1587
1586
sp .signal .tf2ss (squeeze (sys .num ), squeeze (sys .den ))
1588
- return StateSpace (
1589
- A , B , C , D , sys .dt , inputs = sys .input_labels ,
1590
- outputs = sys .output_labels , name = sys .name )
1587
+ newsys = StateSpace (A , B , C , D , sys .dt )
1588
+
1589
+ # Copy over the signal (and system) names
1590
+ newsys ._copy_names (
1591
+ sys ,
1592
+ prefix_suffix_name = 'converted' if use_prefix_suffix else None )
1593
+ return newsys
1591
1594
1592
1595
elif isinstance (sys , FrequencyResponseData ):
1593
1596
raise TypeError ("Can't convert FRD to StateSpace system." )
@@ -1600,7 +1603,6 @@ def _convert_to_statespace(sys):
1600
1603
except Exception :
1601
1604
raise TypeError ("Can't convert given type to StateSpace system." )
1602
1605
1603
-
1604
1606
# TODO: add discrete time option
1605
1607
def _rss_generate (
1606
1608
states , inputs , outputs , cdtype , strictly_proper = False , name = None ):
@@ -1914,7 +1916,8 @@ def tf2ss(*args, **kwargs):
1914
1916
if not isinstance (sys , TransferFunction ):
1915
1917
raise TypeError ("tf2ss(sys): sys must be a TransferFunction "
1916
1918
"object." )
1917
- return StateSpace (_convert_to_statespace (sys ), ** kwargs )
1919
+ return StateSpace (_convert_to_statespace (sys , use_prefix_suffix = True ),
1920
+ ** kwargs )
1918
1921
else :
1919
1922
raise ValueError ("Needs 1 or 2 arguments; received %i." % len (args ))
1920
1923
0 commit comments