@@ -746,7 +746,8 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
746746
747747 Parameters
748748 ----------
749- sys : StateSpace or TransferFunction
749+ sys : SISO dynamic system model. Dynamic systems that you can use include:
750+ StateSpace or TransferFunction
750751 LTI system to simulate
751752
752753 T : array_like or float, optional
@@ -785,14 +786,20 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
785786 --------
786787 >>> info = step_info(sys, T)
787788 '''
788- _ , sys = _get_ss_simo (sys )
789+
790+ if not sys .issiso ():
791+ sys = _mimo2siso (sys ,0 ,0 )
792+ warnings .warn (" Internal conversion from a MIMO system to a SISO system,"
793+ " the first input and the first output were used (u1 -> y1);"
794+ " it may not be the result you are looking for" )
795+
789796 if T is None or np .asarray (T ).size == 1 :
790797 T = _default_time_vector (sys , N = T_num , tfinal = T , is_step = True )
791798
792799 T , yout = step_response (sys , T )
793800
794801 # Steady state value
795- InfValue = sys .dcgain ()
802+ InfValue = sys .dcgain (). real
796803
797804 # TODO: this could be a function step_info4data(t,y,yfinal)
798805 rise_time : float = np .NaN
@@ -803,8 +810,11 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
803810 peak_time : float = np .Inf
804811 undershoot : float = np .NaN
805812 overshoot : float = np .NaN
806-
813+ steady_state_value : float = np .NaN
814+
807815 if not np .isnan (InfValue ) and not np .isinf (InfValue ):
816+ # SteadyStateValue
817+ steady_state_value = InfValue
808818 # Peak
809819 peak_index = np .abs (yout ).argmax ()
810820 peak_value = np .abs (yout [peak_index ])
@@ -813,29 +823,26 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
813823 sup_margin = (1. + SettlingTimeThreshold ) * InfValue
814824 inf_margin = (1. - SettlingTimeThreshold ) * InfValue
815825
816- if InfValue < 0.0 :
817- # RiseTime
818- tr_lower_index = (np .where (yout <= RiseTimeLimits [0 ] * InfValue )[0 ])[0 ]
819- tr_upper_index = (np .where (yout <= RiseTimeLimits [1 ] * InfValue )[0 ])[0 ]
820- # SettlingTime
821- for i in reversed (range (T .size - 1 )):
822- if (- yout [i ] <= np .abs (inf_margin )) | (- yout [i ] >= np .abs (sup_margin )):
823- settling_time = T [i + 1 ]
824- break
825- # Overshoot and Undershoot
826- overshoot = np .abs (100. * ((- yout ).max () - np .abs (InfValue )) / np .abs (InfValue ))
827- undershoot = np .abs (100. * (- yout ).min () / np .abs (InfValue ))
826+ # RiseTime
827+ tr_lower_index = (np .where (np .sign (InfValue .real ) * (yout - RiseTimeLimits [0 ] * InfValue ) >= 0 )[0 ])[0 ]
828+ tr_upper_index = (np .where (np .sign (InfValue .real ) * yout >= np .sign (InfValue .real ) * RiseTimeLimits [1 ] * InfValue )[0 ])[0 ]
829+
830+ # SettlingTime
831+ settling_time = T [np .where (np .abs (yout - InfValue ) >= np .abs (SettlingTimeThreshold * InfValue ))[0 ][- 1 ]+ 1 ]
832+ # Overshoot and Undershoot
833+ y_os = (np .sign (InfValue .real )* yout ).max ()
834+ dy_os = np .abs (y_os ) - np .abs (InfValue )
835+ if dy_os > 0 :
836+ overshoot = np .abs (100. * dy_os / InfValue )
837+ else :
838+ overshoot = 0
839+
840+ y_us = (np .sign (InfValue .real )* yout ).min ()
841+ dy_us = np .abs (y_us )
842+ if dy_us > 0 :
843+ undershoot = np .abs (100. * dy_us / InfValue )
828844 else :
829- tr_lower_index = (np .where (yout >= RiseTimeLimits [0 ] * InfValue )[0 ])[0 ]
830- tr_upper_index = (np .where (yout >= RiseTimeLimits [1 ] * InfValue )[0 ])[0 ]
831- # SettlingTime
832- for i in reversed (range (T .size - 1 )):
833- if (yout [i ] <= inf_margin ) | (yout [i ] >= sup_margin ):
834- settling_time = T [i + 1 ]
835- break
836- # Overshoot and Undershoot
837- overshoot = np .abs (100. * (yout .max () - InfValue ) / InfValue )
838- undershoot = np .abs (100. * yout .min () / InfValue )
845+ undershoot = 0
839846
840847 # RiseTime
841848 rise_time = T [tr_upper_index ] - T [tr_lower_index ]
@@ -852,7 +859,7 @@ def step_info(sys, T=None, T_num=None, SettlingTimeThreshold=0.02,
852859 'Undershoot' : undershoot ,
853860 'Peak' : peak_value ,
854861 'PeakTime' : peak_time ,
855- 'SteadyStateValue' : InfValue
862+ 'SteadyStateValue' : steady_state_value
856863 }
857864
858865def initial_response (sys , T = None , X0 = 0. , input = 0 , output = None , T_num = None ,
0 commit comments