Comment on page
Using Python Notebooks
Getting started with Python notebooks
Notebooks are environments where you can write Python code to load models and run simulations over them programmatically. This will allow you to run multiple simulations with different parameters or input data, and find the optimal parameters for your model. You can also use Python code to more closely look at the simulation results data, plot the data in different ways with matplotlib, or even analyze the linearized version of a submodel.
Alternatively, you can click the
+icon next to Notebooks in the left pane to create new notebooks.
After a while, the notebook editor page should come up. It will likely ask you to select a kernel: choose python3.
Cells of type markdown can contain markdown-formatted text, meaning it can contain section titles, bold or slanted text, small tables, formulas, etc... The full specification for markdown and its syntax can be found at https://daringfireball.net/projects/markdown/basics.
Here is an example of a markdown cell with its raw contents and its rendered output:
Markdown cells can be used to add documentation to your projects and models.
These cells are non-code text cells that can only contain plain text, without any specific formatting.
More default scientific libraries can be added upon request to the Collimator team.
Shift+Enterto run the current cell and jump to the next one, or create a new one if this is the last cell.
Ctrl+Enterto run the current cell without changing focus.
Option+Enteron macOS) to run the current cell and always create a new one.
- go back to the dashboard, via the collimator icon
- see the list of models, files and notebooks in the current project
- see the currently running kernels
- save the notebook
- insert a new cell
- cut, copy and paste existing cells
- execute the current cell
- stop the current cell
- restart the kernel, which resets the python environment entirely
- restart the kernel and replay the entire notebook
Note that stopping a cell execution will not cancel running simulations as those are executed in a separate, distributed cloud environment.
- select the type of the currently selected cell. This allows switching between python and text types.
Escto get the focus out of a cell and
dtwice to delete the selected cell(s).
The documentation for
collimatorpython package can be accessed via the python
help()built in function. This inline documentation will always be the most up-to-date version since it is based on inline comments in the code.
Further information can be displayed with the
In the left pane, you can select the
Kernel browsertab to see which python kernels are currently running on your server.
At the bottom of the page, you can find two tabs: Variables and Console. If you open the console, you will have access to a Python console that runs within the same environment as the Notebook cells. This can allow you to run some quick Python commands and prototype code before moving it back to a notebook cell.
Closing the Console tab will reset its contents.
Left from the Console tab, the Variables tab can be found. Its contents should reflect the top-level variables defined in the currently running python environment. Use it to observe at a quick glance what variables are defined and their values.
xbutton allows you to remove variables from the environment. This has the same effect as calling