54
54
55
55
from .lti import LTI , _process_frequency_response
56
56
from .exception import pandas_check
57
- from .namedio import _NamedIOSystem
57
+ from .namedio import NamedIOSystem , _process_namedio_keywords
58
58
from . import config
59
59
60
60
__all__ = ['FrequencyResponseData' , 'FRD' , 'frd' ]
61
61
62
62
63
- class FrequencyResponseData (LTI , _NamedIOSystem ):
63
+ class FrequencyResponseData (LTI ):
64
64
"""FrequencyResponseData(d, w[, smooth])
65
65
66
66
A class for models defined by frequency response data (FRD).
@@ -117,7 +117,7 @@ class FrequencyResponseData(LTI, _NamedIOSystem):
117
117
118
118
# Allow NDarray * StateSpace to give StateSpace._rmul_() priority
119
119
# https://docs.scipy.org/doc/numpy/reference/arrays.classes.html
120
- __array_priority__ = 11 # override ndarray and matrix types
120
+ __array_priority__ = 13 # override ndarray, StateSpace, I/O sys
121
121
122
122
#
123
123
# Class attributes
@@ -157,6 +157,9 @@ def __init__(self, *args, **kwargs):
157
157
# TODO: discrete-time FRD systems?
158
158
smooth = kwargs .pop ('smooth' , False )
159
159
160
+ #
161
+ # Process positional arguments
162
+ #
160
163
if len (args ) == 2 :
161
164
if not isinstance (args [0 ], FRD ) and isinstance (args [0 ], LTI ):
162
165
# not an FRD, but still a system, second argument should be
@@ -196,28 +199,28 @@ def __init__(self, *args, **kwargs):
196
199
raise ValueError (
197
200
"Needs 1 or 2 arguments; received %i." % len (args ))
198
201
199
- # Set the size of the system
200
- self .noutputs = self .fresp .shape [0 ]
201
- self .ninputs = self .fresp .shape [1 ]
202
-
203
- # Process signal names
204
- _NamedIOSystem .__init__ (
205
- self , name = kwargs .pop ('name' , None ),
206
- inputs = kwargs .pop ('inputs' , self .ninputs ),
207
- outputs = kwargs .pop ('outputs' , self .noutputs ))
208
-
202
+ #
203
+ # Process key word arguments
204
+ #
209
205
# Keep track of return type
210
206
self .return_magphase = kwargs .pop ('return_magphase' , False )
211
207
if self .return_magphase not in (True , False ):
212
208
raise ValueError ("unknown return_magphase value" )
213
209
210
+ # Determine whether to squeeze the output
214
211
self .squeeze = kwargs .pop ('squeeze' , None )
215
212
if self .squeeze not in (None , True , False ):
216
213
raise ValueError ("unknown squeeze value" )
217
214
218
- # Make sure there were no extraneous keywords
219
- if kwargs :
220
- raise TypeError ("unrecognized keywords: " , str (kwargs ))
215
+ # Process namedio keywords
216
+ defaults = {
217
+ 'inputs' : self .fresp .shape [1 ], 'outputs' : self .fresp .shape [0 ]}
218
+ name , inputs , outputs , states , dt = _process_namedio_keywords (
219
+ kwargs , defaults , end = True )
220
+
221
+ # Process signal names
222
+ NamedIOSystem .__init__ (
223
+ self , name = name , inputs = inputs , outputs = outputs , dt = dt )
221
224
222
225
# create interpolation functions
223
226
if smooth :
@@ -231,7 +234,6 @@ def __init__(self, *args, **kwargs):
231
234
w = 1.0 / (absolute (self .fresp [i , j , :]) + 0.001 ), s = 0.0 )
232
235
else :
233
236
self .ifunc = None
234
- super ().__init__ (self .fresp .shape [1 ], self .fresp .shape [0 ])
235
237
236
238
#
237
239
# Frequency response properties
@@ -666,8 +668,6 @@ def to_pandas(self):
666
668
# FrequenceResponseData and then assigning FRD to point to the same object
667
669
# fixes this problem.
668
670
#
669
-
670
-
671
671
FRD = FrequencyResponseData
672
672
673
673
0 commit comments