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
Prev Previous commit
Next Next commit
PEP8 cleanup
  • Loading branch information
murrayrm committed Mar 21, 2020
commit dcf12fd496d3e93dfe57bafc3a0f747939f2a797
25 changes: 15 additions & 10 deletions control/nichols.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

# Default parameters values for the nichols module
_nichols_defaults = {
'nichols.grid':True,
'nichols.grid': True,
}


Expand Down Expand Up @@ -156,12 +156,13 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
# Default chart magnitudes
# The key set of magnitudes are always generated, since this
# guarantees a recognizable Nichols chart grid.
key_cl_mags = np.array([-40.0, -20.0, -12.0, -6.0, -3.0, -1.0, -0.5, 0.0,
0.25, 0.5, 1.0, 3.0, 6.0, 12.0])
key_cl_mags = np.array([-40.0, -20.0, -12.0, -6.0, -3.0, -1.0, -0.5,
0.0, 0.25, 0.5, 1.0, 3.0, 6.0, 12.0])

# Extend the range of magnitudes if necessary. The extended arange
# will end up empty if no extension is required. Assumes that closed-loop
# magnitudes are approximately aligned with open-loop magnitudes beyond
# the value of np.min(key_cl_mags)
# will end up empty if no extension is required. Assumes that
# closed-loop magnitudes are approximately aligned with open-loop
# magnitudes beyond the value of np.min(key_cl_mags)
cl_mag_step = -20.0 # dB
extended_cl_mags = np.arange(np.min(key_cl_mags),
ol_mag_min + cl_mag_step, cl_mag_step)
Expand All @@ -171,7 +172,8 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
if cl_phases is None:
# Choose a reasonable set of default phases (denser if the open-loop
# data is restricted to a relatively small range of phases).
key_cl_phases = np.array([-0.25, -45.0, -90.0, -180.0, -270.0, -325.0, -359.75])
key_cl_phases = np.array([-0.25, -45.0, -90.0, -180.0, -270.0,
-325.0, -359.75])
if np.abs(ol_phase_max - ol_phase_min) < 90.0:
other_cl_phases = np.arange(-10.0, -360.0, -10.0)
else:
Expand All @@ -181,7 +183,8 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
assert ((-360.0 < np.min(cl_phases)) and (np.max(cl_phases) < 0.0))

# Find the M-contours
m = m_circles(cl_mags, phase_min=np.min(cl_phases), phase_max=np.max(cl_phases))
m = m_circles(cl_mags, phase_min=np.min(cl_phases),
phase_max=np.max(cl_phases))
m_mag = 20*sp.log10(np.abs(m))
m_phase = sp.mod(sp.degrees(sp.angle(m)), -360.0) # Unwrap

Expand All @@ -208,9 +211,11 @@ def nichols_grid(cl_mags=None, cl_phases=None, line_style='dotted'):
linestyle=line_style, zorder=0)

# Add magnitude labels
for x, y, m in zip(m_phase[:][-1] + phase_offset, m_mag[:][-1], cl_mags):
for x, y, m in zip(m_phase[:][-1] + phase_offset, m_mag[:][-1],
cl_mags):
align = 'right' if m < 0.0 else 'left'
plt.text(x, y, str(m) + ' dB', size='small', ha=align, color='gray')
plt.text(x, y, str(m) + ' dB', size='small', ha=align,
color='gray')

# Fit axes to generated chart
plt.axis([phase_offset_min - 360.0, phase_offset_max - 360.0,
Expand Down
7 changes: 3 additions & 4 deletions control/pzmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

# Define default parameter values for this module
_pzmap_defaults = {
'pzmap.grid':False, # Plot omega-damping grid
'pzmap.plot':True, # Generate plot using Matplotlib
'pzmap.grid': False, # Plot omega-damping grid
'pzmap.plot': True, # Generate plot using Matplotlib
}


Expand Down Expand Up @@ -89,7 +89,7 @@ def pzmap(sys, plot=True, grid=False, title='Pole Zero Map', **kwargs):
# Get parameter values
plot = config._get_param('rlocus', 'plot', plot, True)
grid = config._get_param('rlocus', 'grid', grid, False)

if not isinstance(sys, LTI):
raise TypeError('Argument ``sys``: must be a linear system.')

Expand All @@ -115,7 +115,6 @@ def pzmap(sys, plot=True, grid=False, title='Pole Zero Map', **kwargs):
ax.scatter(real(zeros), imag(zeros), s=50, marker='o',
facecolors='none', edgecolors='k')


plt.title(title)

# Return locations of poles and zeros as a tuple
Expand Down
10 changes: 5 additions & 5 deletions control/rlocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@

# Default values for module parameters
_rlocus_defaults = {
'rlocus.grid':True,
'rlocus.plotstr':'b' if int(matplotlib.__version__[0]) == 1 else 'C0',
'rlocus.print_gain':True,
'rlocus.plot':True
'rlocus.grid': True,
'rlocus.plotstr': 'b' if int(matplotlib.__version__[0]) == 1 else 'C0',
'rlocus.print_gain': True,
'rlocus.plot': True
}


Expand Down Expand Up @@ -110,7 +110,7 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None,
warnings.warn("'Plot' keyword is deprecated in root_locus; "
"use 'plot'", FutureWarning)
# Map 'Plot' keyword to 'plot' keyword
plot= kwargs.pop('Plot')
plot = kwargs.pop('Plot')

# Check to see if legacy 'PrintGain' keyword was used
if 'PrintGain' in kwargs:
Expand Down
2 changes: 1 addition & 1 deletion control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

# Define module default parameter values
_statesp_defaults = {
'statesp.use_numpy_matrix':True,
'statesp.use_numpy_matrix': True,
}


Expand Down