32
32
from warnings import warn
33
33
34
34
from .statesp import StateSpace , tf2ss , _convert_to_statespace
35
- from .timeresp import _check_convert_array , _process_time_response
35
+ from .timeresp import _check_convert_array , _process_time_response , \
36
+ TimeResponseData
36
37
from .lti import isctime , isdtime , common_timebase
37
38
from . import config
38
39
@@ -878,7 +879,7 @@ def __init__(self, updfcn, outfcn=None, inputs=None, outputs=None,
878
879
def __call__ (sys , u , params = None , squeeze = None ):
879
880
"""Evaluate a (static) nonlinearity at a given input value
880
881
881
- If a nonlinear I/O system has not internal state, then evaluating the
882
+ If a nonlinear I/O system has no internal state, then evaluating the
882
883
system at an input `u` gives the output `y = F(u)`, determined by the
883
884
output function.
884
885
@@ -907,7 +908,8 @@ def __call__(sys, u, params=None, squeeze=None):
907
908
908
909
# Evaluate the function on the argument
909
910
out = sys ._out (0 , np .array ((0 ,)), np .asarray (u ))
910
- _ , out = _process_time_response (sys , None , out , None , squeeze = squeeze )
911
+ _ , out = _process_time_response (
912
+ None , out , issiso = sys .issiso (), squeeze = squeeze )
911
913
return out
912
914
913
915
def _update_params (self , params , warning = False ):
@@ -1641,14 +1643,21 @@ def input_output_response(
1641
1643
----------
1642
1644
sys : InputOutputSystem
1643
1645
Input/output system to simulate.
1646
+
1644
1647
T : array-like
1645
1648
Time steps at which the input is defined; values must be evenly spaced.
1649
+
1646
1650
U : array-like or number, optional
1647
1651
Input array giving input at each time `T` (default = 0).
1652
+
1648
1653
X0 : array-like or number, optional
1649
1654
Initial condition (default = 0).
1655
+
1650
1656
return_x : bool, optional
1657
+ If True, return the state vector when assigning to a tuple (default =
1658
+ False). See :func:`forced_response` for more details.
1651
1659
If True, return the values of the state at each time (default = False).
1660
+
1652
1661
squeeze : bool, optional
1653
1662
If True and if the system has a single output, return the system
1654
1663
output as a 1D array rather than a 2D array. If False, return the
@@ -1657,15 +1666,27 @@ def input_output_response(
1657
1666
1658
1667
Returns
1659
1668
-------
1660
- T : array
1661
- Time values of the output.
1662
- yout : array
1663
- Response of the system. If the system is SISO and squeeze is not
1664
- True, the array is 1D (indexed by time). If the system is not SISO or
1665
- squeeze is False, the array is 2D (indexed by the output number and
1666
- time).
1667
- xout : array
1668
- Time evolution of the state vector (if return_x=True).
1669
+ results : TimeResponseData
1670
+ Time response represented as a :class:`TimeResponseData` object
1671
+ containing the following properties:
1672
+
1673
+ * time (array): Time values of the output.
1674
+
1675
+ * outputs (array): Response of the system. If the system is SISO and
1676
+ `squeeze` is not True, the array is 1D (indexed by time). If the
1677
+ system is not SISO or `squeeze` is False, the array is 2D (indexed
1678
+ by output and time).
1679
+
1680
+ * states (array): Time evolution of the state vector, represented as
1681
+ a 2D array indexed by state and time.
1682
+
1683
+ * inputs (array): Input(s) to the system, indexed by input and time.
1684
+
1685
+ The return value of the system can also be accessed by assigning the
1686
+ function to a tuple of length 2 (time, output) or of length 3 (time,
1687
+ output, state) if ``return_x`` is ``True``. If the input/output
1688
+ system signals are named, these names will be used as labels for the
1689
+ time response.
1669
1690
1670
1691
Other parameters
1671
1692
----------------
@@ -1727,8 +1748,9 @@ def input_output_response(
1727
1748
for i in range (len (T )):
1728
1749
u = U [i ] if len (U .shape ) == 1 else U [:, i ]
1729
1750
y [:, i ] = sys ._out (T [i ], [], u )
1730
- return _process_time_response (
1731
- sys , T , y , np .array ((0 , 0 , np .asarray (T ).size )),
1751
+ return TimeResponseData (
1752
+ T , y , None , U , issiso = sys .issiso (),
1753
+ output_labels = sys .output_index , input_labels = sys .input_index ,
1732
1754
transpose = transpose , return_x = return_x , squeeze = squeeze )
1733
1755
1734
1756
# create X0 if not given, test if X0 has correct shape
@@ -1823,8 +1845,11 @@ def ivp_rhs(t, x):
1823
1845
else : # Neither ctime or dtime??
1824
1846
raise TypeError ("Can't determine system type" )
1825
1847
1826
- return _process_time_response (sys , soln .t , y , soln .y , transpose = transpose ,
1827
- return_x = return_x , squeeze = squeeze )
1848
+ return TimeResponseData (
1849
+ soln .t , y , soln .y , U , issiso = sys .issiso (),
1850
+ output_labels = sys .output_index , input_labels = sys .input_index ,
1851
+ state_labels = sys .state_index ,
1852
+ transpose = transpose , return_x = return_x , squeeze = squeeze )
1828
1853
1829
1854
1830
1855
def find_eqpt (sys , x0 , u0 = [], y0 = None , t = 0 , params = {},
0 commit comments