Skip to main content

A faithful, dependency-light Python port of the INSYDE synthetic flood depth-damage model (Dottori et al. 2016).

Project description

pyinsyde — a Python port of the INSYDE flood-damage model

CI License: GPL-3.0 Python

pyinsyde is a faithful, dependency-light Python port of INSYDE, the synthetic (component-based) flood depth-damage model for residential buildings of Dottori et al. (2016, NHESS 16, 2577–2591). It reproduces the original R model (ComputeDamage) component by component — in both deterministic and Monte-Carlo modes — and ships the model's original reference (EUR) cost data.

The only runtime dependencies are numpy and scipy.

Port of the reference R implementation by Dottori, Figueiredo, Martina, Molinari and Scorzini (GPL-3.0). See PORTING.md for fidelity notes and the known R quirks that are reproduced on purpose.


What INSYDE does

INSYDE estimates flood damage to a residential building by summing physical damage to individual components (structure, finishes, windows/doors, systems, clean-up/dehumidification, …) as a function of the flood hazard (water depth, velocity, duration, sediment load, water quality) and the building's exposure (geometry, materials, finishing level). Damage is returned in absolute terms and as a relative damage ratio (0→1) against the building's replacement value, and can be produced as an expected value or as a Monte-Carlo distribution.


Install

pip install -e .            # or: uv pip install -e .

For development (tests + linter):

uv venv --python 3.12
uv pip install -e ".[dev]"
uv run pytest -q

Quick start

import numpy as np
from pyinsyde import (ExposureVariables, HazardVariables,
                      compute_damage, load_unit_prices, replacement_value_eur)

exp = ExposureVariables()                 # INSYDE reference building
up = load_unit_prices()                   # original EUR unit prices
rv = replacement_value_eur(exp.BS, exp.BT)

hz = HazardVariables(he=np.arange(0.0, 3.0 + 1e-9, 0.5))   # depth vector
res = compute_damage(exp, hz, up, rv, uncert=0)            # deterministic
print(res.rel_damage)     # relative damage ratio at each depth

A complete runnable script — the Python equivalent of the R example — is in examples/run_insyde.py:

uv run python examples/run_insyde.py

Regional localization (bring your own prices)

INSYDE's damage logic is region-agnostic; only the cost inputs are local. The model ships with its original Italian (EUR) reference data, but you can run it for any country without modifying the package:

from pyinsyde import compute_damage, load_unit_prices, ExposureVariables, HazardVariables

up = load_unit_prices(path="prices/my_region.txt")   # your unit-price table
rv = 2000.0                                           # your replacement value (per m²)
res = compute_damage(ExposureVariables(), HazardVariables(), up, rv, uncert=0)

Your price table uses the same name value #unit format as pyinsyde/data/unit_prices.txt. Supply your region's replacement value directly to compute_damage.

Only commit openly-licensed data. Keep commercial cost tables out of the repository and load them at runtime via path=. Contributions of open regional datasets are very welcome — see the roadmap (multi-region support).


Repository layout

pyinsyde/
  variables.py   ExposureVariables / HazardVariables  (mirror INSYDE inputs)
  model.py       compute_damage — faithful port of insyde_function.R
  prices.py      unit-price + replacement-value loaders (original EUR data)
  data/          unit_prices.txt, replacement_values.txt  (INSYDE EUR reference)
examples/
  run_insyde.py  the R INSYDE example, in Python (deterministic + Monte-Carlo)
tests/           model validation tests
r_reference/     the original INSYDE R sources, for line-by-line comparison
PORTING.md       fidelity notes and reproduced R quirks
DATA.md          provenance of the bundled reference data

License / attribution

Ported from INSYDE (Dottori, Figueiredo, Martina, Molinari, Scorzini), released under the GNU GPL-3.0. This port is likewise GPL-3.0 — see LICENSE. The bundled unit_prices.txt / replacement_values.txt are the model's original reference data; see DATA.md.

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

pyinsyde-0.1.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

pyinsyde-0.1.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyinsyde-0.1.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pyinsyde-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd88ecc0c66e9f146659b62a42d40f4329baf84367800b8c6d6a42d7ba129fe8
MD5 f088752fd41e284dd67a1289dc83eefb
BLAKE2b-256 30d29db1e392f36d426bb2c64cc52aaf40ef1de5a00869816246b24bb50d32a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyinsyde-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for pyinsyde-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 056b8d7d88492fc3afee21dfbfc40e4ba209c1259a9add31f57b4f52099b82c9
MD5 e829fd0b6f5b7661829246d376308ccb
BLAKE2b-256 98984928ecf7afadeeb7938b26228d80e42d4331c2438e66de7a6fcfc162ca0e

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