Skip to main content

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.

It may also be worth setting 'RAW_DIR' so that the raw files are saved to a certain folder, and not downloded again if they are already there.

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' -e ORDER_IDS='id1 id2 id3' 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!

Release files for metoffice-weather-datahub 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metoffice-weather-datahub 1.2.3
File Size Uploaded
metoffice-weather-datahub-1.2.3.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metoffice-weather-datahub 1.2.3
File Interpreter ABI Platform
metoffice_weather_datahub-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / metoffice-weather-datahub-1.2.3.tar.gz

Download URL metoffice-weather-datahub-1.2.3.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fe96755372e2455218bf76c68ded7503f446a0b3597dea418ee3d8df8df80d72
BLAKE2b-256 checksum
How to use checksums
5f73475488eb49979032dc52084d53a9734ef4b7f557b767edfd63909bfd970e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / metoffice_weather_datahub-1.2.3-py3-none-any.whl

Download URL metoffice_weather_datahub-1.2.3-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c172b8a919ac0a4dbf324ff9e6681c0b570e2691d906b4ee578b6772cc6bc3db
BLAKE2b-256 checksum
How to use checksums
5b65e62fe169f330260cb85a93c8c0196edae6944ec310e6a324cd8b280d1cd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.29

2 release files

1.1.28

2 release files

1.1.27

2 release files

1.1.26

2 release files

1.1.15

2 release files

1.1.14

2 release files

1.1.13

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.0.43

2 release files

1.0.42

2 release files

1.0.41

2 release files

1.0.40

2 release files

1.0.39

2 release files

1.0.38

2 release files

1.0.37

2 release files

1.0.36

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.31

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page