Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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
languagebash
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:

...

You can start typing your code into the boxescells. Press CTRL-Return to execute the code in the current cell, or SHIFT-Return to execute and move to the next code cell. The Kernel menu allows the restart of a session. To generate plots inside the notebook, call

...

at some point before calling the plot() command. By default, plots will go to an interactive Metview plot window unless this is done.

mv.setoutput('jupyter') for inline plotsWith no setoutput command, and an interactive plot window

Image RemovedImage Added

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.

Image Added

Pressing the Run button will invoke the Python interpreter (whatever the python3 command runs) and show output in the bottom panel.

Image Added