Skip to content

Commit aef709c

Browse files
committed
initial refactoring of bode_plot
1 parent 0a6146b commit aef709c

File tree

5 files changed

+636
-360
lines changed

5 files changed

+636
-360
lines changed

control/frdata.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
from .lti import LTI, _process_frequency_response
5656
from .exception import pandas_check
57-
from .iosys import InputOutputSystem, _process_iosys_keywords
57+
from .iosys import InputOutputSystem, _process_iosys_keywords, common_timebase
5858
from . import config
5959

6060
__all__ = ['FrequencyResponseData', 'FRD', 'frd']
@@ -93,6 +93,8 @@ class FrequencyResponseData(LTI):
9393
fresp : 3D array
9494
Frequency response, indexed by output index, input index, and
9595
frequency point.
96+
dt : float, True, or None
97+
System timebase.
9698
9799
Notes
98100
-----
@@ -169,6 +171,7 @@ def __init__(self, *args, **kwargs):
169171
else:
170172
z = np.exp(1j * self.omega * otherlti.dt)
171173
self.fresp = otherlti(z, squeeze=False)
174+
arg_dt = otherlti.dt
172175

173176
else:
174177
# The user provided a response and a freq vector
@@ -182,6 +185,7 @@ def __init__(self, *args, **kwargs):
182185
"The frequency data constructor needs a 1-d or 3-d"
183186
" response data array and a matching frequency vector"
184187
" size")
188+
arg_dt = None
185189

186190
elif len(args) == 1:
187191
# Use the copy constructor.
@@ -191,6 +195,8 @@ def __init__(self, *args, **kwargs):
191195
" an FRD object. Received %s." % type(args[0]))
192196
self.omega = args[0].omega
193197
self.fresp = args[0].fresp
198+
arg_dt = args[0].dt
199+
194200
else:
195201
raise ValueError(
196202
"Needs 1 or 2 arguments; received %i." % len(args))
@@ -210,9 +216,11 @@ def __init__(self, *args, **kwargs):
210216

211217
# Process iosys keywords
212218
defaults = {
213-
'inputs': self.fresp.shape[1], 'outputs': self.fresp.shape[0]}
219+
'inputs': self.fresp.shape[1], 'outputs': self.fresp.shape[0],
220+
'dt': None}
214221
name, inputs, outputs, states, dt = _process_iosys_keywords(
215222
kwargs, defaults, end=True)
223+
dt = common_timebase(dt, arg_dt) # choose compatible timebase
216224

217225
# Process signal names
218226
InputOutputSystem.__init__(

0 commit comments

Comments
 (0)