Skip to content

Cases and controls

limen_core.cases

Cells with a landslide against cells without one: the rows of a measure.

To know whether a feature of the ground tells the cells where a landslide happened from the others, the feature is read in both, as of the same kind of day. This module builds those rows from plain values; reading the feature and the landslides is the caller's (tools/measure_motion_asof.py).

  • :func:cell_at: the square of the grid a point falls in, on the EEA grid (EPSG:3035 metres, squares aligned on multiples of their side). The id is the one egms-client gives its cells: "1000m_E4400000_N2000000".
  • :func:matched_controls: cells with no landslide near them, each given the date of a case. Matching the dates keeps the season and the year out of the comparison: a control read in August is compared with a landslide of August.
  • :func:compare_scores: for each score, how often a case scores higher than a control (the AUC), with how many of each it rests on.

An AUC of 0.5 is a coin; the release-wide features of EGMS read 0.48 to 0.54 for Limen's landslide cells. Pure functions, no I/O.

CellBox dataclass

A square of the grid in EPSG:3035 metres, with the id egms-client gives it.

Separation dataclass

How one score tells cases from controls.

cell_at

cell_at(x: float, y: float, *, size_m: float = CELL_SIZE_M) -> CellBox

The square of side size_m that holds the point (x, y) (EPSG:3035 metres).

around

around(cell: CellBox, *, rings: int = 1) -> set[str]

The ids of cell and of the rings rings of cells around it.

matched_controls

matched_controls(cases: Sequence[tuple[CellBox, date]], candidates: Iterable[CellBox], *, excluded: Iterable[str], per_case: int, seed: int) -> list[tuple[CellBox, date]]

per_case controls for each case: a candidate cell not excluded, with the case's date.

A control cell is used at most once per date. When there are too few candidates, a case gets fewer controls: never the same pair twice. The draw depends only on seed and on the order of the inputs.

compare_scores

compare_scores(cases: Sequence[R], controls: Sequence[R], scores: Mapping[str, Callable[[R], float | None]]) -> list[Separation]

The AUC of each score, in the order of scores; a None score leaves the row out.