Here are some different ways that you can use Metview's Python interface. Make sure you have set up your environment first.
Table of Contents |
---|
Text editor and command line
Perhaps the simplest - just use any text editor to edit the Python code and run it from the command line, e.g.
Code Block | ||
---|---|---|
| ||
python3 my_metv_python_script.py |
Python IDE
Python IDEs, such as PyCharm, provide an interactive environment and even debugging facilities.
Jupyter notebook
A Jupyter notebook provides an interactive workspace combining code, plots and documentation. It runs in a web browser and can be started from the command-line as follows:
...
mv.setoutput('jupyter') for inline plots | With no setoutput command, and an interactive plot window |
---|---|
A Metview session
A Metview Python script can be created, edited and run from within an interactive Metview session in the same way that a Metview Macro can.
From the main user interface, right-click on an empty part of the Metview desktop, select Create New Icon and choose Python Script.
You can either just start writing your Python code, or you can use Metview to help you. Any Metview icons can be dropped into Metview's Code Editor, and the corresponding Python code will be automatically generated for you, giving a convenient way of trying things out interactively before committing them to code.
Pressing the Run button will invoke the Python interpreter (whatever the python3 command runs) and show output in the bottom panel.