Skip to content

Commit fabcb37

Browse files
committed
add %matplotlib note + tweak docstrings
1 parent 74d96f0 commit fabcb37

File tree

1 file changed

+39
-34
lines changed

1 file changed

+39
-34
lines changed

control/sisotool.py

+39-34
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def sisotool(sys, initial_gain=None, xlim_rlocus=None, ylim_rlocus=None,
2222
plotstr_rlocus='C0', rlocus_grid=False, omega=None, dB=None,
2323
Hz=None, deg=None, omega_limits=None, omega_num=None,
2424
margins_bode=True, tvect=None, kvect=None):
25-
"""
26-
Sisotool style collection of plots inspired by MATLAB's sisotool.
25+
"""Sisotool style collection of plots inspired by MATLAB's sisotool.
26+
2727
The left two plots contain the bode magnitude and phase diagrams.
2828
The top right plot is a clickable root locus plot, clicking on the
2929
root locus will change the gain of the system. The bottom left plot
@@ -32,52 +32,52 @@ def sisotool(sys, initial_gain=None, xlim_rlocus=None, ylim_rlocus=None,
3232
Parameters
3333
----------
3434
sys : LTI object
35-
Linear input/output systems. If sys is SISO, use the same
36-
system for the root locus and step response. If it is desired to
37-
see a different step response than feedback(K*sys,1), such as a
38-
disturbance response, sys can be provided as a two-input, two-output
39-
system (e.g. by using :func:`bdgalg.connect' or
40-
:func:`iosys.interconnect`). For two-input, two-output
41-
system, sisotool inserts the negative of the selected gain K between
42-
the first output and first input and uses the second input and output
43-
for computing the step response. To see the disturbance response,
44-
configure your plant to have as its second input the disturbance input.
45-
To view the step response with a feedforward controller, give your
46-
plant two identical inputs, and sum your feedback controller and your
47-
feedforward controller and multiply them into your plant's second
48-
input. It is also possible to accomodate a system with a gain in the
49-
feedback.
35+
Linear input/output systems. If sys is SISO, use the same system for
36+
the root locus and step response. If it is desired to see a different
37+
step response than feedback(K*sys,1), such as a disturbance response,
38+
sys can be provided as a two-input, two-output system (e.g. by using
39+
:func:`bdgalg.connect' or :func:`iosys.interconnect`). For two-input,
40+
two-output system, sisotool inserts the negative of the selected gain
41+
K between the first output and first input and uses the second input
42+
and output for computing the step response. To see the disturbance
43+
response, configure your plant to have as its second input the
44+
disturbance input. To view the step response with a feedforward
45+
controller, give your plant two identical inputs, and sum your
46+
feedback controller and your feedforward controller and multiply them
47+
into your plant's second input. It is also possible to accomodate a
48+
system with a gain in the feedback.
5049
initial_gain : float, optional
5150
Initial gain to use for plotting root locus. Defaults to 1
5251
(config.defaults['sisotool.initial_gain']).
5352
xlim_rlocus : tuple or list, optional
54-
control of x-axis range, normally with tuple
53+
Control of x-axis range, normally with tuple
5554
(see :doc:`matplotlib:api/axes_api`).
5655
ylim_rlocus : tuple or list, optional
5756
control of y-axis range
5857
plotstr_rlocus : :func:`matplotlib.pyplot.plot` format string, optional
59-
plotting style for the root locus plot(color, linestyle, etc)
58+
Plotting style for the root locus plot(color, linestyle, etc).
6059
rlocus_grid : boolean (default = False)
6160
If True plot s- or z-plane grid.
6261
omega : array_like
63-
List of frequencies in rad/sec to be used for bode plot
62+
List of frequencies in rad/sec to be used for bode plot.
6463
dB : boolean
65-
If True, plot result in dB for the bode plot
64+
If True, plot result in dB for the bode plot.
6665
Hz : boolean
67-
If True, plot frequency in Hz for the bode plot (omega must be provided in rad/sec)
66+
If True, plot frequency in Hz for the bode plot (omega must be
67+
provided in rad/sec).
6868
deg : boolean
69-
If True, plot phase in degrees for the bode plot (else radians)
69+
If True, plot phase in degrees for the bode plot (else radians).
7070
omega_limits : array_like of two values
71-
Limits of the to generate frequency vector.
72-
If Hz=True the limits are in Hz otherwise in rad/s. Ignored if omega
73-
is provided, and auto-generated if omitted.
71+
Limits of the to generate frequency vector. If Hz=True the limits
72+
are in Hz otherwise in rad/s. Ignored if omega is provided, and
73+
auto-generated if omitted.
7474
omega_num : int
7575
Number of samples to plot. Defaults to
7676
config.defaults['freqplot.number_of_samples'].
7777
margins_bode : boolean
78-
If True, plot gain and phase margin in the bode plot
78+
If True, plot gain and phase margin in the bode plot.
7979
tvect : list or ndarray, optional
80-
List of timesteps to use for closed loop step response
80+
List of timesteps to use for closed loop step response.
8181
8282
Examples
8383
--------
@@ -207,7 +207,7 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
207207
plot=True):
208208
"""Manual PID controller design based on root locus using Sisotool
209209
210-
Uses `Sisotool` to investigate the effect of adding or subtracting an
210+
Uses `sisotool` to investigate the effect of adding or subtracting an
211211
amount `deltaK` to the proportional, integral, or derivative (PID) gains of
212212
a controller. One of the PID gains, `Kp`, `Ki`, or `Kd`, respectively, can
213213
be modified at a time. `Sisotool` plots the step response, frequency
@@ -275,18 +275,18 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
275275
Parameters
276276
----------
277277
plant : :class:`LTI` (:class:`TransferFunction` or :class:`StateSpace` system)
278-
The dynamical system to be controlled
278+
The dynamical system to be controlled.
279279
gain : string (optional)
280280
Which gain to vary by `deltaK`. Must be one of `'P'`, `'I'`, or `'D'`
281-
(proportional, integral, or derative)
281+
(proportional, integral, or derative).
282282
sign : int (optional)
283-
The sign of deltaK gain perturbation
283+
The sign of deltaK gain perturbation.
284284
input : string (optional)
285285
The input used for the step response; must be `'r'` (reference) or
286-
`'d'` (disturbance) (see figure above)
286+
`'d'` (disturbance) (see figure above).
287287
Kp0, Ki0, Kd0 : float (optional)
288288
Initial values for proportional, integral, and derivative gains,
289-
respectively
289+
respectively.
290290
deltaK : float (optional)
291291
Perturbation value for gain specified by the `gain` keywoard.
292292
tau : float (optional)
@@ -307,6 +307,11 @@ def rootlocus_pid_designer(plant, gain='P', sign=+1, input_signal='r',
307307
closedloop : class:`StateSpace` system
308308
The closed-loop system using initial gains.
309309
310+
Notes
311+
-----
312+
When running using iPython or Jupyter, use `%matplotlib` to configure
313+
the session for interactive support.
314+
310315
"""
311316

312317
if plant.ninputs == 1:

0 commit comments

Comments
 (0)