Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
initial refactoring of bode_plot
  • Loading branch information
murrayrm committed Sep 16, 2023
commit aef709cda19495ba3968454bbca6cbfca0fbcd71
12 changes: 10 additions & 2 deletions control/frdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

from .lti import LTI, _process_frequency_response
from .exception import pandas_check
from .iosys import InputOutputSystem, _process_iosys_keywords
from .iosys import InputOutputSystem, _process_iosys_keywords, common_timebase
from . import config

__all__ = ['FrequencyResponseData', 'FRD', 'frd']
Expand Down Expand Up @@ -93,6 +93,8 @@ class FrequencyResponseData(LTI):
fresp : 3D array
Frequency response, indexed by output index, input index, and
frequency point.
dt : float, True, or None
System timebase.

Notes
-----
Expand Down Expand Up @@ -169,6 +171,7 @@ def __init__(self, *args, **kwargs):
else:
z = np.exp(1j * self.omega * otherlti.dt)
self.fresp = otherlti(z, squeeze=False)
arg_dt = otherlti.dt

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

elif len(args) == 1:
# Use the copy constructor.
Expand All @@ -191,6 +195,8 @@ def __init__(self, *args, **kwargs):
" an FRD object. Received %s." % type(args[0]))
self.omega = args[0].omega
self.fresp = args[0].fresp
arg_dt = args[0].dt

else:
raise ValueError(
"Needs 1 or 2 arguments; received %i." % len(args))
Expand All @@ -210,9 +216,11 @@ def __init__(self, *args, **kwargs):

# Process iosys keywords
defaults = {
'inputs': self.fresp.shape[1], 'outputs': self.fresp.shape[0]}
'inputs': self.fresp.shape[1], 'outputs': self.fresp.shape[0],
'dt': None}
name, inputs, outputs, states, dt = _process_iosys_keywords(
kwargs, defaults, end=True)
dt = common_timebase(dt, arg_dt) # choose compatible timebase

# Process signal names
InputOutputSystem.__init__(
Expand Down
Loading