Skip to end of metadata
Go to start of metadata

Metview's Python interface is currently available on internal ECMWF desktop machines, lxc and on the Member State server ecgate. It is also on github and PyPi and can be installed with the command "pip install metview".

Setup

To use it, you need three things:

  1. A Python 3 interpreter
  2. Metview 5 needs to be installed and in your PATH
  3. Metview's Python module needs to be accessible from Python

So, to try it right now, do the following from a terminal:

module load python3/new
module swap metview/new
module load metview-python/new

The internal installation at ECMWF also includes the cfgrib library for obtaining xarray datasets from GRIB. Metview's to_dataset() function uses this internally from version 0.8.4 onwards.

If you plan to use the cfgrib module directly, you should also ensure that the ecCodes library is in your LD_LIBRARY_PATH:

export LD_LIBRARY_PATH=$ECCODES_LIB_DIR:$LD_LIBRARY_PATH


Test it

To check that Metview's binary and Python parts can communicate with each other, type this

python3 -m metview selfcheck

Here's a quick Python program to check that it's working. Copy this into a file called test-metview.py

import metview as mv

# call Metview's built-in function to return a lower case string
print(mv.lowercase('Hello World!')) # should output "hello world!"

and run it like this:

python3 test-metview.py

If this works, then you have successfully set up Metview's Python interface!

Need more output?

Set the following environment variable before starting your Python interpreter, and you will see much more output from Metview:

export METVIEW_PYTHON_START_CMD=1


Further reading

For a quick start, check out some of the examples in the Gallery. They all have Python code, and each contains a tarball containing its code and data.

Look at the Jupyter notebooks in the examples folder on github for more inspiration!

To see the different environments you can write Metview Python scripts in, see Developing and Running Metview Python Scripts.

To understand what Metview's functions take as input and output in a Python environment, see Using Metview's Python Interface.

  • No labels