10000 Merge pull request #1037 from murrayrm/cds_examples-06Jul2024 · python-control/python-control@3d79ce3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d79ce3

Browse files
authored
Merge pull request #1037 from murrayrm/cds_examples-06Jul2024
CDS 110 and CDS 112 Jupyter notebooks
2 parents 373ff11 + 7915c91 commit 3d79ce3

39 files changed

+13769
-2698
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ venv/
4242
ENV/
4343
env.bak/
4444
venv.bak/
45+
46+
# Files for MacOS
47+
.DS_Store

control/freqplot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ def bode_plot(
147147
figure with the correct number and shape of axes, a new figure is
148148
created. The shape of the array must match the shape of the
149149
plotted data.
150+
freq_label: str, optional
151+
Frequency label (defaults to "rad/sec" or "Hertz")
150152
grid : bool, optional
151153
If True, plot grid lines on gain and phase plots. Default is set by
152154
`config.defaults['freqplot.grid']`.
@@ -168,6 +170,8 @@ def bode_plot(
168170
legend_loc : int or str, optional
169171
Include a legend in the given location. Default is 'center right',
170172
with no legend for a single response. Use False to suppress legend.
173+
magnitude_label : str, optional
174+
Label to use for magnitude axis. Defaults to "Magnitude".
171175
margins_method : str, optional
172176
Method to use in computing margins (see :func:`stability_margins`).
173177
omega_limits : array_like of two values
@@ -179,6 +183,8 @@ def bode_plot(
179183
Number of samples to use for the frequeny range. Defaults to
180184
config.defaults['freqplot.number_of_samples']. Ignored if data is
181185
not a list of systems.
186+
phase_label : str, optional
187+
Label to use for phase axis. Defaults to "Phase [rad]".
182188
plot : bool, optional
183189
(legacy) If given, `bode_plot` returns the legacy return values
184190
of magnitude, phase, and frequency. If False, just return the

control/phaseplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def vectorfield(
309309
sys._update_params(params)
310310
for i, x in enumerate(points):
311311
vfdata[i, :2] = x
312-
vfdata[i, 2:] = sys._rhs(0, x, 0)
312+
vfdata[i, 2:] = sys._rhs(0, x, np.zeros(sys.ninputs))
313313

314314
with plt.rc_context(rcParams):
315315
out = ax.quiver(

doc/examples.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Examples
77

88
The source code for the examples below are available in the `examples/`
99
subdirectory of the source code distribution. They can also be accessed online
10-
via the [python-control GitHub repository](https://github.com/python-control/python-control/tree/master/examples).
10+
via the `python-control GitHub repository <https://github.com/python-control/python-control/tree/master/examples>`_.
1111

1212

1313
Python scripts
@@ -62,3 +62,19 @@ online sources.
6262
simulating_discrete_nonlinear
6363
steering
6464
stochresp
65+
66+
Google Colab Notebooks
67+
======================
68+
69+
A collection of Jupyter notebooks are available on `Google Colab
70+
<https://colab.research.google.com>`_, where they can be executed
71+
through a web browser:
72+
73+
* `Caltech CDS 110 Google Colab notebooks
74+
<https://drive.google.com/drive/folders/1LI2xWVn1kqrZ5lIcM5Ktxr2B7X730cCj?usp=share_link>`_:
75+
Jupyter notebooks created by Richard Murray for CDS 110 (Analysis
76+
and Design of Feedback Systems) at Caltech.
77+
78+
Note: in order to execute the Jupyter notebooks in this collection,
79+
you will need a Google account that has access to the Google
80+
Colaboratory application.

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.ipynb-clean

examples/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Makefile for python-control examples
2+
# RMM, 6 Jul 2024
3+
#
4+
# This makefile allows cleanup and posting of Jupyter notebooks into
5+
# Google Colab.
6+
#
7+
# Files are copied to Google Colab using rclone. In order to copy files to
8+
# Google Colab, you should edit the GDRIVE variable to use the name of the
9+
# drive you have configured in rclone and the path where you want to place
10+
# the files. The default location is set up for the fbsbook.org@gmail.com
11+
# Google Drive account, currently maintained by Richard Murray.
12+
13+
NOTEBOOKS = cds110-L*_*.ipynb cds112-L*_*.ipynb
14+
GDRIVE= fbsbook-gdrive:python-control/public/notebooks
15+
16+
# Clean up notebooks to remove output
17+
clean: .ipynb-clean
18+
.ipynb-clean: $(NOTEBOOKS)
19+
@for i in $?; do \
20+
echo jupyter nbconvert --clear-output clear-metadata $$i; \
21+
jupyter nbconvert \
22+
--ClearMetadataPreprocessor.enabled=True \
23+
--clear-output $$i; \
24+
done
25+
touch $@
26+
27+
# Post Jupyter notebooks on course website
28+
post: .ipynb-clean
29+
rclone copy . $(GDRIVE) --include /cds110-L\*_\*.ipynb

0 commit comments

Comments
 (0)
0