Skip to content

CDS 110 and CDS 112 Jupyter notebooks #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ venv/
ENV/
env.bak/
venv.bak/

# Files for MacOS
.DS_Store
6 changes: 6 additions & 0 deletions control/freqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def bode_plot(
figure with the correct number and shape of axes, a new figure is
created. The shape of the array must match the shape of the
plotted data.
freq_label: str, optional
Frequency label (defaults to "rad/sec" or "Hertz")
grid : bool, optional
If True, plot grid lines on gain and phase plots. Default is set by
`config.defaults['freqplot.grid']`.
Expand All @@ -168,6 +170,8 @@ def bode_plot(
legend_loc : int or str, optional
Include a legend in the given location. Default is 'center right',
with no legend for a single response. Use False to suppress legend.
magnitude_label : str, optional
Label to use for magnitude axis. Defaults to "Magnitude".
margins_method : str, optional
Method to use in computing margins (see :func:`stability_margins`).
omega_limits : array_like of two values
Expand All @@ -179,6 +183,8 @@ def bode_plot(
Number of samples to use for the frequeny range. Defaults to
config.defaults['freqplot.number_of_samples']. Ignored if data is
not a list of systems.
phase_label : str, optional
Label to use for phase axis. Defaults to "Phase [rad]".
plot : bool, optional
(legacy) If given, `bode_plot` returns the legacy return values
of magnitude, phase, and frequency. If False, just return the
Expand Down
2 changes: 1 addition & 1 deletion control/phaseplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def vectorfield(
sys._update_params(params)
for i, x in enumerate(points):
vfdata[i, :2] = x
vfdata[i, 2:] = sys._rhs(0, x, 0)
vfdata[i, 2:] = sys._rhs(0, x, np.zeros(sys.ninputs))

with plt.rc_context(rcParams):
out = ax.quiver(
Expand Down
18 changes: 17 additions & 1 deletion doc/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Examples

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
via the `python-control GitHub repository <https://github.com/python-control/python-control/tree/master/examples>`_.
via the `python-control GitHub repository <https://github.com/python-control/python-control/tree/main/examples>`_.



Python scripts
Expand Down Expand Up @@ -62,3 +62,19 @@ online sources.
simulating_discrete_nonlinear
steering
stochresp

Google Colab Notebooks
======================

A collection of Jupyter notebooks are available on `Google Colab
<https://colab.research.google.com>`_, where they can be executed
through a web browser:

* `Caltech CDS 110 Google Colab notebooks
<https://drive.google.com/drive/folders/1LI2xWVn1kqrZ5lIcM5Ktxr2B7X730cCj?usp=share_link>`_:
Jupyter notebooks created by Richard Murray for CDS 110 (Analysis
and Design of Feedback Systems) at Caltech.

Note: in order to execute the Jupyter notebooks in this collection,
you will need a Google account that has access to the Google
Colaboratory application.
1 change: 1 addition & 0 deletions examples/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ipynb-clean
29 changes: 29 additions & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Makefile for python-control examples
# RMM, 6 Jul 2024
#
# This makefile allows cleanup and posting of Jupyter notebooks into
# Google Colab.
#
# Files are copied to Google Colab using rclone. In order to copy files to
# Google Colab, you should edit the GDRIVE variable to use the name of the
# drive you have configured in rclone and the path where you want to place
# the files. The default location is set up for the fbsbook.org@gmail.com
# Google Drive account, currently maintained by Richard Murray.

NOTEBOOKS = cds110-L*_*.ipynb cds112-L*_*.ipynb
GDRIVE= fbsbook-gdrive:python-control/public/notebooks

# Clean up notebooks to remove output
clean: .ipynb-clean
.ipynb-clean: $(NOTEBOOKS)
@for i in $?; do \
echo jupyter nbconvert --clear-output clear-metadata $$i; \
jupyter nbconvert \
--ClearMetadataPreprocessor.enabled=True \
--clear-output $$i; \
done
touch $@

# Post Jupyter notebooks on course website
post: .ipynb-clean
rclone copy . $(GDRIVE) --include /cds110-L\*_\*.ipynb
Loading
Loading