Lean probabilistic climate risk calculation engine
Project description
climate-lama-engine
Lean probabilistic climate risk calculation engine. Clean-room reimplementation of CLIMADA's core math — no geospatial dependencies, no I/O, just numpy and scipy.
Runtime deps: numpy>=1.24, scipy>=1.11
Python: >=3.10
Install
uv sync --group dev
Or with pip:
pip install -e ".[dev]"
Run tests
uv run pytest
Use on another machine
Clone the repo and sync the environment — the lockfile guarantees identical versions:
git clone <repo-url>
cd climate-lama-core
uv sync --group notebooks
Then open VS Code, create or open any notebook, and select the .venv inside
climate-lama-core/ as the kernel. import climate_lama_engine as cc will work
from any notebook on the machine, not just the ones in this repo.
To update later:
git pull
uv sync --group notebooks
Notebooks
Documentation and manual testing notebooks live in notebooks/.
Setup
uv sync --group notebooks
uv run jupyter notebook
Or with pip:
pip install -e .
pip install -r notebooks/requirements.txt
jupyter notebook
Then open any notebook from the notebooks/ folder in your browser.
Notebook overview
| Notebook | Description |
|---|---|
| 00_quickstart.ipynb | 10-minute end-to-end walkthrough: hazard to EAD to measure |
| 01_hazard.ipynb | Hazard deep dive: marginal frequencies, sparse matrix internals |
| 02_exposures.ipynb | Exposures: centroid assignment, insurance parameters |
| 03_impact_functions.ipynb | MDR, MDD, PAA -- why they are separate, JRC flood function |
| 04_impact_calculation.ipynb | Core engine: all output attributes, identity checks, spatial risk map |
| 05_measures.ipynb | Adaptation measures: intensity reduction, retrofits, early warning |
| 06_cost_benefit.ipynb | Cost-benefit analysis: BCR, discount rates, risk metric sensitivity |
| 07_flood_greece_pattern.ipynb | Realistic JRC flood scenario on a 50x50 Greece grid |
| 08_climada_comparison.ipynb | Side-by-side verification against upstream CLIMADA |
Quick example
import numpy as np
from scipy import sparse
import climate_lama_engine as cc
rps = np.array([10, 100, 500])
intensity = sparse.csr_matrix(np.array([
[0.0, 0.5, 1.0, 0.0, 0.2],
[0.0, 1.2, 2.5, 0.5, 0.8],
[0.0, 2.0, 4.0, 1.0, 1.5],
]))
hazard = cc.Hazard.from_rp_maps(
haz_type="RF", intensity_unit="m",
return_periods=rps, intensity=intensity,
centroid_lat=np.array([37.9, 38.0, 38.1, 38.2, 38.3]),
centroid_lon=np.array([23.7, 23.8, 23.9, 24.0, 24.1]),
)
impf = cc.ImpactFunc(
id=1, haz_type="RF",
intensity=np.array([0.0, 0.5, 1.0, 2.0, 3.0, 5.0]),
mdd=np.array([0.0, 0.02, 0.07, 0.25, 0.50, 0.80]),
paa=np.array([0.0, 0.20, 0.40, 0.70, 0.90, 1.00]),
)
impfset = cc.ImpactFuncSet([impf])
exposures = cc.Exposures(
value=np.array([500_000, 1_200_000, 800_000, 300_000]),
centroid_idx=np.array([1, 2, 3, 4]),
impf_id=np.array([1, 1, 1, 1]),
value_unit="EUR",
)
result = cc.ImpactCalc(hazard, exposures, impfset).impact()
print(f"EAD: EUR {result.aai_agg:,.0f}")
levee = cc.Measure(name="Flood Levee", haz_type="RF", haz_inten_a=0.8, cost=2_000_000)
mod_haz, mod_impf = levee.apply(hazard, impfset)
result_with_levee = cc.ImpactCalc(mod_haz, exposures, mod_impf).impact()
print(f"EAD with levee: EUR {result_with_levee.aai_agg:,.0f}")
Changelog
See CHANGELOG.md for a full history of releases.
License & Legal
Apache 2.0 — see LICENSE.
climate-lama-engine is a clean-room reimplementation of well-known probabilistic
climate risk mathematics. No GPL-licensed source code was used during implementation.
See CLEAN_ROOM.md for the full implementation statement.
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
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 climate_lama_engine-0.3.0.tar.gz.
File metadata
- Download URL: climate_lama_engine-0.3.0.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96391522d41b8079f3f3cbd7c137da1e722f7906e54af1bd454303769c9b7773
|
|
| MD5 |
c2dad3f679cf6b049c39cb80f10ae65a
|
|
| BLAKE2b-256 |
c90e05a6c1bacc40110761c10de0df8e1ab2505ca8af92a11937467ea2af7539
|
Provenance
The following attestation bundles were made for climate_lama_engine-0.3.0.tar.gz:
Publisher:
release.yml on CortoMaltese3/climate-lama-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
climate_lama_engine-0.3.0.tar.gz -
Subject digest:
96391522d41b8079f3f3cbd7c137da1e722f7906e54af1bd454303769c9b7773 - Sigstore transparency entry: 1341698093
- Sigstore integration time:
-
Permalink:
CortoMaltese3/climate-lama-engine@4a36d993d3d3074e1f8279cf636a4de16721d267 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/CortoMaltese3
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a36d993d3d3074e1f8279cf636a4de16721d267 -
Trigger Event:
push
-
Statement type:
File details
Details for the file climate_lama_engine-0.3.0-py3-none-any.whl.
File metadata
- Download URL: climate_lama_engine-0.3.0-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25e9a2d26c76e913636e4bd289ea9914a0bf002640ec37e31cd41bc8b92ef257
|
|
| MD5 |
23a9f28572a56fa7a118dc78341c5ada
|
|
| BLAKE2b-256 |
2ab1aa159c6a1281862468ad3e2255148a3c735043873baa7bb7aecb8b396edc
|
Provenance
The following attestation bundles were made for climate_lama_engine-0.3.0-py3-none-any.whl:
Publisher:
release.yml on CortoMaltese3/climate-lama-engine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
climate_lama_engine-0.3.0-py3-none-any.whl -
Subject digest:
25e9a2d26c76e913636e4bd289ea9914a0bf002640ec37e31cd41bc8b92ef257 - Sigstore transparency entry: 1341698098
- Sigstore integration time:
-
Permalink:
CortoMaltese3/climate-lama-engine@4a36d993d3d3074e1f8279cf636a4de16721d267 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/CortoMaltese3
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4a36d993d3d3074e1f8279cf636a4de16721d267 -
Trigger Event:
push
-
Statement type: