Skip to main content

Python wrapper for the UK Met Office Weather DataHub API

Project description

MetOfficeDataHub

All Contributors

Python wrapper around MetOffice Atmospheric Model Data REST API

codecov Lint Python

MetOfficeDataHub is a simple wrapper for the API provided by the British Met Office known as Weather DataHub. It can be used to retrieve weather observations and forecasts. The aim is to focus on the AMD - Atmosphere Model Data REST API https://metoffice.apiconnect.ibmcloud.com/metoffice/production/product/17502/api/16908

This wrapper currently only downloads the latest results. No historic data can be fetched. The timestamp can be seen in the grib/xarray files.

⚠️ This (unofficial) library has been built and is maintained by Open Climate Fix, not the UK MetOffice.

Access

You need to register with the Weather DataHub and obtain an API key and secret. These should be placed in environment variables as API_KEY and API_SECRET.

Python

Installation

Install directly from pypi using pip install metoffice-weather-datahub

Example

from metofficedatahub.multiple_files import MetOfficeDataHub

# 1. Get data from API, download grib files
datahub = MetOfficeDataHub(client_id="fake", client_secret="fake")
datahub.download_all_files(order_ids=["test_order_id"])

# 2. load grib files to one Xarray Dataset
data = datahub.load_all_files()

CLI

You can run the script directly as a CLI using:

python3 metofficedatahub/app.py --save-dir="s3://bucket/folder"

which will download all the files from Weather DataHub, join them together into a xarray dataset, and then save them.

You can set the environmental variable LOG_LEVEL to define what log level you would like.

Docker

The application can be run using docker

You can pull the production docker image from docker hub using

docker pull openclimatefix/metoffice_weather_datahub

local

You can also build your own docker image locally using

docker build -t metofficedatahub -f infrastructure/docker/Dockerfile .

and then to run the docker file use

docker run -it -e API_KEY=change -e API_SECRET=change -e SAVE_DIR='save_dir' metofficedatahub

Data variables

When the data is loaded they are given a short name. Here is are some common examples:

  • lcc : Low-level cloud cover in %.
  • mcc : Medium-level cloud cover in %.
  • hcc : High-level cloud cover in %.
  • sde : Snow depth in meters.
  • dlwrf : Downward longwave radiation flux - ground
  • t : Air temperature at 1 meter above surface in Kelvin.
  • r : Relative humidty in %.
  • vis : Visibility in meters.
  • si10 : Wind speed in meters per second, 10 meters above surface.
  • prate : Precipitation rate at the surface in kg/m^2/s.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Peter Dudfield

💻

Flo

💻

Jack Kelly

👀

Jacob Bieker

👀

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metoffice-weather-datahub-1.0.7.tar.gz (10.3 kB view hashes)

Uploaded Source

Built Distribution

metoffice_weather_datahub-1.0.7-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page