Skip to content

After an earthquake

limen_core.seismic

After an earthquake: how long a slope stays shaken, and how much less rain it takes.

A ShakeMap gives the peak ground acceleration (PGA, in g) of one earthquake at one place, and that number does not change with time. What changes is the slope: for days it is more ready to fail, for months it fails with less rain. That is a model of the slope, not a reading of the earthquake, so it lives here and not in the library that reads the ShakeMaps (ingv-shakemap gives the PGA of an event at a point, and stops there).

Two memories, on purpose:

  • :func:decayed_pga and :func:seismic_factor: the shaking that still counts today, fading in days (tau_days), turned into a factor from 0 to 1;
  • :func:rain_threshold_reduction: how much the rain threshold of the place is lowered, fading in months (memory_days). It uses the shaking of each event as it was, not the one already faded in days: the slope stays weak long after the ground has stopped moving.

Every constant is a parameter and none has a default: they are calibration, and calibration belongs to whoever measured it. Pure functions, no I/O.

Shaking dataclass

One earthquake as one place felt it.

SeismicParams dataclass

The calibration of the seismic factor.

ThresholdMemory dataclass

How an earthquake lowers the rain threshold, and for how long.

decayed_pga

decayed_pga(events: Iterable[Shaking], *, as_of: datetime, params: SeismicParams) -> float

The shaking that still counts at as_of, in g: 0 with no earthquake that counts.

Each earthquake of at least min_magnitude, not in the future and not older than lookback_days, counts for pga_g * exp(-days / tau_days). The answer is the largest of them, not their sum: two earthquakes do not shake a place twice as hard as the stronger one did.

seismic_factor

seismic_factor(pga_g: float, *, params: SeismicParams) -> float

A PGA in g as a factor from 0 to 1.

0 below pga_min_g, then a sigmoid centred on pga_threshold_g and pga_scale_g wide, rescaled so that it starts from 0 at pga_min_g. The bare sigmoid is already 0.27 for a PGA close to nothing: every place an earthquake brushed would take a step up.

seismic

seismic(events: Iterable[Shaking], *, as_of: datetime, params: SeismicParams) -> tuple[float, float]

(decayed PGA in g, seismic factor) at as_of.

rain_threshold_reduction

rain_threshold_reduction(events: Iterable[Shaking], *, as_of: datetime, params: SeismicParams, memory: ThresholdMemory | None) -> float

The share by which the rain threshold of the place is lowered: 0 to max_reduction.

For each earthquake that counts, :func:seismic_factor of its PGA as it was, times exp(-days / memory_days); the largest, times max_reduction. Multiply the threshold by one minus this (with rainfall-thresholds: threshold.scaled(1 - reduction)). 0 with no memory: the rain does not feel the earthquakes.