Cells for a model
egms_client.cells ¶
Per-cell statistics of the L3 grids, for a model or a map: missing stays missing.
A model works on cells (1 km squares, say), not on 100 m pixels. This module takes the L3 grids of a place and gives, for every cell, what its pixels say, with three rules a model needs and easily breaks:
- Not measured is not zero. A cell with no pixel gets
Nonefor every statistic andvalid_pixels == 0. Writing 0.0 there tells a model "the ground is still" where the satellite saw nothing (a forest, radar shadow). - Signs are kept.
vertical_medianand the tailsvertical_p10(the pixels sinking most) andvertical_p90keep up and down apart. The acceleration is vertical and signed:acceleration_p10 < 0means some pixels sink faster and faster. A magnitude (sqrt(E² + U²)) mixes a slope speeding up with one slowing down.speed_p90is the one unsigned number, kept because a landslide fills few pixels of a cell. - One mask. Every statistic, the acceleration and the seasonality too,
uses the same pixels: those with a velocity (both components when
eastis given).valid_pixelscounts them;pixelscounts the grid pixels whose centre falls in the cell. Both are 100 m pixels, not radar targets.
A cell takes the pixels whose centre lies in it (minx <= x < maxx), so
cells need not align with the 100 m grid. The rule is the one of Limen's
aggregation, and a test checks that the medians, the p90 and the counts are
the same on the same input.
score is the coverage part of :mod:egms_client.reliability
(coverage / FULL_COVERAGE, at most 1), lowered by the fit of the series
when rmse is given; reliable is score >= RELIABLE_FROM.
Needs the raster extra for the grids; :func:to_frame needs tables.
Cell
dataclass
¶
A rectangle in EPSG:3035 metres, with its id.
CellStats
dataclass
¶
What the pixels of one cell say. None: not measured, never zero.
Velocities in mm/year, accelerations in mm/year², seasonality in mm.
square_cells ¶
square_cells(minx: float, miny: float, maxx: float, maxy: float, *, size_m: float = 1000.0, origin: tuple[float, float] = (0.0, 0.0)) -> list[Cell]
The squares of side size_m that touch a rectangle, on a grid from origin.
The id is the size and the lower-left corner: "1000m_E4400000_N2000000".
on_grid ¶
on_grid(frame: Any, column: str, like: Mosaic) -> Any
A column of the L3 attributes on the grid of a mosaic, pixel by pixel.
frame has easting and northing (the pixel centre, EPSG:3035)
and column (acceleration, seasonality, rmse_ts): the
attributes of the same component as like. NaN where a pixel has no row.
per_cell ¶
per_cell(cells: Iterable[Cell], up: Mosaic, east: Mosaic | None = None, *, acceleration: Any = None, seasonality: Any = None, rmse: Any = None) -> list[CellStats]
One :class:CellStats per cell. Pure: no I/O.
up (and east, on the same grid) are mosaics of the L3 velocity.
acceleration, seasonality and rmse are arrays on the same
grid (:func:on_grid of the vertical attributes); each is optional.
to_frame ¶
to_frame(stats: Iterable[CellStats]) -> Any
The statistics as a DataFrame, one row per cell; missing stays NaN, not 0.