Skip to content

Commit 73c8c80

Browse files
committed
add gangof4_plot back as non-legacy function
1 parent 4285454 commit 73c8c80

File tree

1 file changed

+66
-5
lines changed

1 file changed

+66
-5
lines changed

control/freqplot.py

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,18 @@ def gangof4_response(
20692069
Linear input/output systems (process and control).
20702070
omega : array
20712071
Range of frequencies (list or bounds) in rad/sec.
2072+
omega_limits : array_like of two values
2073+
Set limits for plotted frequency range. If Hz=True the limits are
2074+
in Hz otherwise in rad/s. Specifying ``omega`` as a list of two
2075+
elements is equivalent to providing ``omega_limits``. Ignored if
2076+
data is not a list of systems.
2077+
omega_num : int
2078+
Number of samples to use for the frequeny range. Defaults to
2079+
config.defaults['freqplot.number_of_samples']. Ignored if data is
2080+
not a list of systems.
2081+
Hz : bool, optional
2082+
If True, when computing frequency limits automatically set
2083+
limits to full decades in Hz instead of rad/s.
20722084
20732085
Returns
20742086
-------
@@ -2123,11 +2135,60 @@ def gangof4_response(
21232135

21242136

21252137
def gangof4_plot(
2126-
P, C, omega=None, omega_limits=None, omega_num=None, **kwargs):
2127-
"""Legacy Gang of 4 plot; use gangof4_response().plot() instead."""
2128-
return gangof4_response(
2129-
P, C, omega=omega, omega_limits=omega_limits,
2130-
omega_num=omega_num).plot(**kwargs)
2138+
*args, omega=None, omega_limits=None, omega_num=None,
2139+
Hz=False, **kwargs):
2140+
"""Plot the response of the "Gange of 4" transfer functions for a system.
2141+
2142+
Plots a 2x2 frequency response for the "Gang of 4" sensitivity
2143+
functions [T, PS; CS, S]. Can be called in one of two ways:
2144+
2145+
gangof4_plot(response[, ...])
2146+
gangof4_plot(P, C[, ...])
2147+
2148+
Parameters
2149+
----------
2150+
response : FrequencyPlotData
2151+
Gang of 4 frequency response from `gangof4_response`.
2152+
P, C : LTI
2153+
Linear input/output systems (process and control).
2154+
omega : array
2155+
Range of frequencies (list or bounds) in rad/sec.
2156+
omega_limits : array_like of two values
2157+
Set limits for plotted frequency range. If Hz=True the limits are
2158+
in Hz otherwise in rad/s. Specifying ``omega`` as a list of two
2159+
elements is equivalent to providing ``omega_limits``. Ignored if
2160+
data is not a list of systems.
2161+
omega_num : int
2162+
Number of samples to use for the frequeny range. Defaults to
2163+
config.defaults['freqplot.number_of_samples']. Ignored if data is
2164+
not a list of systems.
2165+
Hz : bool, optional
2166+
If True, when computing frequency limits automatically set
2167+
limits to full decades in Hz instead of rad/s.
2168+
2169+
Returns
2170+
-------
2171+
response : :class:`~control.FrequencyResponseData`
2172+
Frequency response with inputs 'r' and 'd' and outputs 'y', and 'u'
2173+
representing the 2x2 matrix of transfer functions in the Gang of 4.
2174+
2175+
"""
2176+
if len(args) == 1 and isinstance(arg, FrequencyResponseData):
2177+
if any([kw is not None
2178+
for kw in [omega, omega_limits, omega_num, Hz]]):
2179+
raise ValueError(
2180+
"omega, omega_limits, omega_num, Hz not allowed when "
2181+
"given a Gang of 4 response as first argument")
2182+
return args[0].plot(kwargs)
2183+
else:
2184+
if len(args) > 3:
2185+
raise TypeError(
2186+
f"expecting 2 or 3 positional arguments; received {len(args)}")
2187+
omega = omega if len(args) < 3 else args[2]
2188+
args = args[0:2]
2189+
return gangof4_response(
2190+
*args, omega=omega, omega_limits=omega_limits,
2191+
omega_num=omega_num, Hz=Hz).plot(**kwargs)
21312192

21322193
#
21332194
# Singular values plot

0 commit comments

Comments
 (0)