A Python library for pre-processing FLEXPART inputs
Project description
preFLEXPART
WARNING:
This project is in BETA and under active development. Interfaces and functionality are subject to change.
preFLEXPART 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
# poetry
poetry add preflexpart
# or pip
pip install preflexpart
At a glance
-
Retrieve IFS forecasts
-
Preprocess for FLEXPART V10
- De-accumulates precipitation, radiation, and fluxes
- Converts
etadot→omega(Pa s⁻¹)
-
Write GRIB2
- Preserves/overrides GRIB metadata as needed
- Ensures all fields are written as GRIB2
Example usage
Run the full preFLEXPART preprocessing pipeline end-to-end using the example scripts in the examples/ directory.
Each script demonstrates a complete workflow: loading IFS data, preprocessing it, and writing FLEXPART-ready GRIB2 files.
| Data Source | Example Command |
|---|---|
| 🧪 Bundled test data | python -s examples/run_pipeline_local.py tests/data/test_sources_raw_ifs.tar.gz |
| 💾 Local GRIB files | python -s examples/run_pipeline_local.py /path/to/grib_dir |
| ☁️ ECMWF MARS archive | python -s examples/run_pipeline_mars.py --date 2025-09-29 --time 12 --step "1/to/2/by/1" --max-level 137 |
| 🌍 ECMWF Polytope API | python -s examples/run_pipeline_polytope.py --date 2025-07-29 --time 1200 --step "1/to/2/by/1" --max-level 137 |
Documentation
See the docs/ folder for detailed information:
Changelog
See CHANGELOG.md for version history.
Running Tests
To run the full test suite:
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 preFLEXPART Package
This guide explains how to test the preFLEXPART 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
You can either install it from PyPI (recommended for testers) or from source (for contributors).
Option A — From PyPI
pip install preflexpart==0.1.3-rc1
💡 After installation, you can run the example scripts using plain
python— no need for Poetry when installed viapip.
Option B — From source (development setup)
git clone https://gitlab.phaidra.org/flexpart/preflexpart.git
cd preflexpart
poetry install
2️. Run an example pipeline
Each example runs the preFLEXPART 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) |
🧠 If you installed with Poetry instead of pip, prefix each command with:
poetry run python ...
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).
Try it out
- You can run preflexpart with the included dataset:
python examples/run_pipeline_local.py tests/data/test_sources_raw_ifs.tar.gz
- MARS and Polytope examples require ECMWF access tokens or credentials.
- All examples write FLEXPART-ready GRIB2 files suitable for dispersion simulations.
Found a bug or have feedback? Please open an issue or contact nina.burgdorfer@meteoswiss.ch
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file preflexpart-0.1.3rc3.tar.gz.
File metadata
- Download URL: preflexpart-0.1.3rc3.tar.gz
- Upload date:
- Size: 28.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.1 CPython/3.11.7 Linux/6.8.0-84-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
144fdc506bffea3616e770235104c84284e44de260b1dddf04ddcdf62d621637
|
|
| MD5 |
bb7b080f700754f3f9bc25a66179944e
|
|
| BLAKE2b-256 |
3bb27eb6dc98654b820d66e725a109db64decbc7df131ba31ec7335807a9cb30
|
File details
Details for the file preflexpart-0.1.3rc3-py3-none-any.whl.
File metadata
- Download URL: preflexpart-0.1.3rc3-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.1 CPython/3.11.7 Linux/6.8.0-84-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90de7bedbdff5754c23fc7db1ba47c337ba6a2904d426f3ada8cb750a693ca26
|
|
| MD5 |
2701b70267eede9dc235151d2252fae6
|
|
| BLAKE2b-256 |
d249687bd4f7ce8dc17396df720d21e1e8d4533ec6316af625bc6f51c70722bd
|