Skip to main content

NWP Consumer

All Contributors

Download and convert weather data for use in ML pipelines

tags badge pypi badge documentation badge contributors badge workflows badge ease of contribution: easy

Some renewables, such as solar and wind, generate power according to the weather conditions. Any forecasting therefore requires predictions of how these conditions will change. Many meteorological organisations provide Numerical Weather Prediction (NWP) data, which can then used for model training and inference.

This data is often very large and can come in various formats. Furthermore, these formats are not necessarily suitable for training, so may require preprocessing and conversion.

This package aims to streamline the collection and processing of this NWP data.

Installation

Install from PyPi using pip:

$ pip install nwp-consumer

Or use the container image:

$ docker pull ghcr.io/openclimatefix/nwp-consumer

Example usage

To download the latest available day of GFS data:*

$ nwp-consumer consume

To create an archive of a month of GFS data:

$ nwp-consumer archive --year 2024 --month 1

Documentation

Documentation is generated via pdoc. To build the documentation, run the following command in the repository root:

$ python -m pdoc -o docs --docformat=google src/nwp_consumer

FAQ

How do I authenticate with model repositories that require accounts?

Authentication, and model repository selection, is handled via environment variables. Choose a repository via the MODEL_REPOSITORY environment variable. Required environment variables can be found in the repository's metadata function. Missing variables will be warned about at runtime.

How do I use an S3 bucket for created stores?

The ZARRDIR environment variable can be set to an S3 url (ex: s3://some-bucket-name/some-prefix). Valid credentials for accessing the bucket must be discoverable in the environment as per Botocore's documentation

How do I write to Icechunk instead of Zarr?

Set the STORE_BACKEND environment variable to icechunk. Data is then written to one Icechunk store per month in ZARRDIR (ex: 2026-02.icechunk), which holds every init time of the model in that month. Each run adds its init times to the store, committing each one only once it has been written and validated in full, so readers never see an incomplete init time. Runs for different init times can safely write to the same store concurrently.

The store's boolean init_time_complete coordinate records which init times were written in full. Init times committed with a small number of failed writes (within the consumer's error tolerance) are left unmarked, and are retried by later runs that request them. Readers can use the coordinate to select only complete init times.

Failed and conflicting runs leave behind data that is never committed. Remove it by periodically running the maintain command for each month's store:

$ nwp-consumer maintain --year 2026 --month 2

This only deletes uncommitted data more than a day old, so it is safe to run alongside consuming runs. Add --expire-snapshots-older-than-days N to also discard the store's history older than N days, along with any data that only that history references.

How do I change what variables are pulled?

With difficulty! This package pulls data specifically tailored to Open Climate Fix's needs, and as such, the data it pulls (and the schema that data is surfaced with) is a fixed part of the package. A large part of the value proposition of this consumer is that the data it produces is consistent and comparable between different sources, so pull requests to the effect of adding or changing this for a specific model are unlikely to be approved.

However, desired changes can be made via cloning the repo and making the relevant parameter modifications to the model's expected coordinates in it's metadata for the desired model repository.

Development

Linting and static type checking

This project uses ty for static type checking and Ruff for linting. Installing the development dependencies makes them available in your virtual environment.

Use them via the provided Makefile targets:

$ make typecheck
$ make lint

Be sure to do this periodically while developing to catch any errors early and prevent headaches with the CI pipeline. It may seem like a hassle at first, but it prevents accidental creation of a whole suite of bugs.

Running the test suite

Run the unittests with:

$ make test

Further reading

On packaging a python project using setuptools and pyproject.toml:

On hexagonal architecture:

On the directory structure:


Contributing and community

issues badge

devsjc
devsjc

📆
Peter Dudfield
Peter Dudfield

💻
Jacob Prince-Bieker
Jacob Prince-Bieker

💻
Aditya Sawant
Aditya Sawant

💻
Mark van der Broek
Mark van der Broek

📖

Part of the Open Climate Fix community.

OCF Logo

Contributors ✨

Thanks goes to these wonderful people (emoji key):

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

Metadata

Release files for nwp-consumer 1.1.41

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

Source distribution (sdist)

Source distribution for nwp-consumer 1.1.41
File Size Uploaded Provenance Actions
nwp_consumer-1.1.41.tar.gz 86.4 kB Without provenance Details for nwp_consumer-1.1.41.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nwp-consumer 1.1.41
File Interpreter ABI Platform Actions
nwp_consumer-1.1.41-py3-none-any.whl Python 3 none any Details for nwp_consumer-1.1.41-py3-none-any.whl

Total release size: 194.0 kB

Release files / nwp_consumer-1.1.41.tar.gz

Download URL nwp_consumer-1.1.41.tar.gz
Size 86.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a98736bb18953bef3e45f3616cf7ea2d001eaf354136629bcb3713255367bc0e
BLAKE2b-256 checksum
How to use checksums
22c8eabe903e9194d62386d77662909b819624bb31252098292dbcf1e510f4d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nwp_consumer-1.1.41-py3-none-any.whl

Download URL nwp_consumer-1.1.41-py3-none-any.whl
Size 107.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6feb212d8f2d7bf3147b77914f145b5cd7fa0425a2e280bfe4504a3966e04771
BLAKE2b-256 checksum
How to use checksums
7365e16a49143f6871e50b4be8924be527a2c3ba1e1b062c2fd15e0e7bc2841f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for nwp-consumer 1.1.41

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.41 This release

2 release files No provenance

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