Metadata-Version: 2.5
Name: quakecascade
Version: 0.1.0
Summary: Earthquake scenario cascades for cities: ground motion, damage, debris road closure, post-event accessibility and relief allocation.
Project-URL: Homepage, https://gitlab.com/yusufeminoglu/quakecascade
Project-URL: Source, https://gitlab.com/yusufeminoglu/quakecascade
Project-URL: Issues, https://gitlab.com/yusufeminoglu/quakecascade/-/issues
Author-email: Yusuf Eminoğlu <geospacephilo@gmail.com>
License-Expression: BSD-3-Clause
License-File: LICENSE
License-File: NOTICE
Keywords: accessibility,debris,earthquake,emergency planning,ground motion,hazus,p-median,scenario
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: Topic :: Scientific/Engineering :: Physics
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.0
Requires-Dist: pyproj>=3.5
Requires-Dist: scipy>=1.10
Requires-Dist: shapely>=2.0
Provides-Extra: demo
Requires-Dist: geopandas>=0.14; extra == 'demo'
Requires-Dist: matplotlib>=3.7; extra == 'demo'
Requires-Dist: osmnx>=2.0; extra == 'demo'
Requires-Dist: pyogrio>=0.7; extra == 'demo'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocstrings[python]>=0.25; extra == 'docs'
Provides-Extra: geo
Requires-Dist: geopandas>=0.14; extra == 'geo'
Requires-Dist: pyarrow>=14; extra == 'geo'
Requires-Dist: pyogrio>=0.7; extra == 'geo'
Provides-Extra: raster
Requires-Dist: rasterio>=1.3; extra == 'raster'
Provides-Extra: test
Requires-Dist: geopandas>=0.14; extra == 'test'
Requires-Dist: pytest-cov>=4.1; extra == 'test'
Requires-Dist: pytest>=7.4; extra == 'test'
Description-Content-Type: text/markdown

# quakecascade

Earthquake scenario cascades for cities: ground motion, building damage, casualties and shelter
need, liquefaction, debris-induced road closure, accessibility to emergency services, relief-depot
allocation, unit ranking and lifeline repair demand, computed on open or municipal inventories.

```text
fault + magnitude ─► ground motion (ASB2014) ─► damage at bracketing design levels (Hazus 6.1)
   ─► casualties, displaced households, shelter ─► liquefaction screen (Zhu 2015 / Hazus)
   ─► Monte Carlo bands with shared ground-motion residuals
   ─► debris reach, pressure, corridor blockage, navigable core ─► closed roads
   ─► travel times before/after ─► isolation status, 2SFCA access
   ─► p-median depots, capacity balance ─► TOPSIS unit ranking ─► pipeline repairs
```

`quakecascade` re-implements, as open source, the methods of DİRİ, the earthquake
decision-support platform built for the İzmir Earthquake Master Plan. It contains none of DİRİ's
code and no data of İzmir Metropolitan Municipality (İBB) or any other city: everything runs on
inputs you supply, on open data, or on the built-in synthetic town.

## Why another earthquake package

Loss engines stop at buildings and lifelines, while accessibility and location-allocation tools
assume the street network is intact. `quakecascade` connects the two in one library, under rules
that keep the chain honest:

- **Missing is never zero.** Each value comes with a status code (`computed`, `partial`,
  `no_vs30`, `outside_envelope`, …), and an unknown street is never reported as a safe one.
- **No silent defaults.** Every coefficient cites its source. A planning choice without a
  published value, such as the debris spread factor or the closure threshold, is a required
  argument.
- **Counts sum, intensities do not.** Aggregation follows the nature of each column.
- **Reproducible.** A cascade run returns a manifest with its parameters, input digests and a
  fingerprint.

## Install

```bash
git clone https://gitlab.com/yusufeminoglu/quakecascade.git
cd quakecascade
python -m pip install -e .            # core: numpy, scipy, pandas, shapely, pyproj
python -m pip install -e ".[demo]"    # + geopandas, osmnx, matplotlib for the examples
```

Python 3.10 or newer is required. The package is not on PyPI yet.

## Quick start

```python
import numpy as np
from quakecascade import fragility, groundmotion as gm

trace = np.array([[0.0, 0.0], [30_000.0, 0.0]])           # metres, projected CRS
rupture = gm.FaultGeometry.from_wells_coppersmith(
    dip_deg=60.0, dip_azimuth_deg=0.0, magnitude=6.8, mechanism="NS",
    source="hypothetical example fault, dip 60 deg to the north")
sites = np.array([[15_000.0, 5_000.0], [15_000.0, 12_000.0], [15_000.0, 40_000.0]])
vs30 = np.array([300.0, np.nan, 760.0])                    # the second site has no Vs30

motion = gm.scenario(sites, vs30, trace, magnitude=6.8, mechanism="NS", geometry=rupture)
dmg = fragility.damage(motion["pga_g_p50"].to_numpy(), ["C1M", "C1M", "URML"],
                       floors=[5, 5, 2], design_levels=["pre", "moderate"])
print(dmg[["building_id", "design_level", "p_complete", "dmg_status"]])
```

```text
   building_id design_level  p_complete          dmg_status
0            0          pre       0.519            computed
1            1          pre         NaN              no_pga
2            2          pre       0.006            computed
3            0     moderate       0.138            computed
4            1     moderate         NaN              no_pga
5            2     moderate         NaN  no_fragility_curve
```

The whole chain on the synthetic town, and on open data for a small area (network required):

```bash
python examples/01_synthetic_town.py
python examples/02_open_data.py        # needs the demo and raster extras
```

## Modules

| Module | Computes |
|---|---|
| `groundmotion` | Joyner–Boore distance to a dipping rupture plane; PGA, PGV and SA percentiles from Akkar, Sandıkkaya & Bommer (2014) |
| `fragility` | Hazus 6.1 damage-state probabilities at several design levels |
| `impact` | casualties by severity and time of day, displaced households, public shelter need (Hazus 6.1) |
| `montecarlo` | city-total damage bands under independent, between-event and fully correlated sampling |
| `liquefaction`, `hydro` | Zhu et al. (2015) geospatial liquefaction, Hazus susceptibility, CTI from a DEM |
| `debris` | debris reach, road pressure, blocked corridor share, navigable core, closed roads |
| `network` | routable road network with SciPy or pure-NumPy shortest paths |
| `access` | isolation status, nearest-facility time, 2SFCA and Hansen accessibility |
| `allocate` | p-median depot location and capacity-balanced allocation |
| `mcda` | TOPSIS ranking |
| `lifelines` | buried pipeline repair rates and counts |
| `cascade` | the whole chain as one run, with a stage log and manifest |
| `datasets` | synthetic demonstration town; OSM, Copernicus DEM and GEM fault fetchers |
| `contract`, `crs` | status codes, column specifications, aggregation rules, metric-CRS checks |

Each module has a method page under `docs/methods/` with its equations, parameter tables,
sources and caveats. Build the documentation site with
`pip install -e ".[docs]" && mkdocs serve`.

## Scope and limits

Fragility, casualty and shelter tables are Hazus calibrations of US practice. Ground motion uses
one model, derived from European and Middle Eastern records. Debris parameters are not calibrated
against observations, so bracket them. The package is a scenario tool for planning and teaching.
It does not produce probabilistic seismic hazard and is not a substitute for a site-specific
engineering assessment.

## Development

```bash
python -m pip install -e ".[test]"
python -m pytest -q                               # 600+ tests, no network
QUAKECASCADE_FORCE_NUMPY=1 python -m pytest -q    # pure-NumPy paths
ruff check src tests
```

See `CONTRIBUTING.md` and `CODE_OF_CONDUCT.md`.

## Licence and citation

BSD-3-Clause (see `LICENSE`). Third-party material, such as the ASB2014 coefficient table from
pyGMM (MIT), is listed in `NOTICE`. To cite the software, see `CITATION.cff`.
