This repository contains a set of Jupyter Notebooks containing examples of how to use the Canopy Python library.
Each example tends to install a specific version of the Canopy library, for example
pip install -q 'canopy==8.13'. This is so that the example continues to run even if we make breaking changes to the underlying Canopy Python library. In your own code you can either install a specific version or use the latest version with
pip install -q canopy. If you do find some of the example code fails to run in the latest version of the library, let us know and we will update it.
If you find you need to update your Canopy library you can run
pip install --upgrade canopy. If you run this from a Jupyter Notebook or other runtime, make sure you restart the runtime after upgrading to pick up the newly installed version.
Breaking changes to the Canopy Python library are documented in the CHANGELOG.md file.
Loading and Saving Configs takes you through the basics of accessing and creating configs on the platform.
Running Studies demonstrates loading configs and using them to run run studies on the platform, including how to ensure a study has completed before extracting the results.
Loading Vector Results shows how to load channel data from simulations for further analysis and visualization.
Loading Scalar Results shows how to load scalar results from simulations for further analysis and visualization.
Loading All Vector Results shows how you would go about loading every single channel from a study by using the vector metadata to extract the list of channels.
Loading Study Data from Worksheets shows how to iterate through the rows of a worksheet and extract scalar and vector data from each study in the worksheet.
Deleting old studies shows how to bulk delete studies, should you wish to free up storage credits.
Encrypting Config Components shows how to programatically encrypt part of a config.
Converting bump-stops from lookup to parametric loads a car with a bump stop lookup, converts it to a parametric bump stop, and saves the result as a new car on the platform.
Finding the quickest 5 seconds to apply a power increase uses the
dTLap_drEnginePowerFactorchannel to find the sLap ranges representing the optimal places to deploy 5 seconds of power increase.
Fitting aero data to a polynomial and RBF fits some data from a CSV file and saves the resulting polynomial and RBF aero definition to a car on the platform.
The examples use Jupyter Notebooks which can be viewed directly on GitHub. If you want to interact with the notebook, or create your own, you'll need to either install Juypyer Notebooks locally using something like the Anaconda Distribution or use one of the many online Jupyter Notebook hosts such as the excellent and free Google Colab.
Note that Google Colab uses a fairly old IPython runtime by default, so most of our examples start by upgrading the runtime to support the latest Python features, in particular async/await at the cell level. The process for running the examples after opening in Google Colab is therefore:
- Run the "Upgrade Runtime" cell.
- Click the button that appears to restart the runtime.
- Run the rest of the notebook.
Most of the examples use Matplotlib which has the advantage of rendering in GitHub. However numerous other options are available such as Seaborn which sits on top of Matplotlib, Bokeh and Plotly which have great interactivity support and Altair.