Skip to main content

Tool for aggregating raw NWP files into .zarr files

Project description

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.

[!Note] This is not built to replace tools such as Herbie. It is built to produce data specific to the needs of Open Climate Fix's models, so things like the output format and the variable selection are hard-coded. If you need a more configurable cli-driven tool, consider using herbie instead.

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:

[!Note] This will download several gigabytes of data to your home partition. Make sure you have plenty of free space (and time!)

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

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

[!Note] The PDOC_ALLOW_EXEC=1 environment variable is required due to a facet of the ocf_blosc2 library, which imports itself automatically and hence necessitates execution to be enabled.

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 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 MyPy for static type checking and Ruff for linting. Installing the development dependencies makes them available in your virtual environment.

Use them via:

$ python -m mypy .
$ python -m ruff check .

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:

$ python -m unittest discover -s src/nwp_consumer -p "test_*.py"

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!

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

nwp_consumer-1.1.34.tar.gz (71.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nwp_consumer-1.1.34-py3-none-any.whl (92.1 kB view details)

Uploaded Python 3

File details

Details for the file nwp_consumer-1.1.34.tar.gz.

File metadata

  • Download URL: nwp_consumer-1.1.34.tar.gz
  • Upload date:
  • Size: 71.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for nwp_consumer-1.1.34.tar.gz
Algorithm Hash digest
SHA256 83cbb021742895c83b6c3b9f9f1bd464862ba5f5936a80348b09ffb0da3ba390
MD5 b914d30b77083876692e68dbab99805f
BLAKE2b-256 cbe14fd587c8d246a73473751ff8518d680ce857b941934a9b9d9cfff29cb5bd

See more details on using hashes here.

File details

Details for the file nwp_consumer-1.1.34-py3-none-any.whl.

File metadata

  • Download URL: nwp_consumer-1.1.34-py3-none-any.whl
  • Upload date:
  • Size: 92.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for nwp_consumer-1.1.34-py3-none-any.whl
Algorithm Hash digest
SHA256 0ba2097183ee16d59893a045b5e7f53c5c9fa6a785d80b09d874c096e3ea6307
MD5 6d2890dc226bc5805e236a959983434f
BLAKE2b-256 8ab7b85cda2ef2bbbd7436f615f1c85fec54344e16118e2150fd3b09de65a832

See more details on using hashes here.

Supported by

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