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 etadotomega (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

Download files

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

Source Distribution

flexprep-0.2.2.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

flexprep-0.2.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file flexprep-0.2.2.tar.gz.

File metadata

  • Download URL: flexprep-0.2.2.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.11.9 Linux/5.14.21-150500.55.97_13.0.78-cray_shasta_c

File hashes

Hashes for flexprep-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d2f2cc6efa655acc7667bbdb05e03d95cd973a6ff661ecf605956abcf19cf74e
MD5 5c81e864de22d7f23073f092a0baf5a0
BLAKE2b-256 35a6e8b23af4e9a3dd5dd0b0d23f1f25275d70a260328c75c2f14434b60abad4

See more details on using hashes here.

File details

Details for the file flexprep-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: flexprep-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.11.9 Linux/5.14.21-150500.55.97_13.0.78-cray_shasta_c

File hashes

Hashes for flexprep-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 024f9a5895286b42ab2239e1acdc2e3909be307e95f7203f81e77183f3abb3e5
MD5 54d88d7e1449935257c58b60107b1303
BLAKE2b-256 690f1644ef5293b4f3bcf7f926c8c518eb1120f58aca9c16d43c2e27977ac2e5

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.1.3

2 files

Supported by

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