Skip to main content

flexprep

PyPI version Licence

WARNING:

This project is in BETA and under active development. Interfaces and functionality are subject to change.

flexprep is a Python toolkit to retrieve and preprocess ECMWF IFS fields for the Lagrangian particle dispersion model FLEXPART.

It uses ECMWF’s earthkit-data library to load meteorological GRIB data into familiar xarray/numpy arrays for computation, preserves GRIB metadata, and can write the results back to GRIB2.

Compatibility

Target model: FLEXPART V10

Install the latest release from PyPI

# pip
pip install flexprep

# or poetry
poetry add flexprep

At a glance

  1. Retrieve IFS forecasts

  2. Preprocess for FLEXPART V10

    • De-accumulates precipitation, radiation, and fluxes
    • Converts etadot → omega (Pa s⁻¹)
  3. Write GRIB2

    • Preserves/overrides GRIB metadata as needed
    • Ensures all fields are written as GRIB2

Documentation

See the docs/ folder for detailed information:

Changelog

See CHANGELOG.md for version history.

Running Tests

To run the full test suite:

git clone https://gitlab.phaidra.org/flexpart/flexprep.git
cd flexprep
poetry install --with dev
poetry run pytest

Feedback

Found a bug or have feedback? Please open an issue.

Roadmap / TODO

  • Publish a hosted documentation site (e.g., Read the Docs or GitHub Pages)
  • Add Copernicus Data Store (CDS) as a data source
  • Find suitable package name (flexprep?)

Testing the flexprep Package

This guide explains how to test the flexprep pipeline using example scripts included in the repository. Each example demonstrates a full workflow: loading, preprocessing, and writing FLEXPART-ready GRIB2 files.

1️. Install the package

Option A — From PyPI

pip install flexprep==0.1.3

2️. Get the example scripts

Clone the repository to access the example workflows.

git clone https://gitlab.phaidra.org/flexpart/flexprep.git
cd flexprep

3. Run an example pipeline

Each example runs the flexprep pipeline end-to-end.

Data source Command Notes
🧪 Bundled test data python examples/run_pipeline_local.py tests/data/test_sources_raw_ifs.tar.gz Works offline using a small bundled dataset
💾 Local GRIB files python examples/run_pipeline_local.py /path/to/grib_dir Use your own GRIB directory
☁️ ECMWF MARS archive python examples/run_pipeline_mars.py --date 2025-09-29 --time 12 --step "1/to/2/by/1" --max-level 137 Requires ECMWF MARS credentials (.ecmwfapirc)

3️. Check the outputs

After running a pipeline, the processed GRIB2 files are written to ./out_grib2/.

Each file corresponds to one forecast step (e.g. dispf2025072912).

Found a bug or have feedback? Please open an issue or contact nina.burgdorfer@meteoswiss.ch

Metadata

Release files for flexprep 0.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 flexprep 0.2.3
File Size Uploaded Provenance Actions
flexprep-0.2.3.tar.gz 16.4 kB Without provenance Details for flexprep-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flexprep 0.2.3
File Interpreter ABI Platform Actions
flexprep-0.2.3-py3-none-any.whl Python 3 none any Details for flexprep-0.2.3-py3-none-any.whl

Total release size: 38.0 kB

Release files / flexprep-0.2.3.tar.gz

Download URL flexprep-0.2.3.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
39ace0c06feeb67bf70133a18dca8ae97a920c39823d437690ad4f8b2a8e63c4
BLAKE2b-256 checksum
How to use checksums
86212224ddadaa0a46bcb4970e3adecf2282194dd5a49d71320463393252e54f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.12 Linux/6.8.0-111-generic

Release files / flexprep-0.2.3-py3-none-any.whl

Download URL flexprep-0.2.3-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66346b3ce8034db8abd97fbb7af8782eaf4e52974a3fee9f33b672961e0aa873
BLAKE2b-256 checksum
How to use checksums
3b8bc1b857d320c9cc7433a4c60d832fa5e715259946067d516085cbc53d52c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.10.12 Linux/6.8.0-111-generic

Security for flexprep 0.2.3

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.

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