Skip to main content

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.

Download files

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

Source Distribution

climate_lama_engine-0.5.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

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

climate_lama_engine-0.5.0-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file climate_lama_engine-0.5.0.tar.gz.

File metadata

  • Download URL: climate_lama_engine-0.5.0.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for climate_lama_engine-0.5.0.tar.gz
Algorithm Hash digest
SHA256 400800a222026dd15558981b98549226e2a0231efbd734b2cf296bc30d4d72ed
MD5 24ddf26cf865877e12ddd7f06905ae6b
BLAKE2b-256 d9755dabf69ac0a966192bc4a3faade7e39871116c22f438c28df55df14ef7bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for climate_lama_engine-0.5.0.tar.gz:

Publisher: release.yml on CortoMaltese3/climate-lama-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file climate_lama_engine-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for climate_lama_engine-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e5fd73d5cd1ec42e42023bcde1f2821cbeb8c5f2ec1163dda6faca5d8ebb33e
MD5 f58a8c7d8e3e214c8d730852d1f34fc1
BLAKE2b-256 e4038cede6e25cf751b3955e65b1fdecb7c7175d2334bbfa53c533f7929c581a

See more details on using hashes here.

Provenance

The following attestation bundles were made for climate_lama_engine-0.5.0-py3-none-any.whl:

Publisher: release.yml on CortoMaltese3/climate-lama-engine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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