cascade¶
The whole chain as one run, repeated collapse draws and GIS export.
quakecascade.cascade
¶
One scenario earthquake through the whole chain, as a thin orchestrator.
run calls the module functions in order and keeps every intermediate
table:
ground motion (groundmotion) -> damage at bracketing
design levels (fragility) -> casualties and shelter
(impact) -> liquefaction screening
(liquefaction, when a DEM is given) -> Monte Carlo bands
(montecarlo, when requested) -> debris reach, pressure
and corridor blockage for one sampled collapse realisation
(debris) -> closed edges -> pre/post travel times
(network) -> isolation status and 2SFCA
(access) -> p-median depots and capacity balance
(allocate) -> TOPSIS ranking of planning units
(mcda) -> pipeline repairs
(lifelines).
A stage whose inputs are missing is skipped and recorded in
CascadeResult.stages with the reason; its outputs are None, never
zero-filled. Every coefficient without a cited default is a field of
CascadeParams with no default value.
Per-unit sums over buildings that were not all computed are lower bounds. The
ranking and the shelter capacity stages never read them as complete totals:
CascadeParams.partial_units decides whether such units are left out (the
default), scaled up, or used as lower bounds, and the stage log records the
choice and the number of units it touched.
BUILDING_COLUMNS
module-attribute
¶
Columns run reads from CascadeInputs.buildings.
PARTIAL_UNIT_POLICIES
module-attribute
¶
How ranking and allocation treat a per-unit sum over incompletely computed buildings.
CascadeInputs
dataclass
¶
CascadeInputs(
crs,
fault_trace,
buildings,
fault=None,
roads=None,
hospitals=None,
fire_stations=None,
sites=None,
units=None,
dem=None,
dem_transform=None,
pipes=None,
)
Everything spatial a run needs; optional members switch stages on.
All geometries are in crs, a projected metric CRS. Frames may be
GeoDataFrames or DataFrames with a geometry column of Shapely objects.
Attributes:
| Name | Type | Description |
|---|---|---|
crs |
str or CRS
|
Projected metric CRS (checked). |
fault_trace |
LineString or (M, 2) array
|
Surface trace of the scenario fault. |
buildings |
frame
|
Columns |
fault |
(FaultGeometry, optional)
|
Dip geometry with its source; |
roads |
(frame, optional)
|
|
hospitals |
(frame, optional)
|
Points with |
fire_stations |
(frame, optional)
|
Points: a second isolation target. |
sites |
(frame, optional)
|
Candidate depot/shelter sites with |
units |
(frame, optional)
|
Planning units with |
dem, dem_transform |
optional
|
Elevation grid (row 0 at the top) and |
pipes |
(DataFrame, optional)
|
|
CascadeParams
dataclass
¶
CascadeParams(
run_id,
magnitude,
mechanism,
design_levels,
chain_level,
time_of_day,
collapse_mode,
collapse_seed,
debris_k,
closed_share,
clear_width_m,
closure_rule,
road_speeds_kmh,
max_snap_m,
worse_tol_s,
fca_threshold_s,
fca_decay,
topsis_weights,
occupancy_rate=1.0,
shelter_alpha=1.0,
fca_param=None,
access_limit_s=None,
mc_runs=None,
mc_seed=None,
mc_modes=montecarlo.CORRELATION_MODES,
n_depots=None,
unreachable_penalty_s=None,
m2_per_person=None,
depot_max_cost_s=None,
pipe_ductile=None,
pipe_brittle=None,
unknown_height_reach_m=None,
default_height=None,
partial_units="exclude",
)
Scenario choices and coefficients of one run.
Fields without a default have no citable default value and must be
stated. Fields defaulting to None belong to optional stages: when the
stage runs and the field is still None, run raises
TypeError (contract.require) instead of assuming a value. The few
numeric defaults are cited where they are defined (Hazus 6.1 neutral
shelter modifier, the ASB2014 sigmas taken from the ground-motion table).
Attributes:
| Name | Type | Description |
|---|---|---|
run_id |
str
|
Name stored in the manifest. |
magnitude |
float
|
Moment magnitude. |
mechanism |
{'SS', 'NS', 'RS'}
|
Style of faulting. |
design_levels |
sequence of str
|
Hazus design levels bracketing the stock, e.g. |
chain_level |
str
|
The bracket member that drives debris, closure and everything after it. |
time_of_day |
{'2am', '2pm', '5pm'}
|
Hazus casualty scenario time. |
collapse_mode |
str
|
Correlation mode of the one sampled collapse realisation
( |
collapse_seed |
int
|
Seed of that realisation. |
debris_k |
float
|
Debris spread factor |
closed_share |
float
|
Blocked corridor share at or above which a road is closed. |
clear_width_m |
float
|
Minimum clear width for the navigable-core test (m). |
closure_rule |
{'blockage', 'navigable', 'either'}
|
Which closure test removes edges from the network. |
road_speeds_kmh |
mapping
|
Road class -> free-flow speed (km/h); unlisted classes are not routed. |
max_snap_m |
float
|
Farthest a facility or unit point may lie from a network node (m). |
worse_tol_s |
float
|
Isolation tolerance (s) below which a change counts as |
fca_threshold_s |
float
|
2SFCA catchment size (s). |
fca_decay |
str
|
2SFCA decay kind ( |
topsis_weights |
mapping or None
|
Criterion weights; |
occupancy_rate, shelter_alpha |
float
|
Hazus 6.1 Section 13 households per unit and Eq. 13-5 modifier;
defaults 1.0 are the neutral upper-bound values of
|
fca_param |
(float, optional)
|
Decay parameter where the kind needs one. |
access_limit_s |
(float, optional)
|
Times above it count as unreachable in the isolation status. |
mc_runs, mc_seed |
(int, optional)
|
Monte Carlo bands run when |
mc_modes |
sequence of str
|
Correlation modes of the bands (all three by default: the module's own set). |
n_depots |
(int, optional)
|
p for the p-median depot stage. |
unreachable_penalty_s |
(float, optional)
|
Cost of an unreachable unit-site pair in the p-median. |
m2_per_person |
(float, optional)
|
Usable area per sheltered person, for site capacity. |
depot_max_cost_s |
(float, optional)
|
Catchment limit of the capacity balance. |
pipe_ductile, pipe_brittle |
sequence of str, optional
|
Inventory material codes of ductile and brittle pipe. |
unknown_height_reach_m |
(float, optional)
|
Reach (m) assumed for buildings without a usable height in the debris
stages (see |
default_height |
({'L', 'M', 'H'}, optional)
|
Hazus height class assumed for a building of a height-split type
without a storey count; required as soon as one exists (the screening
convention of mid-rise is a choice, not a Hazus value). The buildings
it was applied to are flagged |
partial_units |
{'exclude', 'scale', 'lower_bound'}
|
What the ranking and the shelter capacity stages do with a unit whose
sum (expected complete damage, casualties, shelter need) misses some
of its buildings. |
CascadeResult
dataclass
¶
CascadeResult(
params,
manifest,
stages,
ground_motion,
damage,
buildings,
casualties=None,
shelter=None,
liquefaction=None,
bands=None,
collapsed=None,
debris_pressure=None,
blockage=None,
navigable=None,
closed_edges=None,
travel=None,
isolation=dict(),
population_by_status=dict(),
access=None,
depots=None,
capacity=None,
ranking=None,
pipes=None,
units=None,
)
Every table of one run.
buildings (one row per building at chain_level) and units
(one row per planning unit) are the summary tables; the per-stage tables
are kept as returned by the modules. Skipped stages leave None.
stages maps each stage to {"status": "run" | "skipped", ...}.
summary
¶
A few headline numbers, each with the number of buildings it leaves out.
The sums run over the buildings that have a value; <name>_n_missing
counts the others, so a sum with a non-zero count is a lower bound.
Realisations
dataclass
¶
Closure and isolation over repeated collapse draws (see realisations).
Attributes:
| Name | Type | Description |
|---|---|---|
seeds |
list of int
|
The |
runs |
DataFrame
|
One row per run: |
roads |
DataFrame
|
One row per road: |
units |
DataFrame or None
|
One row per planning unit: |
target |
str
|
The facility kind the isolation shares refer to. |
run
¶
Run the cascade.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
CascadeInputs
|
|
required |
params
|
CascadeParams
|
|
required |
Returns:
| Type | Description |
|---|---|
CascadeResult
|
All stage tables, the per-building and per-unit summaries, the stage
log and a fingerprinted manifest ( |
Raises:
| Type | Description |
|---|---|
CRSError
|
When a frame carries a CRS other than |
ValueError
|
When a road has no usable width (fill it first, e.g. with
|
realisations
¶
Repeat the collapse draw and count how often each road closes and each unit is cut off.
run draws one correlated collapse realisation, so its closed
roads and isolation categories hold for that draw only. This function
reruns the chain for every seed in seeds (collapse_seed replaced,
everything else unchanged) and reports frequencies: the share of draws in
which a road closes, and the share in which a unit falls in each isolation
category. The ground motion and the damage probabilities are the same in
every run; only the realised collapses change.
Stages that do not depend on the collapse draw (liquefaction, Monte Carlo bands, allocation, lifelines) are left out of the repeated runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
CascadeInputs
|
As for |
required |
params
|
CascadeParams
|
As for |
required |
seeds
|
sequence of int
|
One run per seed. The frequencies have a sampling error of about
|
required |
target
|
str
|
Facility kind for the isolation shares ( |
'hospital'
|
Returns:
| Type | Description |
|---|---|
Realisations
|
|
result_layers
¶
The result tables joined to their geometries, as GeoDataFrames (needs geopandas).
Returns:
| Type | Description |
|---|---|
dict of GeoDataFrame
|
|
export_geopackage
¶
Write result_layers to a GeoPackage, one layer each, and the manifest beside it.
The manifest goes to <path without suffix>.manifest.json, so the
numbers in the GeoPackage can be traced to the run that produced them.
Returns {"geopackage": path, "manifest": manifest_path, "layers": [...]}.