63
63
_freqplot_defaults = {
64
64
'freqplot.feature_periphery_decades' :1 ,
65
65
'freqplot.number_of_samples' :1000 ,
66
+ 'freqplot.dB' :False ,# Plot gain in dB
67
+ 'freqplot.deg' :True ,# Plot phase in degrees
68
+ 'freqplot.Hz' :False ,# Plot frequency in Hertz
69
+ 'freqplot.grid' :True ,# Turn on grid for gain and phase
70
+ 'freqplot.wrap_phase' :False ,# Wrap the phase plot at a given value
66
71
}
67
72
68
73
#
76
81
# Bode plot
77
82
#
78
83
79
- # Default values for Bode plot configuration variables
80
- _bode_defaults = {
81
- 'bode.dB' :False ,# Plot gain in dB
82
- 'bode.deg' :True ,# Plot phase in degrees
83
- 'bode.Hz' :False ,# Plot frequency in Hertz
84
- 'bode.grid' :True ,# Turn on grid for gain and phase
85
- 'bode.wrap_phase' :False ,# Wrap the phase plot at a given value
86
- }
87
-
88
84
89
85
def bode_plot (syslist ,omega = None ,
90
86
plot = True ,omega_limits = None ,omega_num = None ,
@@ -103,10 +99,10 @@ def bode_plot(syslist, omega=None,
103
99
If True, plot result in dB. Default is false.
104
100
Hz : bool
105
101
If True, plot frequency in Hz (omega must be provided in rad/sec).
106
- Default value (False) set by config.defaults['bode .Hz']
102
+ Default value (False) set by config.defaults['freqplot .Hz']
107
103
deg : bool
108
104
If True, plot phase in degrees (else radians). Default value (True)
109
- config.defaults['bode .deg']
105
+ config.defaults['freqplot .deg']
110
106
plot : bool
111
107
If True (default), plot magnitude and phase
112
108
omega_limits : array_like of two values
@@ -184,16 +180,21 @@ def bode_plot(syslist, omega=None,
184
180
plot = kwargs .pop ('Plot' )
185
181
186
182
# Get values for params (and pop from list to allow keyword use in plot)
187
- dB = config ._get_param ('bode' ,'dB' ,kwargs ,_bode_defaults ,pop = True )
188
- deg = config ._get_param ('bode' ,'deg' ,kwargs ,_bode_defaults ,pop = True )
189
- Hz = config ._get_param ('bode' ,'Hz' ,kwargs ,_bode_defaults ,pop = True )
190
- grid = config ._get_param ('bode' ,'grid' ,kwargs ,_bode_defaults ,pop = True )
191
- plot = config ._get_param ('bode' ,'plot' ,plot ,True )
192
- margins = config ._get_param ('bode' ,'margins' ,margins ,False )
183
+ dB = config ._get_param (
184
+ 'freqplot' ,'dB' ,kwargs ,_freqplot_defaults ,pop = True )
185
+ deg = config ._get_param (
186
+ 'freqplot' ,'deg' ,kwargs ,_freqplot_defaults ,pop = True )
187
+ Hz = config ._get_param (
188
+ 'freqplot' ,'Hz' ,kwargs ,_freqplot_defaults ,pop = True )
189
+ grid = config ._get_param (
190
+ 'freqplot' ,'grid' ,kwargs ,_freqplot_defaults ,pop = True )
191
+ plot = config ._get_param ('freqplot' ,'plot' ,plot ,True )
192
+ margins = config ._get_param (
193
+ 'freqplot' ,'margins' ,margins ,False )
193
194
wrap_phase = config ._get_param (
194
- 'bode ' ,'wrap_phase' ,kwargs ,_bode_defaults ,pop = True )
195
+ 'freqplot ' ,'wrap_phase' ,kwargs ,_freqplot_defaults ,pop = True )
195
196
initial_phase = config ._get_param (
196
- 'bode ' ,'initial_phase' ,kwargs ,None ,pop = True )
197
+ 'freqplot ' ,'initial_phase' ,kwargs ,None ,pop = True )
197
198
omega_num = config ._get_param ('freqplot' ,'number_of_samples' ,omega_num )
198
199
# If argument was a singleton, turn it into a tuple
199
200
if not hasattr (syslist ,'__iter__' ):
@@ -937,9 +938,12 @@ def gangof4_plot(P, C, omega=None, **kwargs):
937
938
"Gang of four is currently only implemented for SISO systems." )
938
939
939
940
# Get the default parameter values
940
- dB = config ._get_param ('bode' ,'dB' ,kwargs ,_bode_defaults ,pop = True )
941
- Hz = config ._get_param ('bode' ,'Hz' ,kwargs ,_bode_defaults ,pop = True )
942
- grid = config ._get_param ('bode' ,'grid' ,kwargs ,_bode_defaults ,pop = True )
941
+ dB = config ._get_param (
942
+ 'freqplot' ,'dB' ,kwargs ,_freqplot_defaults ,pop = True )
943
+ Hz = config ._get_param (
944
+ 'freqplot' ,'Hz' ,kwargs ,_freqplot_defaults ,pop = True )
945
+ grid = config ._get_param (
946
+ 'freqplot' ,'grid' ,kwargs ,_freqplot_defaults ,pop = True )
943
947
944
948
# Compute the senstivity functions
945
949
L = P * C
@@ -1094,11 +1098,11 @@ def singular_values_plot(syslist, omega=None,
1094
1098
1095
1099
# Get values for params (and pop from list to allow keyword use in plot)
1096
1100
dB = config ._get_param (
1097
- 'singular_values_plot ' ,'dB' ,kwargs ,_singular_values_plot_default ,pop = True )
1101
+ 'freqplot ' ,'dB' ,kwargs ,_singular_values_plot_default ,pop = True )
1098
1102
Hz = config ._get_param (
1099
- 'singular_values_plot ' ,'Hz' ,kwargs ,_singular_values_plot_default ,pop = True )
1103
+ 'freqplot ' ,'Hz' ,kwargs ,_singular_values_plot_default ,pop = True )
1100
1104
grid = config ._get_param (
1101
- 'singular_values_plot ' ,'grid' ,kwargs ,_singular_values_plot_default ,pop = True )
1105
+ 'freqplot ' ,'grid' ,kwargs ,_singular_values_plot_default ,pop = True )
1102
1106
plot = config ._get_param (
1103
1107
'singular_values_plot' ,'plot' ,plot ,True )
1104
1108
omega_num = config ._get_param ('freqplot' ,'number_of_samples' ,omega_num )
@@ -1262,7 +1266,7 @@ def _determine_omega_vector(syslist, omega_in, omega_limits, omega_num, Hz):
1262
1266
np .log10 (omega_limits [1 ]),
1263
1267
num = omega_num ,endpoint = True )
1264
1268
else :
1265
- omega_out = np .asarray (omega_in )
1269
+ omega_out = np .copy (omega_in )
1266
1270
if Hz :
1267
1271
omega_out *= 2. * math .pi
1268
1272
return omega_out ,omega_range_given