Storms as objects¶
A frame is a field of pixels. storms turns it into a list of storms, each
with a centre, an area and a peak; track follows them from frame to frame
and says how long each one lived, where it went and how fast.
from datetime import timedelta
from dpc_radar import storms, track # pip install "dpc-radar[storms]"
srt1 = await radar.latest("SRT1")
for storm in storms(srt1, threshold=20): # patches of 20 mm in the hour or more
print(storm.area_km2, storm.lon, storm.lat, storm.peak)
# 58.0 13.32 44.98 31.7 (10 October 2026, 06:00 UTC)
for t in track(hourly_frames, threshold=20, max_gap=timedelta(hours=1)):
print(t.start, t.end, t.peak, t.area_km2, t.distance_km, t.speed_kmh, t.heading)
# 02:00 06:00 36.0 541.0 30.7 7.7 92.0 the storm over Melito di Porto Salvo
With SRI frames every five minutes the default max_gap of 20 minutes is the
right one; with hourly frames say max_gap=timedelta(hours=1), and read the
track as "rain stayed here", not as the motion of one cell.
dpc_radar.storms ¶
Storms as objects: where each one is, how large, how strong, and where it goes.
A frame is a field of pixels; a storm is the patch of touching pixels at or
over a threshold. :func:storms finds the patches of one frame and describes
each one (:class:Storm): centre, area, peak, mean. :func:track follows
them from frame to frame (:class:Track): how long each storm lived, the path
of its centre, its speed, the water it dropped.
Two patches of consecutive frames are the same storm when they overlap: with a
frame every five minutes a storm of a few km moves less than its own width.
When a storm splits, the piece that overlaps it most keeps its track and the
others start a new one; when two merge, the track of the one that overlaps
most goes on and the other ends. A gap between frames longer than max_gap
ends every track: after half an hour a patch in the same place is another storm.
The threshold is the caller's: 10 mm/h on an SRI frame draws the convective
cores, 1 mm/h the whole rain area. Patches smaller than min_area_km2 are
dropped: a few pixels over the threshold are more often clutter than rain.
It needs SciPy for the labelling (extra storms,
pip install "dpc-radar[storms]"). Radar only sees what the radar sees:
where it is blind (:func:dpc_radar.reliability) there are no storms to find.
Storm
dataclass
¶
One patch of touching pixels at or over threshold in one frame.
peak and mean are in the unit of the frame (mm/h for SRI, mm for an
accumulation). lon/lat is the centre of the rain (each pixel
weighted by its rain), not of the shape.
Track
dataclass
¶
One storm followed through the frames: its :class:Storm at every frame it was seen.
duration
property
¶
duration: timedelta
From the first frame to the last: a storm seen in one frame lasted zero.
distance_km
property
¶
distance_km: float
From where it was first seen to where it was last seen, in a straight line.
speed_kmh
property
¶
speed_kmh: float | None
Its mean speed along that line; None for a storm seen in one frame.
heading
property
¶
heading: float | None
Where it goes, in degrees clockwise from north; None if it did not move.
water_m3
property
¶
water_m3: float | None
The water it dropped over the threshold area, in m³ (intensity frames only).
The mean intensity times the area, held from each frame to the next.
None for accumulations: their windows overlap and cannot be summed.
storms ¶
storms(grid: RainGrid, *, threshold: float, min_area_km2: float = MIN_AREA_KM2) -> list[Storm]
The storms of one frame, the strongest first.
track ¶
track(grids: Iterable[RainGrid], *, threshold: float, min_area_km2: float = MIN_AREA_KM2, max_gap: timedelta = MAX_GAP) -> list[Track]
The storms of a run of frames of one product, in order of time, followed through it.
The tracks come in the order they began. Frames on different grids cannot be followed and are refused.