@@ -2428,166 +2428,3 @@ def _mimo2simo(sys, input, warn_conversion=False):
24282428 inputs = sys .input_labels [input ], outputs = sys .output_labels )
24292429
24302430 return sys
2431-
2432-
2433- def tf2ss (* args , ** kwargs ):
2434- """tf2ss(sys)
2435-
2436- Transform a transfer function to a state space system.
2437-
2438- The function accepts either 1 or 2 parameters:
2439-
2440- ``tf2ss(sys)``
2441- Convert a linear system into space space form. Always creates
2442- a new system, even if sys is already a StateSpace object.
2443-
2444- ``tf2ss(num, den)``
2445- Create a state space system from its numerator and denominator
2446- polynomial coefficients.
2447-
2448- For details see: :func:`tf`
2449-
2450- Parameters
2451- ----------
2452- sys : LTI (StateSpace or TransferFunction)
2453- A linear system
2454- num : array_like, or list of list of array_like
2455- Polynomial coefficients of the numerator
2456- den : array_like, or list of list of array_like
2457- Polynomial coefficients of the denominator
2458-
2459- Returns
2460- -------
2461- out : StateSpace
2462- New linear system in state space form
2463-
2464- Other Parameters
2465- ----------------
2466- inputs, outputs : str, or list of str, optional
2467- List of strings that name the individual signals of the transformed
2468- system. If not given, the inputs and outputs are the same as the
2469- original system.
2470- name : string, optional
2471- System name. If unspecified, a generic name <sys[id]> is generated
2472- with a unique integer id.
2473-
2474- Raises
2475- ------
2476- ValueError
2477- if `num` and `den` have invalid or unequal dimensions, or if an
2478- invalid number of arguments is passed in
2479- TypeError
2480- if `num` or `den` are of incorrect type, or if sys is not a
2481- TransferFunction object
2482-
2483- See Also
2484- --------
2485- ss
2486- tf
2487- ss2tf
2488-
2489- Examples
2490- --------
2491- >>> num = [[[1., 2.], [3., 4.]], [[5., 6.], [7., 8.]]]
2492- >>> den = [[[9., 8., 7.], [6., 5., 4.]], [[3., 2., 1.], [-1., -2., -3.]]]
2493- >>> sys1 = ct.tf2ss(num, den)
2494-
2495- >>> sys_tf = ct.tf(num, den)
2496- >>> sys2 = ct.tf2ss(sys_tf)
2497-
2498- """
2499-
2500- from .xferfcn import TransferFunction
2501- if len (args ) == 2 or len (args ) == 3 :
2502- # Assume we were given the num, den
2503- return StateSpace (
2504- _convert_to_statespace (TransferFunction (* args )), ** kwargs )
2505-
2506- elif len (args ) == 1 :
2507- sys = args [0 ]
2508- if not isinstance (sys , TransferFunction ):
2509- raise TypeError ("tf2ss(sys): sys must be a TransferFunction "
2510- "object." )
2511- return StateSpace (
2512- _convert_to_statespace (
2513- sys ,
2514- use_prefix_suffix = not sys ._generic_name_check ()),
2515- ** kwargs )
2516- else :
2517- raise ValueError ("Needs 1 or 2 arguments; received %i." % len (args ))
2518-
2519-
2520- def ssdata (sys ):
2521- """
2522- Return state space data objects for a system
2523-
2524- Parameters
2525- ----------
2526- sys : LTI (StateSpace, or TransferFunction)
2527- LTI system whose data will be returned
2528-
2529- Returns
2530- -------
2531- (A, B, C, D): list of matrices
2532- State space data for the system
2533- """
2534- ss = _convert_to_statespace (sys )
2535- return ss .A , ss .B , ss .C , ss .D
2536-
2537-
2538- def linfnorm (sys , tol = 1e-10 ):
2539- """L-infinity norm of a linear system
2540-
2541- Parameters
2542- ----------
2543- sys : LTI (StateSpace or TransferFunction)
2544- system to evalute L-infinity norm of
2545- tol : real scalar
2546- tolerance on norm estimate
2547-
2548- Returns
2549- -------
2550- gpeak : non-negative scalar
2551- L-infinity norm
2552- fpeak : non-negative scalar
2553- Frequency, in rad/s, at which gpeak occurs
2554-
2555- For stable systems, the L-infinity and H-infinity norms are equal;
2556- for unstable systems, the H-infinity norm is infinite, while the
2557- L-infinity norm is finite if the system has no poles on the
2558- imaginary axis.
2559-
2560- See also
2561- --------
2562- slycot.ab13dd : the Slycot routine linfnorm that does the calculation
2563- """
2564-
2565- if ab13dd is None :
2566- raise ControlSlycot ("Can't find slycot module 'ab13dd'" )
2567-
2568- a , b , c , d = ssdata (_convert_to_statespace (sys ))
2569- e = np .eye (a .shape [0 ])
2570-
2571- n = a .shape [0 ]
2572- m = b .shape [1 ]
2573- p = c .shape [0 ]
2574-
2575- if n == 0 :
2576- # ab13dd doesn't accept empty A, B, C, D;
2577- # static gain case is easy enough to compute
2578- gpeak = scipy .linalg .svdvals (d )[0 ]
2579- # max svd is constant with freq; arbitrarily choose 0 as peak
2580- fpeak = 0
2581- return gpeak , fpeak
2582-
2583- dico = 'C' if sys .isctime () else 'D'
2584- jobe = 'I'
2585- equil = 'S'
2586- jobd = 'Z' if all (0 == d .flat ) else 'D'
2587-
2588- gpeak , fpeak = ab13dd (dico , jobe , equil , jobd , n , m , p , a , e , b , c , d , tol )
2589-
2590- if dico == 'D' :
2591- fpeak /= sys .dt
2592-
2593- return gpeak , fpeak
0 commit comments