Skip to main content

Stochastic rainfall disaggregation using the Bartlett-Lewis process

Project description

lildrip

Stochastic rainfall disaggregation with the Bartlett-Lewis process

PyPI Python License


lildrip takes coarse-resolution rainfall data (e.g. hourly) and generates finer-resolution series (e.g. 10-minute intervals) using the Bartlett-Lewis stochastic process — a well-established model in hydrology.

Quick start

pip install lildrip
from lildrip import BartlettLewisModel

model = BartlettLewisModel()
events = model.identify_events(fine_series, inter_event_gap_minutes=30)
params = model.calibrate(events)

disagg = model.disaggregate(coarse_series, fine_interval_minutes=10)

Web API

pip install "lildrip[api]"
uvicorn api.main:app --host 0.0.0.0 --port 8000

Then POST /calibrar with a high-resolution CSV or POST /desagregar with coarse data + pre-calibrated parameters. Both endpoints accept configurable column names (time_column, rainfall_column).

See the full API docs below.

Demo

Run the examples from the repository root:

# No data?  Generate sample CSV files first:
python examples/generate_demo_rain.py

# Full pipeline (calibrate → disaggregate → plot):
python examples/bartlett_lewis_demo.py

Model parameters

The Bartlett-Lewis model describes rainfall through five parameters calibrated via the Method of Moments.

Parameter Description
λ (lambda) Storm frequency (events/day)
β (beta) Pulses per storm
γ (gamma) Storm termination rate
η (eta) Pulse termination rate
μ (mu) Pulse intensity (mm)

Project structure

lildrip/
├── src/lildrip/
│   ├── __init__.py
│   ├── bartlett_lewis_model.py   # Core model
│   └── plotting.py               # Visualisation helpers
├── api/
│   ├── app.py                    # FastAPI application
│   └── main.py                   # Uvicorn entry point
├── examples/
│   ├── generate_demo_rain.py     # Generate synthetic data
│   └── bartlett_lewis_demo.py    # Calibrate + disaggregate demo
├── tests/
│   └── test_model.py
├── Dockerfile
├── pyproject.toml
└── README.md

License

MIT

Project details


Download files

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

Source Distribution

lildrip-0.1.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

lildrip-0.1.0-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file lildrip-0.1.0.tar.gz.

File metadata

  • Download URL: lildrip-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for lildrip-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1dc2897e15aa3f727e67da785e1d0e08e3ba4776735ac75aae85deba44084049
MD5 ff03154ec05af292079670533c885dba
BLAKE2b-256 acd290fa63c8da4a56f54715e80e4f65a8a7cf4160af79fcdeed4e8f2992d010

See more details on using hashes here.

File details

Details for the file lildrip-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lildrip-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.10

File hashes

Hashes for lildrip-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76cab86da8035fa544e7d8a71b8cfc379a2987158046be360e26e83561def830
MD5 639476d3747155dd875eaa1337ebc996
BLAKE2b-256 f0ae576732488722a8f865ca0a8cd24ea98336956182c5b664caf79afa4f046c

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