# dpc-radar > A small, typed, async Python client for the open radar data of the Italian Civil Protection (DPC): rain over Italy every five minutes, as intensity (SRI), hourly radar rain (SRT1) and rain corrected with the rain gauges (the «Merging»: CUM3 to CUM24). It downloads frames as grids, reads the rain at a place or over a box, checks a frame before trusting it, and adds a reliability map, a rain climatology, storms as objects, a two-hour nowcast, the official criticality bulletin, an MCP server and event reports. Source: https://agentengineering.it/dpc-radar/ **dpc-radar** is a small, typed Python library for the open radar data of the Italian **Civil Protection Department** (*Dipartimento della Protezione Civile*, DPC). A national network of weather radars, together with thousands of rain gauges, measures rain over all of Italy, and the DPC publishes a new map **every 5 minutes**, free for anyone. This library lets you use those maps from a script: which frame is the latest, how to download it, and how to read the API's answers, including its surprises. ```python async with RadarClient() as radar: rain = await radar.latest("CUM24") # the last 24 hours of rain, all of Italy print(rain.sample([(15.78, 37.92)])) # mm at Melito di Porto Salvo (192 on 10 October 2026) ``` On top of the frames it answers the questions that come next: can this frame be trusted, does the radar see this place, how rare is this rain here, where are the storms going, what will fall in the next two hours, what does the official bulletin say. As Python, as a command line, and as tools for an assistant. **Try it now, nothing to install:** open the [first notebook in Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/01_first_rain_map.ipynb) and draw today's rain map of Italy in five minutes. **Or run all of it on your machine:** `docker compose up` gives you the library and a [live map of the rain](#run-it-on-your-machine) on http://localhost:3000. --- ## Contents - [The radar of Italy, in 30 seconds](#the-radar-of-italy-in-30-seconds) - [Why it matters](#why-it-matters) - [What a storm looks like](#what-a-storm-looks-like) - [How a radar measures rain, in plain words](#how-a-radar-measures-rain-in-plain-words) - [The products](#the-products) - [The open data behind it](#the-open-data-behind-it) - [Who is it for, and what you can build](#who-is-it-for-and-what-you-can-build) - [Run it on your machine](#run-it-on-your-machine) - [Notebooks and example apps](#notebooks-and-example-apps) - [Quick start](#quick-start) - [Keep the «Merging», read fifteen years of history](#keep-the-merging-read-fifteen-years-of-history) - [Every frame since 2010, with an account](#every-frame-since-2010-with-an-account) - [Where the radar can be trusted](#where-the-radar-can-be-trusted) - [How far the radar alone is from the «Merging»](#how-far-the-radar-alone-is-from-the-merging) - [How rare is this rain, here](#how-rare-is-this-rain-here) - [Storms, and a list of the rare ones](#storms-and-a-list-of-the-rare-ones) - [The rain of the next two hours](#the-rain-of-the-next-two-hours) - [The official alert, as data](#the-official-alert-as-data) - [Ask an assistant, write a report](#ask-an-assistant-write-a-report) - [How it works](#how-it-works) - [The traps we already fell into](#the-traps-we-already-fell-into) - [API at a glance](#api-at-a-glance) - [Roadmap, and where AI helps](#roadmap-and-where-ai-helps) - [AI in this project](#ai-in-this-project) - [Contributing](#contributing) - [Data licence and credits](#data-licence-and-credits) --- ## The radar of Italy, in 30 seconds A weather radar sends out a pulse of microwaves and listens for the echo. Raindrops reflect it: the stronger the echo, the heavier the rain. The DPC joins the radars that cover Italy into **one national map**, and then corrects the radar with what the **rain gauges** on the ground really collected. The correction is called the **«Merging»**. ```mermaid flowchart LR R["📡 Weather radars
all over Italy"] --> M1["National mosaic
every 5 minutes"] G["🌧️ Rain gauges
thousands on the ground"] --> MG M1 --> P1["SRI · SRT1
radar only, 1 km"] M1 --> MG["«Merging»
radar corrected with gauges"] MG --> P2["CUM3 · 6 · 12 · 24
radar + gauges, 0.01°"] P1 & P2 -->|"radar-api.protezionecivile.it"| D["dpc-radar"] D --> U["📁 Your analysis
maps · alerts · models"] ``` What you can do with it, for example: - know **how much it has rained** in a place in the last 3, 6, 12 or 24 hours; - see a **storm arriving**, 5 minutes at a time; - feed **flood and landslide models** with rain that was measured, not forecast; - keep your own **archive**: the DPC keeps only about five months. ## Why it matters Italy is a country of short, steep valleys. A storm can pour a month of rain on one of them in a few hours, and leave the next one dry. A **forecast** says what will probably happen over a wide area. A **measurement** says what is happening, here, now. On 10 October 2026 the forecast for Melito di Porto Salvo was 20 mm; the measurement was 192. The measurement exists, it is public, and it is free. What is missing is the last step: getting it into a program without a week of work. That is what this library does, and these are the benefits. | | Without dpc-radar | With dpc-radar | |---|---|---| | **Getting a frame** | read the web viewer's traffic to find two undocumented calls, a required header and a signed link | `await radar.latest("CUM24")` | | **Rain at a place** | open a GeoTIFF, handle two map projections and the «no data» value | `rain.sample([(lon, lat)])` | | **A place nobody measured** | usually read as zero: «dry» | `None`: «not measured» | | **A faulty frame** | a false alarm of 7,000 mm | `frame.check(previous)` says `rejected` | | **A faulty rain gauge** | 126 mm every three hours under a dry sky | `frame.quality(radar=...)` masks it and says `gauge_only` | | **Radar-only rain** | 20 % more than the «Merging», and 70 % more often above 30 mm | `correct(frame)`: the frame times a factor measured place by place | | **Data older than five months** | gone | your own archive, one line a night | | **Rain per hour, corrected with gauges** | not published | `MergingArchive.hourly(...)` | | **The official alert** | a web page and a PDF | `bulletin.zone_at(lon, lat).colour` | Three things we care about, beyond the code: - **Honest numbers.** The library never invents a value. Where the radar did not look, it says so. - **Measured claims.** Every cleaning rule runs on a [benchmark of known cases](https://agentengineering.it/dpc-radar/benchmark/) before it ships; the failures are published with the successes. - **Public money, public data, public code.** The radars are paid by everyone. The more people can read their data, the more it is worth. ## What a storm looks like On **10 October 2026** a storm hit the area around Reggio Calabria, in the toe of Italy. This is the rain of those 24 hours, from one frame of the «Merging» CUM24 product: The radar sees the storm **while it happens**. Here is the rain intensity (SRI, in mm per hour) at four moments of the same day: > Look at the arcs west of Sardinia at 06:00. Rings centred on a single > radar usually mean an artefact, not a storm: the radar picks up echoes from > the sea or from bent beams. Check a frame against the one before it before > you trust it ([the traps](#the-traps-we-already-fell-into)). And this is the same storm in **one place**, hour by hour. At Melito di Porto Salvo most of the rain fell before dawn, between midnight and 05:00 UTC, with up to **21 mm in a single hour**: Radar alone, or radar corrected with the gauges? At Melito the gauges («Merging») measured **192 mm** in the day, and the radar alone saw only **115 mm**, 60 % of it. Over the whole box, though, the radar read about **12 % more** than the gauges. The radar is wrong in both directions, depending on the place. That is why the «Merging» exists: it keeps the radar's picture and corrects it to what the gauges collected. Zoom out, and five months of frames tell the story of a season. Averaged over all of Italy's land, 10 October was not even the wettest day of the autumn: 21 October was (19.4 mm on average against 7.1). A storm that devastates one valley can be a small bar on a national chart. Every image above is made from real DPC frames by [`docs/make_images.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/docs/make_images.py), with the functions of this library. The [second notebook](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/02_anatomy_of_a_storm.ipynb) rebuilds this storm step by step. ## How a radar measures rain, in plain words You do not need this section to use the library. You need it to know **how far to trust the numbers**. ### 1. A radar listens to echoes A weather radar is a dish that turns. It sends a short pulse of microwaves, a few centimetres long, and listens. If the pulse meets raindrops, a tiny part of it bounces back. - **How long** the echo takes to come back says how far the rain is. - **How strong** it is says how much water is up there. This strength is called *reflectivity*. The dish turns all the way round, tilts up a little, and turns again. In a few minutes it has scanned the sky for 200 km around. That is why a new map comes out every five minutes. ### 2. From echo to millimetres: an estimate, not a measurement Here is the weak point. The echo does not depend only on *how much* water there is, but very strongly on *how big* the drops are: one 4 mm drop sends back as much echo as about four thousand 1 mm drops. The radar cannot count drops. It uses a formula built on the average rain, and the classic one (Marshall and Palmer, 1948) gives these rates: | Echo strength | Rain rate | It feels like | |---|---|---| | 20 dBZ | about 0.6 mm/h | drizzle | | 30 dBZ | about 3 mm/h | steady rain | | 40 dBZ | about 12 mm/h | heavy rain | | 50 dBZ | about 50 mm/h | a cloudburst | If today's drops are larger or smaller than average, the rain is wrong, even with a perfect radar. Hail is the extreme case: a few stones echo like a flood. ### 3. The radar looks high above your head The beam leaves almost flat, but the Earth curves away under it. ① At 100 km the beam is 1.5 km above the radar; ② at 200 km it is 4 km up. What the radar sees there is not what reaches the ground: - ③ **Mountains block the beam.** Behind a ridge the radar sees less, or nothing. Italy is mostly mountains. - ④ **Melting snow looks like a downpour.** High up, rain is often snow. As it melts it gets a coat of water and echoes much more than the rain it becomes. On the map it is a ring of false heavy rain. - ⑤ **Rain can form under the beam.** Against a slope, moist air rises and the drops grow in the last kilometre before the ground. The radar, looking higher, misses that water. This is the likely story of Melito, where it saw 115 mm of 192. - **Heavy rain hides what is behind it.** The pulse loses strength crossing a storm, so a second storm further away looks weaker than it is. - **Not every echo is rain.** Hills, the sea, wind farms, and on some days the air itself, which bends the beam down to the ground. These are the arcs and disks that appear on the map where no cloud is. ### 4. The rain gauge: true, but only where it stands A rain gauge is a funnel on a pole that collects the rain and weighs or counts it. It measures the water that really reached the ground. But it samples a patch as wide as a dinner plate, and the next gauge may be ten kilometres away. A summer storm can pass between two gauges and leave both dry. The cloudburst over Lipari on the same 10 October was like that, and there even the radar missed it. ### 5. The «Merging»: the best of both So each instrument has what the other lacks: | | Radar | Rain gauge | |---|---|---| | **Where** it rained | everywhere, every kilometre | only where a gauge stands | | **How much** it rained | an estimate, sometimes far off | a real measurement | | **How fast** it arrives | every 5 minutes | minutes to hours | The DPC combines them: the radar gives the **shape** of the rain, the gauges fix the **amount**. The result is the «Merging», published as `CUM3`, `CUM6`, `CUM12` and `CUM24`. It is the closest thing to «how much it really rained, everywhere» that Italy has, and it is open. ### 6. What this means when you use the data - For **totals** (how many millimetres), use a «Merging». Use the radar-only products (`SRI`, `SRT1`) for **timing**: is it raining now, when did it start, where is the storm going. - A **`None`** is information: nobody measured there. Never turn it into zero. - Rain **far from every radar** and **behind mountains** is less sure than rain on a plain near a radar. - A value that is **absurd** (thousands of millimetres) or a shape that is **too regular** (a ring, a disk, a smooth bell) is a fault, not weather. [`check`](#4-check-a-frame-before-you-trust-it) catches the first kind. - A map of measured rain is **not a forecast** and **not an alert**. It tells what fell, not what will. ## The products | Product | What it measures | Source | Grid | New frame | |---|---|---|---|---| | `SRI` | rain intensity right now (mm/h) | radar only | 1 km | every 5 min | | `SRT1` | rain in the last hour (mm) | radar only | 1 km | every 5 min | | `CUM3`, `CUM6`, `CUM12`, `CUM24` | rain in the last 3–24 hours (mm) | «Merging»: radar + rain gauges | 0.01°, EPSG:4326 | every 30 min | **Which one should I use?** - *Is it raining now, and how hard?* → `SRI`. - *How much rain fell in the last hour?* → `SRT1`. - *How much rain fell in the last day?* → `CUM24` (or `CUM3`–`CUM12` for shorter windows). The gauges make it the most accurate, but it arrives every 30 minutes, not every 5. **One open doubt on `SRT1`.** This page calls it radar only. The [ARCO Data Hub](#every-frame-since-2010-with-an-account) serves the very same frames (equal pixel by pixel on 30 hours of 2026) under the name `SRT1_adj`, «radar estimate adjusted with rain gauges». One of the two descriptions is imprecise, and it has not been checked with the DPC. What has been measured: on ten episodes of 2026, three hours of `SRT1` were between 43 % and 118 % of the «Merging» `CUM3` of the same hours. Whatever adjustment `SRT1` carries, it is not the «Merging»: for totals, use the `CUM` products. ## The open data behind it Everything this library reads is published by a public body, free, with no account and no key. | Data | What it is | Published by | How fresh | Kept for | Licence | |---|---|---|---|---|---| | **Radar mosaic** `SRI`, `SRT1` | rain rate now and rain of the last hour, radar only, 1 km | Dipartimento della Protezione Civile | every 5 min | about 5 months | CC BY-SA 4.0 | | **«Merging»** `CUM3`–`CUM24` | rain of the last 3–24 hours, radar corrected with the rain gauges, 0.01° | Dipartimento della Protezione Civile | every 30 min | about 5 months | CC BY-SA 4.0 | | **Criticality bulletin** | the official alert, zone by zone, for today and tomorrow | Dipartimento della Protezione Civile, on GitHub | every afternoon | since 2020 | CC BY 4.0 | | **IT-DPC-SRI** | fifteen years of the radar mosaic, 2010–2025, in one 50 GB file | Fondazione Bruno Kessler, on Zenodo | fixed | permanent (DOI) | CC BY-SA 4.0 | What the licences ask of you, in one line: **say where the data comes from** («Dipartimento della Protezione Civile»), and if you publish something made from the radar data, **share it under the same licence**. Two limits to know before you plan a project: - **The API has a short memory.** A frame older than about five months is gone. If you will need last winter's rain next year, start [your archive](#keep-the-merging-read-fifteen-years-of-history) today. - **The fifteen-year history is radar only.** It has no gauge correction, so it under-estimates: use it to learn *patterns*, not to quote totals. One source is outside that rule, and optional: the [ARCO Data Hub](#every-frame-since-2010-with-an-account) keeps every frame of the mosaic since 2010, live, and asks for a free account. ## Who is it for, and what you can build - **Researchers and students** in hydrology, meteorology and geology who want measured rain in a notebook or a pipeline: the rain behind a landslide, a year of storms over a catchment, a training set for a model. - **Civil protection, utilities and engineers** who watch rivers, slopes, roads or drains: a message when a violent shower enters your area, the rain of the last six hours on every pumping station, a report after each event that can be repeated and checked. - **Farmers and insurers**: how much really fell on a field, not at the nearest weather station twenty kilometres away. - **Data journalists and civic developers** who want to show what fell during a storm, with a source anyone can check, next to the alert that had been issued. - **Teachers**: five notebooks that turn a storm in the news into a lesson on measurement, error and open data. ## Run it on your machine Everything in one go: the library with every extra, the command line, the MCP server and a demo: a live map of the rain, ready for the site of a public body. **With Docker**, and nothing else to install: ```bash git clone https://github.com/agent-engineering-studio/dpc-radar cd dpc-radar docker compose up # builds the images, starts the demo docker compose down # stops it and removes the containers (or: make down) ``` Then open **http://localhost:3000**. The first run takes a few minutes, to build the images. **Without Docker**, with [uv](https://docs.astral.sh/uv/) (it installs Python too) and [Node](https://nodejs.org/) 20 or later: ```bash git clone https://github.com/agent-engineering-studio/dpc-radar cd dpc-radar scripts/init.sh # installs everything, downloads two days of frames into ./data make demo # the demo, on http://localhost:3000 ``` The [demo](https://github.com/agent-engineering-studio/dpc-radar/tree/main/demo) is a page built with [Bootstrap Italia](https://italia.github.io/bootstrap-italia/), the interface kit of the Italian public administration: a map on OpenStreetMap with the rain of now or of the last 1 to 24 hours, and beside it the card of a place. **Play** shows how the rain moved: the last thirteen frames, one after the other. It is made for the site of a municipality. Give it the coordinates and the name of the place (`DPC_RADAR_LAT`, `DPC_RADAR_LON`, `DPC_RADAR_PLACE`, or `?lat=…&lon=…&place=…` in the address) and it opens there, with the card of the place already open; with none it opens on Gioia del Colle, in Apulia. `layer=24` in the address, or `DPC_RADAR_LAYER`, chooses what the map shows first. Click anything and a card says what the library knows about it, with the lines of Python that give it. The radars are drawn when you tick them, and the page is in Italian or in English (**IT | EN**, top right): | Click | The card shows | From | |---|---|---| | **any point** | the rain now and in the last 1 to 24 hours, how rare it is there, the rain of the next two hours and the chance of it, the storms within 50 km, how far the radar can be trusted there | `RainGrid.sample`, `rarity`, `nowcast`, `chance`, `reliability` | | **an alert zone** | the official alert of the DPC bulletin, day by day, and the rain over the whole zone | `bulletins.latest`, `facts.describe` | | **a storm** | its peak, its area, where it is going and how fast | `storms`, `motion` | | **a radar** | whether it is on, and the rain inside its range | `SITES`, `radar_status` | A small API ([`demo/api.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/demo/api.py), Starlette) asks the library; the page ([`demo/web`](https://github.com/agent-engineering-studio/dpc-radar/tree/main/demo/web), Next.js and Leaflet) draws what it answers. What else you can run: | Command | With Docker | What it does | |---|---|---| | `scripts/fetch-data.sh` | `docker compose run --rm init` | downloads the frames of the last days, for the reports, and the status of the radars; run it again to get the newest | | `uv run dpc-radar init data/dpc-radar --days 7` | `docker compose run --rm cli init --days 7` | keeps the frames before the DPC deletes them | | `uv run dpc-radar report --bbox … --day … --out …` | `docker compose run --rm cli report …` | the report of a day over a box | | `uv run dpc-radar sites` | `docker compose run --rm cli sites` | which radars the DPC viewer reports as on | | `uv run python` | `docker compose run --rm python` | Python, with `dpc_radar` to import | | `uv run dpc-radar mcp` | `docker run -i --rm dpc-radar:local dpc-radar mcp` | the MCP server, for an assistant | Three variables change the defaults: `DPC_RADAR_DAYS` (how many days of frames, 2), `DPC_RADAR_PORT` (the port of the demo, 3000) and `DPC_RADAR_DATA` (the data folder: `./data` without Docker, the volume `radar-data` with it). The frames go to `dpc-radar/` inside it, or inside `DATA_ROOT` when it is set (see [Where the data lives](#where-the-data-lives)). The demo is a demo of the library, not an alert service. ## Notebooks and example apps Five notebooks, from the first map to the official alert. Each one is saved **with its results**, so you can read it on GitHub like an article, or open it in Colab and run it on today's rain. | | Notebook | You learn | Run it | |---|---|---|---| | 1 | [Your first rain map of Italy](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/01_first_rain_map.ipynb) | the latest frame, the rain on your city, why «no data» is not «no rain» | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/01_first_rain_map.ipynb) | | 2 | [Anatomy of a storm](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/02_anatomy_of_a_storm.ipynb) | the Melito flood hour by hour; what the radar alone lost | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/02_anatomy_of_a_storm.ipynb) | | 3 | [Trust, but verify](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/03_trust_but_verify.ipynb) | a frame with 7,348 mm of false rain, and the check that rejects it (offline) | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/03_trust_but_verify.ipynb) | | 4 | [Hourly rain from your own archive](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/04_hourly_rain_archive.ipynb) | save the frames; rain per hour corrected with the gauges | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/04_hourly_rain_archive.ipynb) | | 5 | [The official alert, next to the radar](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/05_alert_vs_radar.ipynb) | what was announced and what fell, zone by zone | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/05_alert_vs_radar.ipynb) | Two results from them. The same hours at Melito, radar alone and corrected with the gauges: the worst hour goes from 21 to 63 mm, and passes the 30 mm that count as a flash-flood signal (notebook 4). And the alert issued the day before, next to the rain that fell (notebook 5): And three small programs in [`examples/`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples), each one file (the fourth, in the browser, is the [demo](#run-it-on-your-machine)): | Program | What it does | Run it | |---|---|---| | [`rain_at.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples/rain_at.py) | the rain at a place: now, last 3–24 hours, official alert | `uv run python examples/rain_at.py 12.50 41.90 --name Roma` | | [`storm_watch.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples/storm_watch.py) | watches an area and tells you when a violent shower enters it | `uv run python examples/storm_watch.py --rate 30` | | [`nightly_archive.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples/nightly_archive.py) | keeps your archive up to date; made for cron (the same as `dpc-radar archive`, as code to copy) | `uv run python examples/nightly_archive.py ~/radar-archive` | --- ## Quick start ### 1. Install ```bash pip install dpc-radar ``` Python 3.12 or newer. It depends on `httpx`, `numpy` and `rasterio`. No account and no key: the DPC data are open. ### 2. Get the latest frame ```python import asyncio from dpc_radar import RadarClient async def main() -> None: async with RadarClient() as radar: rain = await radar.latest("CUM24") print(rain.product.name, rain.time) # CUM24 2026-11-04 14:00:00+00:00 print(rain.data.shape) # (1233, 1341): 0.01° pixels, NaN where the radar does not see asyncio.run(main()) ``` ### 3. Read the rain at a place ```python melito, reggio = (15.78, 37.92), (15.65, 38.11) # lon, lat in degrees print(rain.sample([melito, reggio])) # mm in the last 24 hours, or None if not measured print(rain.peak((15.25, 37.75, 17.25, 39.45), threshold=50)) # (highest mm, pixels >= 50) ``` `sample` reads the **median of the 3×3 pixels** around each point, never one pixel, and answers `None` where the radar has no data: not measured is not the same as dry. ### 4. Check a frame before you trust it ```python async with RadarClient() as radar: now = await radar.latest("CUM24") before = await radar.at("CUM24", now.time - now.product.period) # 30 minutes earlier check = now.check(before, max_step=150) # mm: more than half an hour of rain if check.grid is None: rain = before # rejected: this frame jumped up where no rain can fall that fast else: rain = check.grid # consistent, or the frame before was the wrong one print(check.verdict, check.jumps) ``` A frame older than about five months is gone: `radar.at(...)` returns `ABSENT` instead of raising, and never retries it. `check` only sees what moves between two frames. `quality` asks more, and says why it does not trust a pixel: ```python from datetime import timedelta from dpc_radar import ABSENT, radar_total async with RadarClient() as radar: cum3 = await radar.latest("CUM3") hours = [await radar.at("SRT1", cum3.time - timedelta(hours=h)) for h in range(3)] # the radar alone over the same three hours; with an hour missing, no comparison seen = None if any(h is ABSENT for h in hours) else radar_total(hours) q = cum3.quality(radar=seen) print(q.score, q.reasons) rain = q.grid # the frame without the pixels not trusted; None if the frame is rejected ``` On the frame of 7 October 2026, 06 UTC, it prints `0.996 {'jump': 0, 'beyond_record': 0, 'outlier': 0, 'gauge_only': 356}`: 356 pixels of rain from a gauge that was stuck. | Reason | The rule | It needs | |---|---|---| | `jump` | `check` against the frame before: the only rule that rejects a whole frame | `previous` | | `beyond_record` | more than the most rain ever measured in Italy over the window (948 mm in 24 h, 181 mm in 1 h), plus 25 % | nothing | | `outlier` | a pixel at least 50 mm above the 5×5 pixels around it, and ten times their spread | nothing | | `gauge_only` | a «Merging» frame with 30 mm or more where the radar alone saw less than 5 % of it within 2 km, at a place the radar sees well | `radar` | These are rules, not a trained model: there are too few labelled cases to train one. Each has a threshold measured on the 2,550 frames kept from June to November 2026. In those months the last rule found rain gauges reporting rain under a dry sky in 154 of 1,270 three-hour frames, mostly at the same seven places. Where the radar is blind, as on Lipari, a gauge is all there is and its rain is kept. ### 5. Look at it With `pip install matplotlib`: ```python import matplotlib.pyplot as plt h, w = rain.data.shape left, top = rain.transform.c, rain.transform.f right, bottom = left + w * rain.transform.a, top + h * rain.transform.e plt.imshow(rain.data, extent=(left, right, bottom, top), cmap="Blues", vmin=0, vmax=50) plt.colorbar(label="rain in the last 24 hours (mm)") plt.show() ``` ### Without the client Every step is also a plain function, if you have your own HTTP stack: `products.last_product_url`, `parse_last_product`, `products.download_body`, `parse_download`, `is_expired`, then `RainGrid.from_geotiff(raw, product, time)`. --- ## Keep the «Merging», read fifteen years of history The DPC keeps about **five months** of frames. The «Merging», the rain corrected with the gauges, has no public archive: whatever you do not save in time is gone. `dpc_radar.archive` keeps your own copy and turns it into **hourly rain** at any point. ```python from datetime import UTC, datetime, timedelta from pathlib import Path from dpc_radar import RadarClient from dpc_radar.archive import MergingArchive, archive folder = Path("radar-archive") now = datetime.now(UTC) async with RadarClient() as radar: # run it every night: it only fetches what is missing report = await archive(folder, radar, start=now - timedelta(days=150), end=now, limit=1500) print(report) # ArchiveReport(downloaded=..., present=..., lost=..., failed=..., bytes=...) rain = MergingArchive(folder).hourly( [(15.78, 37.92)], datetime(2026, 10, 10, 0, tzinfo=UTC), datetime(2026, 10, 10, 6, tzinfo=UTC) ) # {01:00: [47.4], 02:00: [63.0], 03:00: [24.6], 04:00: [6.3], 05:00: [5.5], 06:00: [1.7]} ``` The same from the shell, ready for `cron`: it fetches what the folder lacks and says how it went in one line. ```bash dpc-radar archive radar-archive --days 3 # 102 frames saved (98 MB), 0 already there, 0 gone at the DPC, 0 to retry next time ``` It keeps two products: `CUM3` (radar and gauges, every three hours) and `SRT1` (radar alone, every hour). The rain of one hour is the radar's hour rescaled so that the three hours add up to the «Merging»: **the gauges say how much, the radar says when**. Oldest frames are fetched first, since they are the next to disappear; frames the DPC no longer has are written down and never asked again. For the years before, there is **IT-DPC-SRI**: the national radar mosaic from 2010 to 2025, every 5–15 minutes, published on [Zenodo](https://doi.org/10.5281/zenodo.18637608) as one 50 GB archive. Unpack it once, and read it with the same call: ```python from dpc_radar.history import SriHistory # pip install "dpc-radar[history]" history = SriHistory(Path("italian-radar-dpc-sri.zarr")) rain = history.hourly( [(15.78, 37.92)], datetime(2015, 11, 1, tzinfo=UTC), datetime(2015, 11, 2, tzinfo=UTC) ) ``` It is **radar only**: where both exist, compare it with the «Merging». Fewer than one frame in a thousand is corrupted, and `hourly` reads those as missing. And it is **not one series**: until 2017 the mosaic read about two thirds of what it reads since 2018, so do not carry a threshold across that year. ### Where the data lives With no folder given, the library keeps its data in one place: `$DATA_ROOT/dpc-radar` when `DATA_ROOT` is set (the root shared with [Limen](https://github.com/agent-engineering-studio/limen) and the other libraries, each in a folder of its own), otherwise `$XDG_CACHE_HOME/dpc-radar` or `~/.cache/dpc-radar`. `default_directory()` says which. ```text dpc-radar/ ├── merging/ the «Merging» frames: CUM3/ and SRT1/, as archive() writes them └── it_dpc_sri/ the IT-DPC-SRI Zarr store, 2010-2025, only if asked (~51 GB) ``` `init` fills it, and can be run again: it downloads only what is missing. `MergingArchive()` and `SriHistory()` with no argument read from there. ```python from dpc_radar import init report = await init(days=2) # the «Merging» of the last two days report = await init(days=2, history=True) # and IT-DPC-SRI from ECMWF, a few hours ``` ```bash dpc-radar init --days 2 # into the default folder dpc-radar init /srv/data/dpc-radar --history ``` `init(directory=None, *, days=2, history=False, client=None, retries=3, concurrency=32)` takes your `httpx.AsyncClient`, and `retries=0` leaves the retrying to you. A file that fails is counted in the `InitReport` and fetched on the next run; only a disk that cannot be written raises. IT-DPC-SRI comes file by file from ECMWF's object store (`history.mirror`), the same store as on Zenodo, a frame in about 0.14 s instead of a single 50 GB download at 0.1 MB/s. --- ## Every frame since 2010, with an account The DPC API forgets after five months, and IT-DPC-SRI stops in 2025. The [ARCO Data Hub](https://arcodatahub.com/) of Fondazione Bruno Kessler keeps the mosaics as stores that grow every five minutes: the frame of any day since 2010, and the one of ten minutes ago. `dpc_radar.arco` reads them one frame at a time, as the same `RainGrid` the rest of the library works on. ```python from datetime import UTC, datetime from dpc_radar.arco import ArcoClient # pip install "dpc-radar[arco]" async with ArcoClient() as arco: # ARCODATAHUB_USERNAME, ARCODATAHUB_ACCESS_KEY rain = await arco.frame("SRT1", datetime(2019, 10, 21, 18, tzinfo=UTC)) # an hour of 2019 last = await arco.last("VMI") # the newest frame: a few minutes old echo = await arco.frame("VMI", last) # reflectivity, dBZ ``` | Name | What it is | Since | |---|---|---| | `SRI` | rain intensity (mm/h) | 2010 | | `SRT1` | rain of the last hour (mm): the same frame the DPC API serves | July 2018 | | `VMI`, `CAPPI2`–`CAPPI8` | reflectivity (dBZ): the highest of the column, and at 2 to 8 km | 2018 to 2022 | | `VIL`, `ETM` | liquid water in the column (mm), height of the echo top (m) | July 2018 | | `OPERA` | the `VMI` of Europe at 2 km, merged with the DPC's | July 2024 | **It is not open like the DPC API.** It needs a free account and the subscription to each dataset, it asks for fair use (`frames` stops at 288 frames unless you raise `limit`), and it is run by a research foundation, not by the DPC: nothing else in the library depends on it. The data are CC BY-SA 4.0, credit «FBK in cooperation with Dipartimento Protezione Civile Nazionale». **Three states, not two.** `NaN` is not measured; *no echo* is measured, and nothing was there: `-inf` in a reflectivity (0 dBZ is a weak echo), 0 in a height. And the time axis is not regular (`SRI` every 15 minutes in 2010, `SRT1` hourly until 2020): ask `arco.times(name, start, end)` which frames exist. The other traps are in the [reference](https://agentengineering.it/dpc-radar/api/arco/). --- ## Where the radar can be trusted A radar that reads zero is not always a dry sky. On 10 October 2026 a cloudburst hit Lipari and the mosaic showed almost nothing: the nearest beams pass 3,500 m above the island. `reliability` says so before the storm: ```python from dpc_radar import reliability r = reliability(14.95, 38.47) # Lipari r.score # 0.42: below 0.5, do not read a radar zero as "dry" r.visibility # 0.42 the lowest beam is high above the ground... r.beam_height # 3550.0 metres r.coverage # 0.88 ...the radars that reach it were on 88 % of the time r.agreement # None no gauges at sea to compare with r.nearest_site # 'Catania Fontanarossa', 112 km away (r.distance_km) ``` The score is the lowest of three parts, each between 0 and 1: | Part | What it measures | Where it is low | |---|---|---| | `visibility` | the height of the lowest beam that reaches the point without being cut by a mountain (1 up to 1,500 m, 0 from 5,000 m) | far from every radar, behind the Alps and Etna, the islands | | `coverage` | the share of the hourly frames in which the mosaic has data there | Calabria and Apulia (radars on about half of the time, June–November 2026); the west of Sicily, never covered: score 0 | | `agreement` | the rain of the radar alone (SRT1) against the «Merging» (CUM3), as the smaller of the two ratios; not known around a rain gauge that reports rain under a dry radar most of the time | around Palermo the radar read 29 % of the gauge-corrected rain | `reliability_map().like(grid)` gives the score on the pixels of any frame, and `SITES` lists the 24 radars. The map is an estimate made from outside: the DPC publishes neither a quality map nor the gauges of the «Merging». Seven radar positions come from the DPC's own table; the others were found by fitting their range circles on the mosaic. `coverage` and `agreement` describe the five months the map was built on. **Which radars are on now.** The DPC viewer reads a file that says, every five minutes, which radars are on: ```python status = await radar.radar_status() # or radar_status(time), two weeks back if status: # ABSENT: not known print([r.code for r in status.off]) # ['LAURO', 'PETTINASCURA', 'LINATE'] ``` ```bash dpc-radar sites # the same, as a table ``` Take it as a hint, not as proof. The file is public but not documented, and it has no licence. On 17 November 2026 it was right about Monte Lauro and Monte Pettinascura (off, and missing from the mosaic), but it gave Milano Linate as off while the mosaic had data all around it, and Catania as on while its circle was empty. The library never uses it to mark data as good or bad. More in the [documentation](https://agentengineering.it/dpc-radar/api/status/). ## How far the radar alone is from the «Merging» The radar-only products (`SRI`, `SRT1`) come every 5 minutes, the «Merging» every 30. So it is tempting to use the radar alone. From June to November 2026 it read **20 % more rain** than the «Merging» (33 % more on land) and passed 30 mm in three hours **70 % more often**. Not everywhere in the same direction: ```python from dpc_radar import correct, radar_factor radar_factor(12.5, 41.9) # 0.64 Rome: the radar reads 1.6 times the «Merging» radar_factor(13.36, 38.12) # 2.0 Palermo: it reads less than half radar_factor(13.0, 40.5) # 1.0 open sea: no gauges, nothing to correct with srt1 = await radar.latest("SRT1") closer = correct(srt1) # the same frame, times the factor of every pixel ``` The factor is the rain of `CUM3` over the rain of the three `SRT1` hours of the same window, summed over five months and over 9 km. Measured by correcting every month with the map of the other months: | Three-hour rain against the «Merging» | Mean error | Total | Passes 30 mm | Passes 50 mm | |---|---|---|---|---| | radar alone | 1.91 mm | 1.20 | 1.70 times as often | 1.81 | | one factor for the whole of Italy | 1.94 mm | 0.99 | 0.94 | 0.87 | | **the factor map** | **1.55 mm** | **1.00** | **0.89** | **0.84** | **What it is not.** It cannot find rain the radar did not see: zero times a factor is zero. It corrects how much, not where. It **lowers heavy rain**: where the «Merging» has 30 mm or more, the radar alone reads 0.91 of it and the corrected radar 0.75, and in July and August it passes 30 mm half to two thirds as often as the «Merging». Use it for totals and for how often a threshold is passed over a season, not for the peak of one storm. In Sicily it helps little. It was measured on three-hour windows of 2026, and it is **not applied to the 2010–2025 history**: there is no «Merging» of those years to test it on. A model with more inputs (gradient boosting) was tried and dropped: about the same mean error, but it almost never reached 100 mm. The [full table](https://agentengineering.it/dpc-radar/api/bias/), by region, by intensity and by month, is in the reference. ## How rare is this rain, here A hundred millimetres in a day are a rain of most years in Genoa and one of a generation in Bari. `rarity` says how rare a rain of 1, 3, 6 or 24 hours is at a place, from a map that ships with the package: ```python from dpc_radar import radar_total, rarity, return_level, return_period rarity(24, 8.93, 44.41, 100.0).return_period # 1.7 Genoa: most years rarity(24, 16.87, 41.12, 100.0) # Bari: 32 years (between 9 and 50 or more), percentile 99.99 return_level(24, 8.93, 44.41, 10) # Level(mm=203.1, low=166.6, high=264.1) srt1 = await radar.latest("SRT1") years = return_period(srt1) # the return period of every pixel of the last hour day = return_period(radar_total(last_24_hours), 24) # of a sum of hourly frames ``` The map is a GEV distribution of the highest window of each year, in cells of 5 km, fitted on the hourly rain of the IT-DPC-SRI history from **2018 to 2025**. Not from 2010: until 2017 the mosaic read about two thirds of what it reads now, and a map on all sixteen years calls ordinary today's rain rare. **How far to trust it.** Eight years are few. Fitted on six and asked about the other two, what the map calls "10 years" came about every 7 and "20 years" every 13; nothing is given beyond 50 years. It is in **radar millimetres**: the radar alone reads more than the rain gauges over most of the land, so these levels are not those of the official rainfall curves, and a radar-only frame brings its faults with it (in the image, the radar alone finds twice the area of the «Merging»). Clean the frame with [`quality`](#4-check-a-frame-before-you-trust-it) first. The [tables](https://agentengineering.it/dpc-radar/api/climatology/) are in the reference. ## Storms, and a list of the rare ones `storms` turns a frame into objects: every patch of rain over a threshold, with its centre, area and peak. `track` follows them from frame to frame. ```python from dpc_radar import rare_events, storms, track, with_merging # pip install "dpc-radar[storms]" for storm in storms(sri, threshold=10): # the convective cores of an SRI frame print(storm.lon, storm.lat, storm.area_km2, storm.peak) for t in track(sri_frames, threshold=10): # one Track per storm print(t.start, t.duration, t.peak, t.distance_km, t.speed_kmh, t.heading, t.water_m3) events = rare_events(hourly_srt1_frames) # rain over the 10-year level of its place events = [with_merging(e, archive) for e in events] # ... and what the «Merging» says ``` `rare_events` reads hourly frames in order, sums them over 1, 3, 6 and 24 hours and keeps the patches over the level of their place ([`rarity`](#how-rare-is-this-rain-here)), where the radar is reliable. Rain that lasts is one `Event`, the rarest first: where, when, how many millimetres against which level, and whether the «Merging» confirms it. On the 160 days of 2026 in our archive it finds **1,689 events** over the 10-year level on land, 339 of them at the 50-year ceiling; the «Merging» confirms 1,054 and 214. The flood of Melito di Porto Salvo of 10 October is there, at rank 172; Lipari is not, because the radar is nearly blind there. The list is [a CSV](https://github.com/agent-engineering-studio/dpc-radar/blob/main/docs/data/rare-rain-2026.csv). **How far to trust it.** These are **candidates**, not verified events: the radar says where to look, the news says what happened. The list is long because a "10-year" rain falls somewhere in Italy most weeks, and because on the hourly frames of 2026 the levels are passed two to five times more often than their name says: read the return period as a ranking. June is full of one-hour summer storms, where hail makes the radar read too much. The [tables](https://agentengineering.it/dpc-radar/api/catalogue/) are in the reference. ## The rain of the next two hours The radar shows rain that has already fallen. `nowcast` moves the latest SRI frame forward along the motion the rain had in the last half hour: a forecast every five minutes, up to two hours. ```python from dpc_radar import chance, motion, nowcast, rain_ahead # pip install "dpc-radar[nowcast]" frames = [...] # the SRI of the last half hour, the oldest first melito = [(15.78, 37.92)] motion(frames).at(*melito[0]) # (5.6, 82.9): km/h, and degrees from north rain_ahead(frames, minutes=120).sample(melito) # [44.7] mm in the next two hours chance(frames, mm=20, minutes=120).sample(melito) # [0.40]: the chance of 20 mm for forecast in nowcast(frames, minutes=60): # the intensity, every five minutes print(forecast.time, forecast.sample(melito)) ``` Everything is a `Forecast`, never a `RainGrid`: it carries when it was issued and how far ahead it looks, and it cannot be taken for observed rain. **How far to trust it.** The rain is moved, not changed: a storm born after the last frame is not there, and one that dies still is. On 120 moments of heavy rain of 2021–2025 it beats the last frame left where it is at every threshold and lead, and it is still poor on peaks: for rain of 1 mm/h the CSI at one hour is 0.34 (0.27 without motion), for 10 mm/h it is 0.08 (0.05). So use `chance` rather than the map of millimetres: of the pixels it gave 40–60 % of 10 mm in the next hour, 39 % got them. On the night of Melito the millimetres forecast for the town went from 4 to 45 from one half hour to the next, and the chance of 20 mm stayed between 0.2 and 0.55. The [tables](https://agentengineering.it/dpc-radar/api/nowcast/) are in the reference. ## The official alert, as data Every day by 16:00 the DPC publishes the **criticality bulletin**: the official alert level of each of Italy's ~190 alert zones, for today and tomorrow, for landslides, rivers and thunderstorms. It is already structured data (GeoJSON, CC BY 4.0); `dpc_radar.bulletins` reads it. ```python from dpc_radar import bulletins # pip install "dpc-radar[bulletins]" bulletin = await bulletins.latest() for zone in bulletin.alerts(): # yellow or above, today, highest first print(zone.colour, zone.name, zone.hydrogeological, zone.hydraulic, zone.thunderstorms) # orange Bacini Flumendosa - Flumineddu 2 0 1 # orange Gallura 2 0 1 # yellow Basi-B 1 0 0 ... zone = bulletin.zone_at(15.78, 37.92) # the zone of a point, with its municipalities print(zone.name, zone.colour) # Versante Jonico Meridionale yellow ``` Levels are numbers: 0 none, 1 yellow, 2 orange, 3 red. This is **the** official alert: whatever you compute from the radar is not, and belongs next to it, never in its place. ## Ask an assistant, write a report **As tools for an assistant.** `dpc-radar mcp` is a server of the [Model Context Protocol](https://modelcontextprotocol.io/): eight tools (`latest`, `rain_at`, `area_summary`, `storm_now`, `rain_ahead`, `official_alert`, `rarity`, `radar_status`) that answer with numbers computed from a frame, each with the product and the time it came from. ```bash claude mcp add dpc-radar -- uvx --from "dpc-radar[mcp]" dpc-radar mcp # or, with the image of this repository (docker compose build): claude mcp add dpc-radar -- docker run -i --rm dpc-radar:local dpc-radar mcp ``` Then "how much has it rained on Messina in the last three hours?" is answered from the `CUM3` frame of that moment, checked against the one before it; where the radar does not measure, the answer is `null`, not zero. The same facts from Python: `dpc_radar.facts.Facts`. **As a report.** One command writes the report of a day of rain over a box: ```bash pip install "dpc-radar[report]" dpc-radar report --bbox 15.5,37.85,16.2,38.3 --day 2026-10-10 --out melito ``` It writes `facts.json` (every figure, with its frames), `report.md`, a map and an hourly chart: how much it rained on the radar alone and on the «Merging», where it rained most and how rare that was there, how far the radar can be trusted at that place, and the level the official bulletin had given it. For 10 October 2026: 206.7 mm at Melito di Porto Salvo on the «Merging», where the radar alone read 115 mm; six hours with a return period of about 31 years; the zone on orange since the day before. The text is written from a template, and **every number in it is checked against `facts.json` before it is saved**. The same check takes a text of your own, or of a language model (`--text`, or `dpc-radar check report.md facts.json`): a number that is not in the facts is refused. It catches an invented number, not one said of the wrong thing. **For coding agents.** The site publishes [`llms.txt`](https://agentengineering.it/dpc-radar/llms.txt), [`llms-full.txt`](https://agentengineering.it/dpc-radar/llms-full.txt) (the whole documentation as text) and an [agent skill](https://agentengineering.it/dpc-radar/skills/dpc-radar/SKILL.md) with the traps below as rules. Details: [MCP server](https://agentengineering.it/dpc-radar/api/mcp/), [event reports](https://agentengineering.it/dpc-radar/api/report/). --- ## How it works ### Two calls, and one surprise The open API at `radar-api.protezionecivile.it` has two calls that matter. The first says which frame is the newest; the second gives a short-lived download link for one frame. ```mermaid sequenceDiagram autonumber participant You as Your script participant L as dpc_radar participant A as DPC radar API participant S as S3 storage You->>L: last_product_url(CUM24) L-->>You: URL + params You->>A: GET /findLastProductByType?type=CUM24 A-->>You: {"lastProducts": [{"time": 1793790000000, "period": "PT30M"}]} You->>L: parse_last_product(answer) L-->>You: LastProduct(time, period = 30 min) You->>L: download_body(CUM24, time) You->>A: POST /downloadProduct {"productType", "productDate"} A-->>You: {"url": "https://…s3…"} (a signed link) You->>S: GET the link S-->>You: GeoTIFF ``` ### What a frame request can answer ```mermaid flowchart TD q(["POST /downloadProduct
(product, time)"]) --> c1{"status 200?"} c1 -- yes --> ok(["parse_download → S3 link
download the GeoTIFF"]) c1 -- no --> c2{"is_expired(status, body)?
a 500 with S3's 403 inside"} c2 -- yes --> gone(["the frame is gone
(older than ~5 months)
never retry"]) c2 -- no --> retry(["a real failure
retry later"]) ``` ### The building blocks Three layers. `products` is **pure**: it builds requests and reads answers, with no network. `grid` turns a GeoTIFF into an array you can sample and check. `client` wires them to **your** `httpx.AsyncClient`, so timeouts, retries and proxies stay under your control. ```mermaid flowchart LR subgraph yours["Your code"] H["httpx.AsyncClient
or a send= hook"] end subgraph lib["dpc_radar"] direction TB CL["client.py
RadarClient · latest · at · ABSENT"] PR["products.py
SRI · SRT1 · CUM3–24
requests · parsers · is_expired"] GR["grid.py
RainGrid · sample · peak · crop · check"] ER["errors.py
DpcRadarError"] AR["archive.py · history.py
MergingArchive · SriHistory
hourly rain"] BU["bulletins.py
the official alert by zone"] end H --> CL CL --> PR CL --> GR AR --> GR classDef next stroke-dasharray: 5 5 ``` --- ## The traps we already fell into Every line below cost a bug in a real early-warning system. The library handles the ones it can; the others are here so you don't have to find them yourself. | Trap | What happens | What to do | |---|---|---| | **No `CUM1`** | asking for it gives an empty list, not an error | the shortest «Merging» is `CUM3`; for one hour use `SRT1` | | **"Gone" looks like a crash** | a frame older than ~5 months answers **500**, with S3's `403 Forbidden` in the body, not 404 | `is_expired(status, body)`: never retry those | | **The «Merging» disappears** | the DPC keeps about five months, and there is no public archive of it | `dpc_radar.archive`: save them every night, oldest first | | **Two grids** | `SRI`/`SRT1` are 1 km in a Transverse Mercator projection; `CUM*` are 0.01° in EPSG:4326 | never mix the arrays: reproject one onto the other | | **A corrupted series** | in October 2026 every CUM24 frame at :30 carried a smooth bell of up to 20,584 mm over Abruzzo, for days (the :00 frames were right) | never trust one frame alone: compare it with its neighbours, and read a place with the median of the 3×3 pixels around it | | **Not every echo is rain** | sea clutter or a radar with a problem can paint rain where there is none. But a round edge alone proves nothing: it is where a radar's range ends | look at the hourly frames: rain moves, clutter stays | | **A gauge can be wrong too** | on 6–8 October 2026 one gauge of the «Merging» was stuck: 126.6 mm every 3 hours for 33 hours on a dry night, 1,152 mm in `CUM24` | a jump between frames does not catch it; the radar alone (`SRT1`) read 0: `frame.quality(radar=...)` masks it | | **Radar alone is not the truth** | the radar-only history read between 10 % and 80 % of the gauges in Apulia in 2016; in 2026 the radar alone read 20 % *more* than the «Merging», and up to 1.7 times in Milan and Genoa | use the «Merging» when you can; `correct(frame)` for the radar alone of 2026; compare on your area | | **A radar "on" may not be there** | the viewer's status file gave Catania as on while its circle was empty, and Linate as off while the mosaic had data there (17 November 2026) | `radar_status()` is a hint; what counts is whether the frame has data (`NaN` is not measured) | | **Times are in UTC, in milliseconds** | the API speaks epoch milliseconds | `to_epoch_ms` / `from_epoch_ms`, and always aware datetimes | | **The `origin` header** | the API once refused requests without it; in November 2026 it no longer does | `products.HEADERS` sends it anyway | Every trap above is a case in the **[benchmark](https://agentengineering.it/dpc-radar/benchmark/)**: real frames where we know the answer, and how each cleaning rule scores on them. The rule the library started from (`limen-max-step`) passes 14 of 33 checks; a frame-level check (`jump-sign`) passes 26, 28 with the reliability map, and `quality` 31: the two it misses are rain gauges wrong by a few millimetres, which one frame cannot tell from light rain. --- ## API at a glance | Name | What it is | |---|---| | `RadarClient(client=None, send=None, retries=3)` | the client: `async with`, your `httpx.AsyncClient` or a `send` hook | | `radar.latest(p, cached=None)` | the newest frame as a `RainGrid`; `cached` skips the download if it is still the newest | | `radar.at(p, time)` / `radar.download(p, time)` | the frame issued at `time` as a grid / as GeoTIFF bytes, or `ABSENT` | | `radar.last_product(p)` | time and period of the newest frame | | `RainGrid` | one frame: `product`, `time`, `data` (NaN = no data), `transform`, `crs` | | `grid.sample(points)` | the value at lon/lat points: median of the 3×3 pixels, `None` if not measured | | `grid.peak(bbox, threshold=)` / `grid.crop(bbox)` | highest value and pixels above a threshold in a box / the box as a grid | | `grid.check(previous, max_step=)` | `FrameCheck(verdict, grid, jumps)`: whether to trust a frame, given the one before | | `grid.quality(previous=None, radar=None)` | `Quality(grid, mask, reasons, score, verdict)`: what to trust pixel by pixel, and why | | `radar_total(frames)` | the radar-only rain over a window: the sum of its hourly `SRT1` frames | | `ABSENT` | a frame the DPC no longer keeps | | `init(directory=None, days=2, history=False)` / `default_directory()` | download what the library needs offline into its folder: the «Merging» of the last days, and IT-DPC-SRI if asked; an `InitReport` / that folder, `$DATA_ROOT/dpc-radar` or `~/.cache/dpc-radar` | | `archive(folder, radar, start=, end=, limit=)` | download the CUM3 and SRT1 frames the archive lacks; an `ArchiveReport` | | `MergingArchive(folder=None).hourly(points, start, end)` | hourly rain per point from the archive: SRT1 rescaled to the CUM3 | | `SriHistory(zarr=None).hourly(points, start, end)` / `history.mirror(folder)` | the same from IT-DPC-SRI, 2010–2025, radar only (extra `history`) / copy the store from ECMWF's object store | | `ArcoClient().frame(name, time)` / `.frames(name, start, end)` / `.times(...)` / `.last(name)` | a frame of the ARCO Data Hub since 2010 as a `RainGrid`, `None` if it has none / the frames of a span / which exist / the newest. `SRI`, `SRT1`, `VMI`, `CAPPI2`–`8`, `VIL`, `ETM`, `OPERA` (extra `arco`, a free account) | | `reliability(lon, lat)` / `reliability_map()` | how much to trust the radar at a point: `score`, `visibility`, `coverage`, `agreement`, `beam_height`, `reliable` / the whole map, `.like(grid)` on the pixels of a frame | | `SITES` | the 24 radars of the mosaic: position, altitude, band, range, DPC code | | `await radar.radar_status(time=None)` | which radars the DPC viewer reports as on: `.off`, `.of(site)`, `.geojson()`; `ABSENT` when not known. From an undocumented file: a hint | | `correct(grid)` / `radar_factor(lon, lat)` / `bias_map()` | a radar-only frame times the factor «Merging» / radar of every pixel / the factor at a point (1.0: no correction) / the whole map, `.like(grid)` | | `rarity(window, lon, lat, mm)` / `return_level(window, lon, lat, years)` / `return_period(grid, window=None)` | how rare a rain of 1, 3, 6 or 24 hours is at a point: `return_period` with `low` and `high`, `percentile`, `years` / the rain of a return period, a `Level(mm, low, high)` / the return period of every pixel of an accumulation frame; `climatology()` is the whole map | | `storms(grid, threshold=)` / `track(grids, threshold=)` | the patches of rain of a frame as `Storm`s (`lon`, `lat`, `area_km2`, `peak`, `mean`, `bbox`) / followed in time as `Track`s: `duration`, `path`, `distance_km`, `speed_kmh`, `heading`, `water_m3` (extra `storms`) | | `rare_events(frames, years=10)` / `with_merging(event, archive)` | the rain of hourly frames over the level of its place, as `Event`s, the rarest first: `start`, `time`, `window`, `mm`, `level_mm`, `times_level`, `return_period`, `area_km2` / the same with `radar_mm`, `merging_mm`, `confirmed` (extra `storms`) | | `nowcast(frames, minutes=120)` / `rain_ahead(frames, minutes=60)` / `chance(frames, mm=, minutes=60)` / `motion(frames)` | the SRI moved along its motion, as `Forecast`s (`issued`, `lead`, `time`, `unit`, `data`, `.sample(points)`): mm/h every five minutes / the mm of the next minutes / the chance of at least `mm` / speed and heading of the rain, `.at(lon, lat)` (extra `nowcast`) | | `Facts(radar)` (`dpc_radar.facts`) | the facts as dicts, each with its frame: `rain_at`, `area_summary`, `storm_now`, `rain_ahead`, `official_alert`, `rarity`, `latest`; the tools of `dpc-radar mcp` (extra `mcp`) | | `report.build(read, bbox, day)` / `check_text(text, facts)` / `check_claims(text, facts)` | the report of a day over a box: `.facts`, `.text()`, `.save(folder, text=None)` / the numbers of a text that are not in the facts / those the template's sentences say of the wrong fact; `dpc-radar report`, `dpc-radar check` (extra `report`) | | `bulletins.latest()` / `bulletins.fetch(name)` | the official criticality bulletin: `Bulletin.zones`, `.alerts()`, `.zone_at(lon, lat)` (extra `bulletins`) | | `SRI`, `SRT1`, `CUM3`, `CUM6`, `CUM12`, `CUM24` | the products: `name`, `hours` (`None` for an intensity), `merging`, `description` | | `PRODUCTS`, `product(name)` | every product by name; `product("cum24")` → `CUM24` | | `products.last_product_url(p)` | URL and params of the "latest frame" request (a `GET`) | | `products.download_url()`, `products.download_body(p, at)` | URL and JSON body of the "download link" request (a `POST`) | | `parse_last_product(answer)` | `LastProduct(product, time, period)`, or `None` if the API lists none | | `parse_download(answer)` | the signed S3 link of a frame | | `is_expired(status, body)` | `True` when the frame is gone for good | | `products.HEADERS`, `products.NODATA` | the `origin` header; `-9999.0`, the no-data value of every product | | `products.to_epoch_ms`, `from_epoch_ms`, `parse_period` | the API's times and periods (`PT5M`, `PT30M`) | | `DpcRadarError` | an answer the library cannot read, or a bad argument | | `dpc-radar archive [FOLDER] --days 2` | the command line: save the CUM3 and SRT1 frames the folder lacks | | `dpc-radar init [DIRECTORY] --days 2 [--history]` | the command line: what `init` downloads | | `dpc-radar report` / `dpc-radar check` / `dpc-radar mcp` | the report of a day over a box / the numbers of a text against its facts / the MCP server | | `dpc-radar sites [--time …] [--out FILE]` | the radars and which are reported on, as a table or as GeoJSON | Full reference: **https://agentengineering.it/dpc-radar/api/client/** --- ## Roadmap, and where AI helps The plan of 2026 is done: every idea below is in the library, and what each one measured is on the [roadmap](https://agentengineering.it/dpc-radar/roadmap/) ([#10](https://github.com/agent-engineering-studio/dpc-radar/issues/10)). dpc-radar stands on its own: it needs no other project, and no project needs to change for you to use it. Its first user is [Limen](https://github.com/agent-engineering-studio/limen), an open early-warning system; what is still open on that side is tracked there ([limen#643](https://github.com/agent-engineering-studio/limen/issues/643)). ```mermaid flowchart LR B["Benchmark
known cases"] --> P0["Phase 0
reliability map
climatology
storm catalogue"] P0 --> P1["Phase 1
frame quality check"] P1 --> P2["Phase 2
nowcasting
radar–gauge bias"] P2 --> P3["Phase 3
MCP · llms.txt
event reports"] P0 & P1 & P2 & P3 -.-> L["Whoever uses it
fewer false alarms ·
more events anticipated"] ``` | Idea | In plain words | What you gain | Issue | |---|---|---|---| | **Benchmark** ✅ | a fixed set of storms and faults where we know the answer | every change measurable | [#2](https://github.com/agent-engineering-studio/dpc-radar/issues/2) | | **Reliability map** ✅ | where the radar sees well, and where it is blind | a blind spot is no longer read as "dry" | [#3](https://github.com/agent-engineering-studio/dpc-radar/issues/3) | | **Rain climatology** ✅ | how rare is this rain *here*, from eight years of radar (2018–2025) | rain judged against the place, not against one national threshold; the effect on real alerts is still to measure | [#4](https://github.com/agent-engineering-studio/dpc-radar/issues/4) | | **Storm catalogue** ✅ | every storm as an object, and the rare rain as candidate events to check in the news | 1,689 candidates in 160 days of 2026, 1,054 confirmed by the «Merging»; the check in the news is yours | [#5](https://github.com/agent-engineering-studio/dpc-radar/issues/5) | | **Frame quality check** ✅ | rules that tell a real storm from a broken frame or a faulty gauge, and say why | fewer false alarms | [#6](https://github.com/agent-engineering-studio/dpc-radar/issues/6) | | **Nowcasting** ✅ | the rain field moved forward along its motion, 0–2 hours, and the chance of rain at every pixel | a trigger on rain that is *coming*; moved, not changed: better than the last frame, poor on peaks | [#7](https://github.com/agent-engineering-studio/dpc-radar/issues/7) | | **Radar–gauge bias** ✅ | how far the radar alone is from the «Merging», place by place, and a factor for it | radar-only rain closer to the «Merging» between two frames; the history is still open | [#8](https://github.com/agent-engineering-studio/dpc-radar/issues/8) | | **AI for agents** ✅ | an MCP server, `llms.txt` and an agent skill, reports whose every number is checked against the facts | the same facts for any assistant, as data, with the frame each one came from | [#9](https://github.com/agent-engineering-studio/dpc-radar/issues/9) | One rule holds for every AI feature: **the numbers come from the frames**, computed by tested code. A language model may read the news and explain the numbers, never invent them, and nothing here replaces the official DPC alert. --- ## AI in this project AI: Claude by Anthropic Where this project calls a language model, the model is **Claude**, by Anthropic, through its API. Here is exactly where that happens, and where it does not. | Part | Does it call a model? | Which one | |---|---|---| | The library: frames, quality, rarity, storms, nowcast, bulletins | no | none: tested code on the DPC frames | | `dpc-radar report` | no | none: the text comes from a template, and every number is checked against `facts.json` | | `dpc-radar mcp` | no | none: it gives facts to the assistant *you* connect, whichever it is | | [`benchmarks/vision.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/benchmarks/README.md#an-experiment-the-cases-as-pictures) | yes, when you run it with a key | Claude (`claude-opus-5-5`): it looks at the picture of a frame and says what should not be trusted | Nothing calls a model unless you ask for it and you give it a key: ```bash cp .env.example .env # then write your ANTHROPIC_API_KEY in it uv run --env-file .env --group vision python -m benchmarks.vision ask ``` [`.env.example`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/.env.example) lists every variable the project reads. `.env` is never committed. With no key, the library, the command line, the MCP server and the demo work as they are. **What it found.** On the first run (18 November 2026) Claude passed 26 of the 30 checks of that day, and it boxed four patches where the «Merging» had rain and the radar alone had none. Checked on 580 three-hour frames, three of them are rain gauges gone wrong, and they are now cases of the benchmark. The model pointed, and the frames said whether it was right: no number of the library comes from it. ### For a public administration In Italy, a public body that adopts AI follows the *Linee Guida per l'adozione di IA nella Pubblica Amministrazione* of AgID (version 1.0, 9 November 2026). The guidelines speak to the administration, not to a library: the risk class of a system, its impact assessment and the notice to its users are yours to write, for your use. This is what the project gives you to write them with. The demo is a page for the site of a public body: built with Bootstrap Italia, it opens on the coordinates of a municipality (`DPC_RADAR_LAT`, `DPC_RADAR_LON`, `DPC_RADAR_PLACE`) or, with none, on Gioia del Colle in Apulia. How to host it, what stays with the body that publishes it, and the way into the software catalogue of Developers Italia ([`publiccode.yml`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/publiccode.yml)) are in [Riuso nella PA](https://agentengineering.it/dpc-radar/riuso/), in Italian. | Principle of the guidelines | What the project does | |---|---| | **P.5 Responsibility**, **P.13 Human oversight** | A model never decides. Its answer on a frame is a proposal that a person confirms before it becomes a case of the benchmark; the rule that ships is tested code. The official alert stays the DPC's. | | **P.7 Transparency and documentation**, **P.8 Information** | The table above: where a model is called, which model, and where none is. The prompt and the answer schema are in the source. | | **P.10 Accuracy** | Every method, a model included, is scored on the same [benchmark of known cases](https://agentengineering.it/dpc-radar/benchmark/), and the failures are published. A text is checked number by number (`dpc-radar check`). | | **P.11 Robustness** | AI is off by default and nothing depends on it. No key, no network or a refused request leave every number as it is. | | **P.14 Logging** | Every answer of the model is saved with the model that gave it and the tokens it cost; every figure of a report carries the frames it came from (`facts.json`). | | **P.4 Personal data** | None. What goes to the model is a picture of open radar data over an area, and the name of the product. | | **P.9 Data quality** | The data is the DPC's, open and licensed (CC BY-SA 4.0); each frame goes through `quality` before it is used, and "not measured" is never turned into zero. | | **P.12 Security** | The key lives in `.env` or in your environment, never in the repository. | | **P.17 Open source**, **P.18 Sustainability** | The code is Apache-2.0. A model is asked about the few frames in doubt, not about each of the 288 a day. | Claude and Anthropic are trademarks of Anthropic, PBC. This project is not affiliated with Anthropic or endorsed by it. --- ## Contributing Contributions of every size are welcome, from a typo to a new module. You don't need to be a meteorologist: most of the code is plain Python, HTTP and arrays. ```bash git clone https://github.com/agent-engineering-studio/dpc-radar cd dpc-radar uv sync # install everything, dev tools included make check # ruff + mypy --strict + pytest, the same gate as CI make docs # build this site locally ``` The tests **need no network**: they run against answers recorded from the real API. ```text dpc-radar/ ├── src/dpc_radar/ │ ├── products.py # products, requests, parsers, is_expired: pure functions │ ├── grid.py # RainGrid: read a frame, sample, peak, crop, check, quality │ ├── client.py # RadarClient: latest, at, download, ABSENT │ ├── archive.py # archive the «Merging», hourly rain from it │ ├── history.py # IT-DPC-SRI 2010-2025 (extra [history]), and its mirror │ ├── arco.py # the ARCO Data Hub: any frame since 2010 (extra [arco], an account) │ ├── local.py # the library's data folder ($DATA_ROOT/dpc-radar) and init() │ ├── bulletins.py # the official criticality bulletin (extra [bulletins]) │ ├── reliability.py # where the radar can be trusted: a map and its parts │ ├── quality.py # what to trust in a frame, pixel by pixel, and why │ ├── bias.py # how far the radar alone is from the «Merging», and a factor │ ├── climatology.py # how rare a rain is at a place: percentile and return period │ ├── storms.py # storms as objects, followed in time (extra [storms]) │ ├── catalogue.py # the rain over the level of its place, as events │ ├── nowcast.py # the rain of the next two hours (extra [nowcast]) │ ├── facts.py # the facts as dicts, each with the frame it came from │ ├── mcp_server.py # the facts as MCP tools: dpc-radar mcp (extra [mcp]) │ ├── report.py # the report of a day over a box (extra [report]) │ ├── cli.py # the dpc-radar command: mcp, report, check │ └── errors.py # DpcRadarError ├── tests/ # offline: synthetic GeoTIFFs and a fake API │ └── live/ # the same on the real API: uv run pytest -m live ├── benchmarks/ # known cases, and how each cleaning rule scores ├── tools/ # build_reliability.py, build_bias.py, build_climatology.py: the maps; │ # build_catalogue.py: the list of rare rain; │ # measure_nowcast.py: the nowcast against what came next; │ # build_llms.py: llms.txt and llms-full.txt for the site ├── skills/dpc-radar/ # the agent skill: how to use the library, and its traps └── docs/ ├── make_images.py # the images of this README, from real frames └── roadmap.md # what comes next, and where AI helps ``` Good first issues: a notebook with a storm you remember, a recipe for your favourite HTTP library, a check of the radar against a rain gauge near you. See [CONTRIBUTING.md](https://github.com/agent-engineering-studio/dpc-radar/blob/main/CONTRIBUTING.md). Questions, ideas and maps you made go in the organisation's [discussions](https://github.com/orgs/agent-engineering-studio/discussions). --- ## Data licence and credits - **Radar data** (SRI, SRT1, «Merging» CUM): © *Dipartimento della Protezione Civile*, open data under [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/). Credit the DPC and share data you derive from it under the same licence. - **Criticality bulletins**: DPC, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). - **IT-DPC-SRI** (the 2010–2025 history, read by the `history` module): Fondazione Bruno Kessler on DPC data, CC BY-SA 4.0, [doi:10.5281/zenodo.18637608](https://doi.org/10.5281/zenodo.18637608). - **ARCO Data Hub** (read by the `arco` module, with an account): Fondazione Bruno Kessler in cooperation with the DPC, for the IT4LIA AI Factory, CC BY-SA 4.0; `OPERA` also credits the European Weather Radar Network. - **The reliability map** (`src/dpc_radar/data/reliability.tif`) is derived from the DPC radar data and so is under CC BY-SA 4.0, not Apache-2.0. Its terrain comes from the [Terrain Tiles](https://registry.opendata.aws/terrain-tiles/) of Mapzen on AWS Open Data (SRTM, EU-DEM and other open sources; see their [attribution](https://github.com/tilezen/joerd/blob/master/docs/attribution.md)). Radar positions: DPC, *Rete Radar Nazionale*, technical annex. - **The bias map** (`src/dpc_radar/data/bias.tif`) is derived from the DPC radar data too: CC BY-SA 4.0. - **The climatology** (`src/dpc_radar/data/climatology.tif`) is derived from IT-DPC-SRI: CC BY-SA 4.0, credit the DPC and Fondazione Bruno Kessler. - **The list of rare rain** (`docs/data/rare-rain-2026.csv`) is derived from the DPC radar data: CC BY-SA 4.0. The names of the alert zones come from the criticality bulletins. - **The status of the radars** (`radar_status`, `dpc-radar sites`) is read from a file of the DPC radar viewer that declares no licence and is not part of the documented open data. The library reads it when asked and ships no copy of it. - **Country borders** in the images: [Natural Earth](https://www.naturalearthdata.com/), public domain. This library is not affiliated with the DPC. It is not an alert system: for official warnings, see the [DPC criticality bulletin](https://rischi.protezionecivile.gov.it/it/meteo-idro/allertamento/) and your regional civil protection. The code is released under the [Apache-2.0](https://github.com/agent-engineering-studio/dpc-radar/blob/main/LICENSE) licence. # Notebooks and example apps The fastest way to understand the library is to watch it work on a real storm. ## Notebooks Each notebook is saved with its results: read it on GitHub, or open it in Colab and run it with nothing to install. | | Notebook | What it shows | Run it | |---|---|---|---| | 1 | [Your first rain map of Italy](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/01_first_rain_map.ipynb) | The latest frame, the rain on your city, and why «no data» is not «no rain». | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/01_first_rain_map.ipynb) | | 2 | [Anatomy of a storm](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/02_anatomy_of_a_storm.ipynb) | The flood of Melito di Porto Salvo (10 October 2026) hour by hour, and what the radar alone lost. | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/02_anatomy_of_a_storm.ipynb) | | 3 | [Trust, but verify](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/03_trust_but_verify.ipynb) | A published frame with 7,348 mm of false rain, and the check that rejects it. | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/03_trust_but_verify.ipynb) | | 4 | [Hourly rain from your own archive](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/04_hourly_rain_archive.ipynb) | Save the frames before they are gone, then read rain per hour corrected with the gauges. | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/04_hourly_rain_archive.ipynb) | | 5 | [The official alert, next to the radar](https://github.com/agent-engineering-studio/dpc-radar/blob/main/notebooks/05_alert_vs_radar.ipynb) | What the bulletin announced and what fell, zone by zone. | [Colab](https://colab.research.google.com/github/agent-engineering-studio/dpc-radar/blob/main/notebooks/05_alert_vs_radar.ipynb) | ![The frame check on a corrupted frame](images/nb-frame-check.png) *Notebook 3: the frame published on 11 October 2026 at 09:30 UTC, the one before it, and the pixels that jumped. The check rejects it.* ![Hourly rain, radar alone and corrected](images/nb-hourly.png) *Notebook 4: the same hours at Melito di Porto Salvo. Radar alone never reaches 30 mm in an hour; corrected with the gauges, two hours do.* ![The official alert next to the measured rain](images/nb-alert-vs-rain.png) *Notebook 5: the alert issued on 9 October for the day after, and the rain that fell.* Notebooks 2, 4 and 5 read frames of 10 October 2026, which the DPC keeps until about March 2027. After that, change the date at the top to a recent storm. ## The demo A live map of the rain over all of Italy, on OpenStreetMap. Click a point, an alert zone, a storm or a radar, and a card shows the rain there: now and in the last 24 hours, how rare it is, the next two hours, the official alert, how far the radar can be trusted. Every card shows the Python that gives it. ```bash git clone https://github.com/agent-engineering-studio/dpc-radar cd dpc-radar docker compose up # with Docker alone scripts/init.sh && make demo # or with uv ``` Then open http://localhost:3000. More in [Run it on your machine](index.md#run-it-on-your-machine). ![The demo: the rain of the last 24 hours over central Italy, the alert zones, and the card of a point](images/demo.png) Play shows how the rain moved in the last frames: ![The demo playing the rain of the last 24 hours](images/demo.gif) ## Example apps Three programs in [`examples/`](https://github.com/agent-engineering-studio/dpc-radar/tree/main/examples), each one file. | Program | What it does | Run it | |---|---|---| | [`rain_at.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples/rain_at.py) | the rain at a place: now, last 3–24 hours, official alert | `uv run python examples/rain_at.py 12.50 41.90 --name Roma` | | [`storm_watch.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples/storm_watch.py) | tells you when a violent shower enters an area | `uv run python examples/storm_watch.py --rate 30` | | [`nightly_archive.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/examples/nightly_archive.py) | keeps your archive up to date; made for cron | `uv run python examples/nightly_archive.py ~/radar-archive` | ## The theory, in one picture ![Why a radar can miss rain, or see too much](images/how-radar-sees.png) The radar beam climbs with distance, mountains hide part of it, melting snow echoes like a downpour, and rain that forms low falls under the beam. The [home page](index.md#how-a-radar-measures-rain-in-plain-words) explains each point in plain words, and why the «Merging» with the rain gauges is the number to trust for totals. # Client ## `dpc_radar.client` An async client for the DPC radar API: the latest frame, or the frame at a time. Give it your `httpx.AsyncClient` and timeouts, proxies and pooling stay yours; give it none and it opens (and closes) its own. Network errors and 429/5xx are retried `retries` times with exponential backoff, except the one answer that must never be retried: a frame the DPC no longer keeps (a 500 with S3's 403 in the body), which comes back as `ABSENT`. To route every request through your own HTTP layer (a shared retry policy, a rate limiter, a cache), pass `send`: an `async (method, url, **kwargs) -> httpx.Response`. The client then uses it for every call and does no retrying of its own. The hook must *return* error responses rather than raise on them, or the client cannot tell a frame that is gone from a failure. For its own failures it should raise `httpx.HTTPError`: that is what `dpc_radar.archive.archive` counts as one failed frame, along with `dpc_radar.errors.DpcRadarError` and `OSError`. An answer that is not a JSON object (a proxy or maintenance page, a body cut off) raises `dpc_radar.errors.DpcRadarError`. The client keeps no state between calls: no cache, no logging. Holding on to the last frame, and deciding what a failure means, is the caller's job. ### `json_object(response: httpx.Response) -> dict[str, Any]` The JSON object in an answer; `DpcRadarError` if it holds anything else. ### `class Absent()` A frame the DPC no longer keeps (older than about five months), or a status file. ### `class RadarClient(client: httpx.AsyncClient | None = None, *, send: Send | None = None, retries: int = 3, backoff_s: float = 2.0, timeout_s: float = 60.0, base: str = API_BASE, status_base: str = STATUS_BASE, sleep: Callable[[float], Awaitable[Any]] = asyncio.sleep)` The open DPC radar API (`radar-api.protezionecivile.it`). #### `async RadarClient.aclose() -> None` Close the HTTP client if this instance opened it. #### `async RadarClient.last_product(name: str | Product) -> LastProduct | None` Time and period of the newest frame; `None` if the API lists none. #### `async RadarClient.latest(name: str | Product, *, cached: RainGrid | None = None) -> RainGrid` The newest frame of a product. Pass the frame you already hold as `cached`: if it is still the newest, it comes back as is and nothing is downloaded (a CUM frame is about 2 MB and changes every 30 minutes). #### `async RadarClient.at(name: str | Product, time: datetime) -> RainGrid | Absent` The frame of a product issued at `time` (aware), or `ABSENT`. #### `async RadarClient.download(name: str | Product, time: datetime) -> bytes | Absent` The GeoTIFF of a frame as published, or `ABSENT` (to archive it as is). #### `async RadarClient.radar_status(time: datetime | None = None) -> NetworkStatus | Absent` Which radars are on at `time` (aware), or now: see `dpc_radar.status`. `ABSENT` if the DPC has no status file for that time: they are kept for about two weeks, and the file is not documented open data, so it may also be gone for good. Without a time, the newest file of the last twenty minutes. # Rain grid ## `dpc_radar.grid` One radar frame as an array, and what to trust in it. A `RainGrid` is a DPC frame read from its GeoTIFF: rain in mm (CUM, SRT1) or mm/h (SRI), `NaN` where the radar has no data. Two grids exist and must not be mixed: SRI and SRT1 are 1 km in a Transverse Mercator projection, the CUM products 0.01° in EPSG:4326. Every method takes lon/lat in degrees and converts them to the grid's own projection. Read a place with `RainGrid.sample`: the median of the 3x3 pixels around it, never one pixel. Check a frame against the one before it with `RainGrid.check` before trusting it: on 9-11 October 2026 and again from 21 October to 3 November the DPC published every CUM24 frame at :30 with a bell of up to 20,584 mm over Abruzzo, while the :00 frames were right. ### `BBox` west, south, east, north, in degrees (EPSG:4326). ### `class RainGrid(product: Product, time: datetime, data: np.ndarray, transform: Affine, crs: CRS)` One frame: `data` in mm or mm/h (float32, as published), `NaN` where there is no data. #### `RainGrid.from_geotiff(raw: bytes, name: str | Product, time: datetime) -> RainGrid` A frame from the bytes of its GeoTIFF; `-9999` becomes `NaN`. #### `RainGrid.sample(points: list[tuple[float, float]]) -> list[float | None]` The value at each lon/lat point: the median of the valid 3x3 pixels. The median and not the pixel, so that one wrong pixel never becomes a flood on one cell. Outside the frame, or where the 3x3 window holds no data, the answer is `None`: not measured, which is not the same as dry. #### `RainGrid.peak(bbox: BBox, *, threshold: float) -> tuple[float, int]` The highest value inside `bbox`, and how many pixels reach `threshold`. `(0.0, 0)` outside the frame or where there is no data: a radar trigger asks "is it raining hard enough, on enough km², here?". #### `RainGrid.crop(bbox: BBox) -> RainGrid` The part of the frame inside `bbox` (plus the pixel on each edge). #### `RainGrid.check(previous: RainGrid, *, max_step: float, min_pixels: int = 5) -> FrameCheck` Whether to trust this frame, given the one before it. Two accumulations of the same length, one period apart, differ by the rain that entered the window minus the rain that left it: never more than one period of rain. Where they differ by more than `max_step`, one of the two is wrong, and the sign says which: every corruption seen so far *adds* rain. * no pixel jumps: `consistent`, the frame as it is; * fewer than `min_pixels` jump: `pixels_masked`, those pixels set to `NaN`; * more jump, and this frame is the higher: `rejected`, use the previous frame instead; * more jump, and this frame is the lower: `previous_wrong`, this frame as it is (it is the previous one that was corrupted); * different grids: `not_comparable`, the frame as it is. `max_step` is the caller's choice (150 mm is a good one for CUM frames 30 minutes apart). Measured on the benchmark of known cases, this rule passes 26 of 30 checks and, on 96 pairs of whole frames, rejects the 44 corrupted ones and no clean one. It cannot see an artefact that does not move between frames: `quality` adds the rules for that. #### `RainGrid.quality(previous: RainGrid | None = None, radar: RainGrid | None = None, *, max_step: float = 150.0, min_pixels: int = 5) -> Quality` What to trust in this frame, pixel by pixel, and why. `check` and three more rules in one answer (see `dpc_radar.quality`): values beyond the Italian record for the window, pixels far above their neighbours and, in a «Merging» frame, rain that the radar alone did not see where it sees well: a rain gauge gone wrong. `previous` is the frame one period before (`max_step` and `min_pixels` are for that comparison, as in `check`); `radar` is the radar-only rain over the same window, on its own grid (`dpc_radar.quality.radar_total` of the hourly SRT1 frames). Both are optional: a rule without what it needs is skipped. #### `RainGrid.discard_inconsistent(previous: RainGrid, *, max_step: float) -> tuple[RainGrid, int]` This frame without the pixels that moved more than `max_step`. The first rule, from October 2026, kept for comparison: it cannot tell which of the two frames is wrong, so it masks the pixels in both cases, and it lets through the edges of a corrupted bell (jumps under `max_step`). Prefer `check`. ### `class FrameCheck(verdict: Verdict, grid: RainGrid | None, jumps: int)` The answer of `RainGrid.check`. `grid` is the frame to use (with masked pixels for `pixels_masked`), or `None` when the frame is `rejected`. `jumps` is how many pixels moved more than `max_step`. # Archive ## `dpc_radar.archive` A local archive of the «Merging», and hourly rain corrected with the gauges. The DPC API keeps about five months of frames, then they are gone. The radar-only history (IT-DPC-SRI, `dpc_radar.history`) under-estimates: in Apulia in September 2016 it read between 10 % and 80 % of the rain gauges. The «Merging» is the correction with the gauges, and nobody archives it publicly: whatever is not saved in time is lost, one month at a time. Two products are kept, because the shortest «Merging» is three hours long: * `CUM3` at 00, 03, ..., 21 UTC: three-hour blocks that do not overlap, radar and gauges, 0.01° in EPSG:4326; * `SRT1` at every full hour: the radar-only rain of that hour, 1 km. The rain of one hour is SRT1 rescaled so that the three hours of a block add up exactly to the CUM3: the «Merging» says *how much*, the radar says *when*. If the radar saw nothing in a block (or missed an hour of it) and the gauges did, the block is split in equal parts; without CUM3, SRT1 stays as it is; without either, the hour is not measured (`None`), which is not the same as dry. Layout: `////
/_.tif`, plus `//absent.txt` with the frames the DPC no longer keeps. An archive written before this library, with `assenti.txt` in place of `absent.txt`, is read as is. Without a folder, `MergingArchive` reads `merging/` in the library's folder (`dpc_radar.local.default_directory`), where `dpc_radar.local.init` downloads. Whatever goes wrong with one frame stays with that frame: it is counted, or read as not there, and the reason goes to the `dpc_radar.archive` logger as a warning. Attach a handler to see which frames and why. ### `path(folder: Path, product: str, time: datetime) -> Path` Where a frame lives in the archive. ### `times(product: str, start: datetime, end: datetime) -> list[datetime]` The archived times of `product` in `[start, end]`, oldest first. ### `class ArchiveReport(downloaded: int = 0, present: int = 0, lost: int = 0, failed: int = 0, bytes: int = 0)` What one `archive` (or `dpc_radar.history.mirror`) run did. ### `async archive(folder: Path, radar: RadarClient, *, start: datetime, end: datetime, limit: int, newest_first: bool = False, now: datetime | None = None) -> ArchiveReport` Download the CUM3 and SRT1 frames of `[start, end]` that the archive lacks. Oldest first, because the oldest is the one the DPC will lose first; `newest_first` for a run that must keep up with the last hours before the `limit` is spent on old frames. Idempotent: a frame on disk is not downloaded again, and one the DPC no longer keeps is written to `absent.txt` and not asked again. A frame younger than `ABSENT_AFTER` that the API calls gone is not written down: it may just not be published yet. Stops after `limit` requests. A frame that fails for any other reason is counted, logged and retried on the next run. With a `send` hook on the client, a failure must surface as an `httpx.HTTPError`, a `DpcRadarError` or an `OSError` (`TimeoutError` is one) to count as one failed frame. Anything else is taken for a bug and ends the run. ### `class MergingArchive(folder: Path | None = None, *, cache_frames: int = 80)` Hourly rain corrected with the gauges, read from an archive on disk. Frames are kept in memory, `cache_frames` at most (an SRT1 frame is about 6.7 MB as float32): the same frames are read for every region of a run. One instance can be shared between threads: the cache is locked, and frames are decoded outside the lock. Without `folder`, `merging/` in the library's folder. #### `MergingArchive.read(product: str, time: datetime) -> RainGrid | None` One archived frame, or `None` if it is not there or not readable. #### `MergingArchive.hourly(points: list[tuple[float, float]], start: datetime, end: datetime) -> dict[datetime, list[float | None]]` Rain of every hour `(h-1, h]` in `(start, end]`, per lon/lat point (mm). ### `split_block(merging: float | None, radar: list[float | None], j: int) -> float | None` The share of hour `j` of a block in its «Merging» total. `radar` holds the SRT1 rain of each hour of the block. The «Merging» says how much, the radar says when; if the radar saw nothing, or missed an hour, the total is split in equal parts. # History (IT-DPC-SRI) ## `dpc_radar.history` Fifteen years of radar rain: the IT-DPC-SRI archive (2010-2025), read from disk. IT-DPC-SRI (Fondazione Bruno Kessler on DPC data, CC BY-SA 4.0, `doi:10.5281/zenodo.18637608 `_) is the national SRI mosaic, rain intensity in mm/h from the radar alone, as one Zarr v2 store: one chunk per time step, 1400 x 1200 pixels of 1 km in a Transverse Mercator projection centred on 42°N 12.5°E, a frame every 15 minutes until 2014, every 10 until 2020, every 5 after. It is published as a single 50 GB `.zarr.tar.zst`, served at about 0.1 MB/s: days. The same store is on ECMWF's object store (catalogue mlcast-datasets), anonymous, a frame in about 0.14 s: `mirror` copies it file by file in a few hours, and can stop and start again. Point `SriHistory` at the `.zarr` folder, either one; with no folder it reads `it_dpc_sri/` in the library's folder, where `dpc_radar.local.init(history=True)` puts the mirror. It is read here without zarr or xarray: the Blosc codec (extra `history`, `pip install "dpc-radar[history]"`) is enough to decompress a frame. It is the history the API does not give (it keeps only the last months), and it is radar only: it under-estimates heavy rain, so compare it with the «Merging» of `dpc_radar.archive` where both exist. An hour covered for less than half by frames is `None`, not measured: a gap in the archive is not a dry hour. Fewer than one frame in a thousand is corrupted (752 of 1,039,785): the whole disk of a radar filled with violent rain, or flat patches of one value over 100 mm/h (229 frames in 2011, 250 in 2014, 5 to 44 in the other years). `suspect` tells them from what rain looks like in the other million frames, and `SriHistory.hourly` reads them as missing. It does not catch everything: a single spike or a short ray of clutter passes, and the median of the 3x3 pixels is what softens those. It is not one series. Until 2017 the mosaic read less: the highest hour of the year is about two thirds of what it is since 2018 (the table is in `dpc_radar.climatology`). A threshold, a trend or a statistic that crosses 2018 compares two different instruments. ### `suspect(frame: np.ndarray) -> bool` Whether a frame in mm/h looks corrupted rather than rained on. In a storm the violent rain is a few pixels inside a much wider area of lighter rain. A frame is suspect when that is not so: at least 100 pixels at 100 mm/h or more that are over 5 % of the pixels with rain or over 70 % of those at 50 mm/h (a flat patch), or more than 2000 of them; or at least 200 pixels at 50 mm/h that are over 20 % of the pixels with rain. The thresholds stand on the one million frames of IT-DPC-SRI: they reject about one in a thousand. ### `class SriHistory(path: Path | None = None)` Hourly rain at lon/lat points from the IT-DPC-SRI Zarr store on disk. Without `path`, `it_dpc_sri/` in the library's folder. #### `SriHistory.pixel(points: list[tuple[float, float]]) -> list[tuple[int, int] | None]` (row, column) of each lon/lat point; `None` outside the grid. #### `SriHistory.frame(i: int) -> np.ndarray | None` Frame `i` of the store in mm/h (NaN for no data); `None` if its chunk is missing. #### `SriHistory.time(i: int) -> datetime` The time of frame `i`. #### `SriHistory.hourly(points: list[tuple[float, float]], start: datetime, end: datetime) -> dict[datetime, list[float | None]]` Rain of every hour `(h-1, h]` in `(start, end]`, per lon/lat point (mm). The mean of the intensities of the hour's frames, each weighted by the time it covers until the next one (15 minutes at most), read as the median of the 3x3 pixels around the point. A corrupted frame (`suspect`) is read as missing. The same signature as `dpc_radar.archive.MergingArchive.hourly`: the two are interchangeable. ### `async mirror(directory: Path, client: httpx.AsyncClient | None = None, *, retries: int = 3, concurrency: int = 32, start: int = 0, stop: int | None = None, base: str = SRI_STORE, backoff_s: float = 2.0, sleep: Callable[[float], Awaitable[Any]] = asyncio.sleep) -> ArchiveReport` Copy the IT-DPC-SRI store from ECMWF's object store into `directory`. The metadata and the coordinates first, then the frames `start` to `stop` (indices on the time axis: 179087 is the first of 2015), `concurrency` at a time. Safe to stop and run again: a file on disk is not downloaded twice, and a frame the store does not have (a 403 or 404) is written to `missing.txt` and not asked again. A file that fails is counted, logged and retried on the next run; a disk that cannot be written raises. `client` is used and left open; `retries=0` leaves the retrying to the caller. # ARCO Data Hub (2010 to now) ## `dpc_radar.arco` The DPC radar archive of the ARCO Data Hub: any frame since 2010, and the last one. The `ARCO Data Hub `_ (Fondazione Bruno Kessler on DPC data, for the IT4LIA AI Factory) keeps the national radar mosaics as Zarr stores that grow every five minutes: the history the DPC API does not give (it keeps about five months) and products it does not publish as open data. `ArcoClient` reads one frame at a time, as a `dpc_radar.grid.RainGrid`: ================ ========================================== ============ name what it is since ================ ========================================== ============ `SRI` rain intensity, mm/h 2010 `SRT1` rain of the last hour, mm July 2018 `VMI` highest reflectivity in the column, dBZ 2018 `CAPPI2`-`8` reflectivity at 2000 to 8000 m, dBZ 2018 to 2022 `VIL` liquid water in the column, mm (kg/m²) July 2018 `ETM` height of the echo top, m July 2018 `OPERA` `VMI` of Europe at 2 km, with the DPC's July 2024 ================ ========================================== ============ It is **not open like the DPC API**: it needs a free account and the subscription to each dataset, and it asks for fair use. The user name and the access key come from `ARCODATAHUB_USERNAME` and `ARCODATAHUB_ACCESS_KEY`, or from the arguments. The data are CC BY-SA 4.0: credit «FBK in cooperation with Dipartimento Protezione Civile Nazionale» (and OPERA for `OPERA`). It is read here without zarr or xarray: one request for a frame of `SRI` (a Zarr v2 store, one object per frame), two for the others (Zarr v3, 288 frames in one object: the index at its end, then the bytes of the frame). The codecs come with the extra `arco` (`pip install "dpc-radar[arco]"`). **What a value means.** Three states, as in the rest of the library: * a number: measured; * `NaN`: not measured (outside the radars' range, or a frame with a hole), `-9999` in the store; * *no echo*: measured, and nothing there (`-9998` in the store). It becomes `-inf` in a reflectivity (0 dBZ is a weak echo, not an absence) and `0` in a height or a quantity of water. **The traps.** * The time axis is not regular: `SRI` has a frame every 15 minutes in 2010, every 5 today; `SRT1` is hourly until July 2020. Ask `ArcoClient.times` which frames exist, never compute them from a step. * Before 30 April 2026 (and not in all of 2025) *no echo* in a reflectivity is written as 0 dBZ, which cannot be told from a weak echo: it stays 0. * `VIL` between August 2019 and October 2025 has no 0.5 bin in some frames: it was merged into 0 when two encodings were made one. * `SRT1` here is the same frame the DPC API serves as `SRT1`, pixel by pixel (checked on 30 hours of 2026). * `OPERA` is on another grid (2 km, ETRS89-LAEA) and is reflectivity, not rain: it does not compare with `SRI` as it is. * The frame of a time not yet published, or lost, is `None`: not an error. The client keeps the description of a store and its time axis in memory. With `cache` it also keeps them, and every frame it reads, in a folder: a frame on disk is not asked again. ### `class ArcoDataset(name: str, store: str, variable: str, product: Product, no_echo: float = 0.0)` One store of the hub, and what its frames become. ### `dataset(name: str | ArcoDataset) -> ArcoDataset` The `ArcoDataset` called `name`. ### `class Store(dataset: ArcoDataset, length: int, shape: tuple[int, int], shard: int, time_chunk: int, transform: Affine, crs: CRS, last_valid: datetime | None)` What the metadata of a store say: its grid, its layout, its last frame. #### `Store.frame_key(i: int) -> str` The object that holds frame `i`, under the store. #### `Store.time_keys() -> list[str]` The objects of the time axis, in order. ### `parse_store(payload: dict[str, Any], name: str | ArcoDataset) -> Store` A `Store` from the consolidated metadata of a store. `payload` is the `zarr.json` of a Zarr v3 store or the `.zmetadata` of a v2 one. A layout this module does not read (another codec, frames grouped in another way) raises `dpc_radar.errors.DpcRadarError`: better than a frame of noise. ### `index_range(store: Store) -> str` The `Range` of the index at the end of a sharded object. Sixteen bytes per frame (where it starts, how long it is) and four of checksum. ### `chunk_range(store: Store, index: bytes, i: int) -> str | None` The `Range` of frame `i` inside its object; `None` if the object does not hold it. ### `decode_frame(store: Store, raw: bytes) -> np.ndarray` The values of a frame from its compressed bytes: see the module for what they mean. ### `class ArcoClient(client: httpx.AsyncClient | None = None, *, username: str | None = None, key: str | None = None, send: Send | None = None, retries: int = 3, backoff_s: float = 2.0, timeout_s: float = 60.0, base: str = ARCO_BASE, cache: Path | None = None, sleep: Callable[[float], Awaitable[Any]] = asyncio.sleep)` The radar stores of the ARCO Data Hub, a frame at a time. `client`, `send`, `retries` and `backoff_s` are those of `dpc_radar.client.RadarClient`: your own `httpx.AsyncClient`, or your own HTTP layer, which then does the retrying. The credentials go with every request as HTTP Basic, never in the URL. #### `async ArcoClient.aclose() -> None` Close the HTTP client if this instance opened it. #### `async ArcoClient.store(name: str | ArcoDataset, *, refresh: bool = False) -> Store` The description of a store; read once, and again with `refresh`. #### `async ArcoClient.last(name: str | ArcoDataset) -> datetime` The time of the newest frame of a store, asked again at every call. #### `async ArcoClient.times(name: str | ArcoDataset, start: datetime, end: datetime) -> list[datetime]` The times of the frames from `start` to `end`, both included. Only frames already written: nothing after the last one the store knew of when this client read its description (`last` reads it again). #### `async ArcoClient.frame(name: str | ArcoDataset, time: datetime) -> RainGrid | None` The frame of `time` (aware); `None` if the store has no frame at that time. #### `async ArcoClient.frames(name: str | ArcoDataset, start: datetime, end: datetime, *, limit: int = MAX_FRAMES) -> list[RainGrid]` The frames from `start` to `end`, both included, the oldest first. A frame the store lost is left out. More than `limit` frames raise before anything is downloaded: the hub asks to be told before a large pull, and a year asked by mistake is 100,000 frames. # Data folder and init ## `dpc_radar.local` Where the library keeps its data on disk, and `init`, which fills it. The folder is, in this order: 1. the one the caller passes; 2. `$DATA_ROOT/dpc-radar`: `DATA_ROOT` is the root shared with Limen and the other libraries of agent-engineering-studio, each in a folder of its own; 3. `$XDG_CACHE_HOME/dpc-radar`, or `~/.cache/dpc-radar`. Inside it: * `merging/`: the «Merging» frames, as `dpc_radar.archive.archive` writes them and `dpc_radar.archive.MergingArchive` reads them; * `it_dpc_sri/`: the IT-DPC-SRI Zarr store, as `dpc_radar.history.mirror` writes it and `dpc_radar.history.SriHistory` reads it. About 51 GB: `init` downloads it only when asked. ### `default_directory() -> Path` The library's folder when the caller names none: see the module. ### `merging_directory(directory: Path | None = None) -> Path` Where the «Merging» frames live, under `directory` or the default folder. ### `history_directory(directory: Path | None = None) -> Path` Where the IT-DPC-SRI store lives, under `directory` or the default folder. ### `class InitReport(merging: ArchiveReport, history: ArchiveReport | None = None)` What one `init` run did: the «Merging», and the history if it was asked. ### `async init(directory: Path | None = None, *, days: int = 2, history: bool = False, client: httpx.AsyncClient | None = None, retries: int = 3, concurrency: int = 32, now: datetime | None = None) -> InitReport` Download what the library needs to work offline into `directory`. The «Merging» frames of the last `days` (about 35 MB a day) into `merging/`; with `history`, the IT-DPC-SRI store (2010-2025, about 51 GB) into `it_dpc_sri/`, `concurrency` files at a time. Safe to run again: a file on disk is not downloaded twice, and one the source no longer has is written down and not asked again. Files are written as `.part` and renamed. A file that fails is counted in the report and retried on the next run; a disk that cannot be written raises. `client` is used for every request and left open; `retries=0` leaves the retrying to the caller. # Reliability map ![The reliability map and its three parts](../images/reliability.png) ## `dpc_radar.reliability` Where the radar can be trusted: a static map of Italy, one value per km. A radar that reads zero is not always a dry sky. Far from the sites the beam passes kilometres above the ground, behind a mountain it is cut, and some radars are off for weeks: there the mosaic shows little or nothing while it rains. On 10 October 2026 it missed a cloudburst on Lipari this way. `reliability` answers "how much can I trust the radar here?" with a score between 0 and 1 and the parts it is made of: * `visibility`: how low the radar sees. From the sites (`SITES`) and a terrain model, the height above the ground of the lowest beam that reaches the point without being cut by a mountain (`beam_height`, metres): 1 up to 1500 m, 0 from 5000 m, where the beam passes above most of the rain; * `coverage`: the share of the hourly frames in which the mosaic has data at the point (the radars that cover it were on). Where the mosaic never has data, as in the west of Sicily, it is 0 and so is the score; * `agreement`: how close the radar alone (SRT1) is to the «Merging» of radar and rain gauges (CUM3) over the same months, as the smaller of the two ratios. `None` where too little rain fell to tell, over the open sea, where there are no gauges to compare with, and around a rain gauge that reports rain under a dry radar most of the time (near Foggia, in 504 of 573 wet windows): such a gauge says nothing about the radar. A window in which a gauge went wrong (the `gauge_only` rule of `dpc_radar.quality`) is left out around it, as in `dpc_radar.bias`. The score is the lowest of the parts that are known: a point is as good as its weakest side. `visibility` is drawn with every radar on; the months a radar was off are in `coverage`. Below `RELIABLE_FROM` a radar zero must not be read as "dry". The map ships with the package as a small GeoTIFF on the 1 km grid of the radar mosaic; `tools/build_reliability.py` builds it again. It is an estimate made from outside: the DPC does not publish a quality map, nor the position of the gauges that enter the «Merging» (so the density of gauges, which would be a fourth part, is not here). `coverage` and `agreement` describe the months the map was built on (see `ReliabilityMap.built_on`), not for ever. ### `class RadarSite(name: str, lon: float, lat: float, altitude: float, band: Literal['C', 'X'], range_km: float, source: Literal['dpc', 'mosaic', 'literature'], code: str | None = None)` One radar of the national network. `source` says where the position comes from: `"dpc"` the Department's own table; `"mosaic"` the range circle fitted on the no-data mask of the mosaic (within about 1 km); `"literature"` a published table, for radars whose circle is always hidden under the others. `range_km` is the radius of the circle in the mosaic (`"literature"` sites: assumed). `code` is the name the DPC gives the radar in its status file (`dpc_radar.status`); `None` if the file does not list it. ### `class Reliability(score: float | None, visibility: float | None, coverage: float | None, agreement: float | None, beam_height: float | None, nearest_site: str, distance_km: float)` How much to trust the radar at a point. Every part is 0-1 or `None` (not known). #### `Reliability.reliable: bool | None` Can a reading here be trusted? `None` outside the map. ### `class ReliabilityMap(score: np.ndarray, visibility: np.ndarray, coverage: np.ndarray, agreement: np.ndarray, beam_height: np.ndarray, transform: Affine, crs: CRS, built_on: str)` The map as arrays on the 1 km grid of the mosaic (NaN: not known). #### `ReliabilityMap.at(lon: float, lat: float) -> Reliability` The reliability at a point; all `None` outside the mosaic. #### `ReliabilityMap.like(grid: RainGrid, part: Part = 'score') -> np.ndarray` The score (or another `part` of the map) on the pixels of `grid`. Any product: 1 km or 0.01°. NaN where not known. ### `reliability_map() -> ReliabilityMap` The map shipped with the package (read once). ### `reliability(lon: float, lat: float) -> Reliability` How much to trust the radar at a point: a score and its parts. ### `nearest_site(lon: float, lat: float) -> tuple[RadarSite, float]` The nearest radar and its distance in km along the great circle. # Radar status Which radars the DPC viewer shows as on, at a time. Use it to explain why a place has no data; do not use it to say that the data are good. ```python from dpc_radar import RadarClient async with RadarClient() as radar: status = await radar.radar_status() # the newest, or radar_status(time) if status: # ABSENT: not known print(status.time, [r.code for r in status.off]) print(status.of("Monte Lauro")) # True, False, or None: not in the file ``` ```bash dpc-radar sites # a table, now dpc-radar sites --time 2026-11-17T12:00 # at a time (UTC), for about two weeks back dpc-radar sites --out sites.geojson # as GeoJSON ``` **Read this before you rely on it.** - The file is the one the DPC radar viewer reads. It is public, but it is not documented, it has no licence, and its address may change without notice. When it is not there, the answer is `ABSENT`: not known. - It is a hint. On 17 November 2026 the two radars reported off in the south (Monte Lauro, Monte Pettinascura) were indeed missing from the mosaic. But Milano Linate was reported off for two weeks while the mosaic had data over its whole circle, and Catania was reported on while its circle had none. - It names three radars that are not in `SITES` (Reggio Calabria, Desio, Flero): nothing in the mosaic shows that they feed it. They are listed with `site` empty. Salento is in `SITES` and not in the file. - Its positions are rounded and some altitudes differ from those of `SITES`, which are kept: `RadarStatus.site` links the two through `RadarSite.code`. - Files are kept for about two weeks, one every five minutes. ## `dpc_radar.status` Which radars are on: the status file behind the DPC's own viewer. The mosaic is made of some two dozen radars, and at any hour a few are off. Where the only radar that covers a place is off, the mosaic has no data there while it may be raining. The viewer of the DPC (`radar.protezionecivile.gov.it`) draws the radars as green and red dots; it reads them from a small GeoJSON file, one every five minutes, kept for about two weeks. This module reads the same file:: async with RadarClient() as radar: status = await radar.radar_status() [r.code for r in status.off] Pure: nothing here does I/O. `dpc_radar.RadarClient.radar_status` sends the request built by `status_url` and hands the answer to `parse_status`. What to know before trusting it: * **The file is not part of the documented open data.** It has no licence and no promise: its address or its shape can change without notice. When it cannot be read the client answers `dpc_radar.ABSENT`, and nothing else in the library depends on it. * **The time is the one asked for.** The `time` inside the file is stale (in November 2026 it still said November 2025) and is ignored. * **"On" is what the DPC reports, not what the mosaic holds.** On 17 November 2026 Linate was reported off for two weeks while its whole circle had data, and Catania was reported on while its circle had none. Monte Lauro and Monte Pettinascura, reported off, were indeed missing. Read `on` as a hint to why a place has no data, never as proof that it has. * The file lists three radars that are not in `dpc_radar.SITES` (Reggio Calabria, Desio and Flero): no trace of them was found in the mosaic. Their `site` is `None`. Salento is in `SITES` and not in the file. ### `class RadarStatus(code: str, place: str, province: str, operator: str, lon: float, lat: float, altitude: float | None, on: bool, site: RadarSite | None)` One radar as the status file has it. ### `class NetworkStatus(time: datetime, radars: tuple[RadarStatus, ...])` The radars of the network at a time, on and off. #### `NetworkStatus.off: tuple[RadarStatus, ...]` The radars reported off. #### `NetworkStatus.of(site: RadarSite | str) -> bool | None` Is a radar on? By its site, its name in `SITES` or its DPC code. `None` if the file does not list it: not known, which is not "off". #### `NetworkStatus.geojson() -> dict[str, Any]` The status as a GeoJSON `FeatureCollection` of points (WGS84). ### `status_time(time: datetime) -> datetime` The time of the file that covers `time` (aware): the five minutes it falls in. ### `status_url(time: datetime, *, base: str = STATUS_BASE) -> str` The address of the status file of `time` (aware). ### `parse_status(payload: dict[str, Any], time: datetime) -> NetworkStatus` The status in a file; `DpcRadarError` if it is not the file we know. The file is the head of a table and repeats the radars: the first row of each is kept (the repeated rows were never seen to disagree). # Frame quality ## `dpc_radar.quality` What to trust in a frame, pixel by pixel, and why. `dpc_radar.RainGrid.quality` looks at a frame from four sides. Each one is a rule a person can check, with a threshold measured on the frames kept from June to November 2026, and each names the pixels it does not trust: * `jump`: the frame against the one before it (`RainGrid.check`). The only side that can reject the whole frame; it needs `previous`; * `beyond_record`: more rain than was ever measured in Italy over the same window (`RECORDS`, with a margin). It needs nothing, so it also works on the first frame; * `outlier`: a pixel far above the 5x5 pixels around it, measured with their median and their spread (MAD): a hot pixel, not a storm; * `gauge_only`: in a «Merging» frame, rain that the radar alone did not see at all, at a place where the radar sees well. It needs `radar`, the radar-only rain over the same window. That is a rain gauge reporting rain under a dry sky: on 6-8 October 2026 one of them put 126.6 mm in every three-hour frame for 33 hours on the Lazio-Abruzzo border. There is no trained model here. Fourteen labelled cases are too few to train one, and a rule that can be read is worth more than a model that cannot be checked: the rules above are the features a model would use, when the labels exist. Two features of the first plan are missing because we have no confirmed case to measure them on: radial symmetry around a radar and rain over the sea against the nearby land. The one case we had, the "disks" west of Sardinia of 20 October 2026, turned out to be rain. What it cannot see: a wrong value that is plausible, moves like rain and agrees with the radar; a gauge that fails where the radar is blind (there the gauge is all we have, and it is kept); a gauge that reads too little. ### `class Quality(grid: RainGrid | None, mask: np.ndarray, reasons: dict[str, int], score: float, verdict: Verdict | None)` The answer of `RainGrid.quality`. `grid` is the frame to use, with the pixels of `mask` set to `NaN`; `None` when the whole frame is rejected. `mask` is `True` where a pixel that had a value is not trusted. `reasons` counts those pixels by the rule that named them (a pixel can be under more than one). `score` is the share of the wet pixels that are trusted: 1 for a clean frame, 0 for a rejected one. `verdict` is the answer of the comparison with the frame before, `None` without one. ### `record_ceiling(hours: int | None) -> float | None` The value no frame of this window should pass (mm); `None` for an intensity. ### `radar_total(frames: list[RainGrid]) -> RainGrid` The radar-only rain over a window: the sum of its hourly `SRT1` frames. For a CUM3 issued at `t`, the frames of `t`, `t - 1 h` and `t - 2 h`. Where one hour has no data, the sum has none (`NaN`). Pass every hour of the window: with one missing the sum is short, and rain the radar did see would look like rain it did not. ### `quality(grid: RainGrid, previous: RainGrid | None, radar: RainGrid | None, *, max_step: float, min_pixels: int) -> Quality` See `dpc_radar.RainGrid.quality`. # Radar bias ## `dpc_radar.bias` How far the radar alone is from the «Merging», place by place, and a factor for it. The radar measures an echo, not rain. Summed over the months from June to November 2026 it reads 20 % more rain than the «Merging» of radar and rain gauges (33 % more on land), and it passes 30 mm in three hours 70 % more often. Not everywhere in the same direction: around Rome, Genoa and Milan it reads 1.6-1.7 times the «Merging», around Palermo less than half of it. `bias_map` is the ratio «Merging» / radar at every km of land where the two can be compared: the rain of CUM3 over the rain of the three `SRT1` hours of the same window, both summed over the months and over 9 km. `correct` multiplies a radar-only frame by it. The map ships with the package; `tools/build_bias.py` builds it again and measures it. What the measure says (every month corrected with the map of the other months, against CUM3, three-hour windows with at least 1 mm): the mean error goes from 1.91 to 1.55 mm, the total from 1.20 to 1.00 of the «Merging», and 30 mm is passed 0.89 times as often as in the «Merging» instead of 1.70. One factor for the whole of Italy does not reduce the error at all: the bias is local. What it does not do, and where it is 1 (no correction): * it does not find rain the radar did not see: zero times a factor is zero. Where the radar is blind (`dpc_radar.reliability`) it stays blind; * it corrects how much, not where: on land the correlation with the «Merging» stays at 0.72; * it lowers heavy rain: where the «Merging» has 30 mm or more, the radar alone reads 0.91 of it and the corrected radar 0.75. In July and August, the months of the storms, the corrected radar passes 30 mm half to two thirds as often as the «Merging». Use it for totals and for how often a threshold is passed over a season, not for the peak of one storm; * in Sicily it helps little (mean error from 3.58 to 3.45 mm): the radar sees the west of the island badly, and a factor cannot repair that. No factor is above `FACTOR_MAX`; * over the sea there are no gauges, and the «Merging» is the radar: factor 1; * where a rain gauge reports rain under a dry sky most of the time (near Foggia one did so in 504 of 573 wet windows) the comparison says nothing: factor 1, on 2,660 km² in all. The `agreement` of `dpc_radar.reliability` is not known there, for the same reason; * the «Merging» contains the radar: it is the best field there is, not an independent truth; * it describes the months it was built on (`BiasMap.built_on`). The hour of the day changes nothing (the ratio stays within 1.18-1.23); the month does (1.11-1.33), and the map does not follow it. It was measured on windows of three hours: on one hour or on an intensity it is an assumption; * it is not applied to the 2010-2025 history (`dpc_radar.history`): the radars, their calibration and the mosaic changed over those years, and there is no «Merging» of those years to test it on. A model with more inputs (gradient boosting on place, beam height, hour and month) had about the same mean error and was not kept: it passed 50 mm 0.40 times as often as the «Merging» and almost never 100 mm. A corrected field that cannot rain hard is of no use to a warning system. ### `class BiasMap(factor: np.ndarray, transform: Affine, crs: CRS, built_on: str)` The factor «Merging» / radar on the 1 km grid of the mosaic (NaN outside it). #### `BiasMap.at(lon: float, lat: float) -> float | None` The factor at a point: 1.0 where there is nothing to correct with, `None` outside. #### `BiasMap.like(grid: RainGrid) -> np.ndarray` The factor on the pixels of `grid` (1.0 where the map has none). ### `bias_map() -> BiasMap` The map shipped with the package (read once). ### `radar_factor(lon: float, lat: float) -> float | None` What to multiply the radar-only rain by at a point to bring it to the «Merging». ### `correct(grid: RainGrid) -> RainGrid` A radar-only frame (SRI, SRT1) brought towards the «Merging»: the frame times the factor. The same product, time and grid. A «Merging» frame already has the gauges in it: correcting it again would be an error, and is refused. ## The measure, in full `uv run python -m tools.build_bias --archive --dem --measure` on the frames kept from 9 June to 16 November 2026. Every month is corrected with the map built on the other months and compared with the «Merging» (`CUM3`) on the three-hour windows in which either has at least 1 mm, away from the rain gauges gone wrong. - **MAE**: the mean error in mm; **total**: the rain of the estimate over the rain of the «Merging»; **correlation**: between the two, pixel by pixel. - **≥ N mm**: how often the estimate passes N mm, over how often the «Merging» does (1 is right, 2 is twice as often); in brackets how well the two agree on where and when (CSI: 1 is always, 0 is never). - The last column: where the «Merging» has 30 mm or more, the rain of the estimate over the rain of the «Merging». "Land" is where at least a quarter of the 9 km around a pixel is land, abroad too. The radar is "reliable" where the [reliability map](reliability.md) scores 0.5 or more. | | | MAE (mm) | total | correlation | ≥ 10 mm | ≥ 30 mm | ≥ 50 mm | ≥ 100 mm | rain where the «Merging» has ≥ 30 mm | |---|---|---|---|---|---|---|---|---|---| | everywhere | radar alone | 1.91 | 1.20 | 0.78 | 1.31 (0.57) | 1.70 (0.34) | 1.81 (0.27) | 1.92 (0.26) | 0.91 | | everywhere | one factor for Italy | 1.94 | 0.99 | 0.78 | 0.96 (0.50) | 0.94 (0.28) | 0.87 (0.24) | 0.70 (0.19) | 0.75 | | everywhere | factor map | 1.55 | 1.00 | 0.81 | 0.97 (0.60) | 0.89 (0.38) | 0.84 (0.32) | 0.80 (0.40) | 0.75 | | land | radar alone | 2.72 | 1.33 | 0.72 | 1.52 (0.44) | 2.04 (0.24) | 2.19 (0.18) | 2.90 (0.12) | 0.89 | | land | one factor for Italy | 2.42 | 1.10 | 0.72 | 1.14 (0.43) | 1.15 (0.24) | 1.04 (0.18) | 1.07 (0.13) | 0.73 | | land | factor map | 2.15 | 0.99 | 0.72 | 0.95 (0.45) | 0.82 (0.24) | 0.74 (0.18) | 0.68 (0.15) | 0.65 | | sea | radar alone | 0.46 | 1.01 | 0.96 | 1.01 (0.87) | 1.03 (0.75) | 1.04 (0.67) | 0.91 (0.72) | 0.95 | | sea | one factor for Italy | 1.08 | 0.83 | 0.96 | 0.70 (0.64) | 0.52 (0.43) | 0.53 (0.42) | 0.33 (0.30) | 0.78 | | sea | factor map | 0.46 | 1.01 | 0.96 | 1.01 (0.87) | 1.03 (0.75) | 1.04 (0.67) | 0.91 (0.72) | 0.95 | | north (from 44°N) | radar alone | 2.20 | 1.29 | 0.76 | 1.46 (0.50) | 1.88 (0.28) | 2.24 (0.21) | 2.93 (0.15) | 0.93 | | north (from 44°N) | one factor for Italy | 2.03 | 1.07 | 0.76 | 1.08 (0.47) | 1.10 (0.28) | 1.14 (0.20) | 1.02 (0.14) | 0.77 | | north (from 44°N) | factor map | 1.74 | 0.98 | 0.77 | 0.92 (0.50) | 0.76 (0.28) | 0.73 (0.21) | 0.61 (0.16) | 0.68 | | centre (41.5-44°N) | radar alone | 3.61 | 1.46 | 0.67 | 1.70 (0.38) | 2.08 (0.20) | 2.05 (0.14) | 3.31 (0.10) | 0.83 | | centre (41.5-44°N) | one factor for Italy | 3.09 | 1.21 | 0.67 | 1.31 (0.38) | 1.14 (0.19) | 0.97 (0.15) | 1.55 (0.14) | 0.68 | | centre (41.5-44°N) | factor map | 2.70 | 1.02 | 0.67 | 0.98 (0.39) | 0.68 (0.19) | 0.66 (0.16) | 1.01 (0.20) | 0.59 | | south (below 41.5°N) | radar alone | 3.68 | 1.38 | 0.67 | 1.59 (0.37) | 2.85 (0.16) | 2.43 (0.12) | 2.25 (0.00) | 0.83 | | south (below 41.5°N) | one factor for Italy | 3.12 | 1.13 | 0.66 | 1.22 (0.37) | 1.54 (0.17) | 0.82 (0.15) | 0.45 (0.00) | 0.68 | | south (below 41.5°N) | factor map | 2.94 | 1.00 | 0.64 | 0.99 (0.36) | 1.18 (0.16) | 0.76 (0.11) | 0.16 (0.00) | 0.60 | | Sicily | radar alone | 3.58 | 1.02 | 0.62 | 1.13 (0.36) | 1.71 (0.20) | 1.28 (0.10) | 0.35 (0.00) | 0.69 | | Sicily | one factor for Italy | 3.22 | 0.84 | 0.62 | 0.88 (0.35) | 0.87 (0.19) | 0.41 (0.08) | 0.16 (0.00) | 0.56 | | Sicily | factor map | 3.45 | 0.96 | 0.60 | 1.03 (0.36) | 1.40 (0.15) | 1.12 (0.06) | 0.58 (0.00) | 0.61 | | Sardinia | radar alone | 2.54 | 1.25 | 0.77 | 1.35 (0.45) | 2.25 (0.24) | 2.96 (0.18) | 9.31 (0.02) | 1.01 | | Sardinia | one factor for Italy | 2.20 | 1.03 | 0.77 | 1.00 (0.44) | 1.28 (0.27) | 1.30 (0.20) | 0.92 (0.00) | 0.82 | | Sardinia | factor map | 2.10 | 0.98 | 0.77 | 0.94 (0.45) | 1.07 (0.27) | 1.25 (0.21) | 0.85 (0.00) | 0.79 | | land, radar reliable (score from 0.5) | radar alone | 2.76 | 1.32 | 0.73 | 1.49 (0.45) | 1.97 (0.24) | 2.21 (0.17) | 3.50 (0.10) | 0.89 | | land, radar reliable (score from 0.5) | one factor for Italy | 2.45 | 1.09 | 0.72 | 1.12 (0.44) | 1.11 (0.24) | 1.06 (0.18) | 1.28 (0.12) | 0.74 | | land, radar reliable (score from 0.5) | factor map | 2.21 | 1.00 | 0.72 | 0.95 (0.45) | 0.80 (0.23) | 0.75 (0.17) | 0.77 (0.12) | 0.65 | | land, radar not reliable | radar alone | 2.38 | 1.37 | 0.63 | 1.90 (0.34) | 2.94 (0.18) | 1.98 (0.22) | 0.72 (0.33) | 0.81 | | land, radar not reliable | one factor for Italy | 2.19 | 1.13 | 0.63 | 1.44 (0.33) | 1.68 (0.19) | 0.80 (0.23) | 0.33 (0.16) | 0.67 | | land, radar not reliable | factor map | 1.65 | 0.97 | 0.69 | 0.95 (0.38) | 1.03 (0.27) | 0.69 (0.32) | 0.38 (0.32) | 0.64 | | «Merging» under 10 mm | radar alone | 1.59 | 1.33 | 0.55 | - | - | - | - | - | | «Merging» under 10 mm | one factor for Italy | 1.52 | 1.10 | 0.54 | - | - | - | - | - | | «Merging» under 10 mm | factor map | 1.19 | 1.10 | 0.62 | - | - | - | - | - | | «Merging» 10-30 mm | radar alone | 4.10 | 1.04 | 0.50 | 0.83 (0.83) | - | - | - | - | | «Merging» 10-30 mm | one factor for Italy | 4.80 | 0.85 | 0.50 | 0.63 (0.63) | - | - | - | - | | «Merging» 10-30 mm | factor map | 3.92 | 0.88 | 0.51 | 0.72 (0.72) | - | - | - | - | | «Merging» 30-50 mm | radar alone | 9.35 | 0.93 | 0.28 | 0.97 (0.97) | 0.64 (0.64) | - | - | 0.93 | | «Merging» 30-50 mm | one factor for Italy | 11.86 | 0.76 | 0.28 | 0.95 (0.95) | 0.35 (0.35) | - | - | 0.76 | | «Merging» 30-50 mm | factor map | 10.98 | 0.76 | 0.25 | 0.93 (0.93) | 0.48 (0.48) | - | - | 0.76 | | «Merging» from 50 mm | radar alone | 17.36 | 0.86 | 0.53 | 0.98 (0.98) | 0.87 (0.87) | 0.59 (0.59) | 1.32 (0.36) | 0.86 | | «Merging» from 50 mm | one factor for Italy | 22.99 | 0.71 | 0.53 | 0.98 (0.98) | 0.79 (0.79) | 0.36 (0.36) | 0.52 (0.22) | 0.71 | | «Merging» from 50 mm | factor map | 21.56 | 0.72 | 0.53 | 0.96 (0.96) | 0.72 (0.72) | 0.45 (0.45) | 0.69 (0.43) | 0.72 | | 2026-06 | radar alone | 2.50 | 1.33 | 0.81 | 1.43 (0.54) | 2.01 (0.34) | 2.27 (0.28) | 3.00 (0.18) | 1.05 | | 2026-06 | one factor for Italy | 2.27 | 1.10 | 0.81 | 1.13 (0.52) | 1.30 (0.34) | 1.27 (0.27) | 1.38 (0.18) | 0.87 | | 2026-06 | factor map | 1.83 | 1.04 | 0.84 | 1.02 (0.58) | 1.06 (0.41) | 1.02 (0.36) | 0.96 (0.33) | 0.84 | | 2026-07 | radar alone | 1.97 | 1.18 | 0.77 | 1.25 (0.52) | 1.41 (0.29) | 1.94 (0.14) | 20.58 (0.02) | 0.85 | | 2026-07 | one factor for Italy | 1.92 | 0.97 | 0.77 | 0.91 (0.47) | 0.78 (0.25) | 0.98 (0.13) | 6.62 (0.03) | 0.71 | | 2026-07 | factor map | 1.61 | 0.94 | 0.78 | 0.81 (0.51) | 0.65 (0.28) | 0.71 (0.16) | 1.29 (0.00) | 0.64 | | 2026-08 | radar alone | 2.20 | 1.22 | 0.78 | 1.34 (0.50) | 1.48 (0.27) | 1.93 (0.17) | 0.94 (0.21) | 0.84 | | 2026-08 | one factor for Italy | 2.06 | 1.01 | 0.78 | 1.00 (0.47) | 0.77 (0.24) | 0.74 (0.15) | 0.23 (0.07) | 0.70 | | 2026-08 | factor map | 1.77 | 0.94 | 0.78 | 0.84 (0.50) | 0.52 (0.24) | 0.39 (0.12) | 0.13 (0.00) | 0.61 | | 2026-09 | radar alone | 2.12 | 1.17 | 0.78 | 1.26 (0.57) | 1.55 (0.31) | 1.54 (0.21) | 1.63 (0.06) | 0.86 | | 2026-09 | one factor for Italy | 2.10 | 0.96 | 0.78 | 0.93 (0.50) | 0.91 (0.28) | 0.74 (0.18) | 0.68 (0.03) | 0.70 | | 2026-09 | factor map | 1.75 | 0.94 | 0.78 | 0.90 (0.58) | 0.70 (0.28) | 0.56 (0.17) | 0.64 (0.04) | 0.64 | | 2026-10 | radar alone | 1.60 | 1.11 | 0.83 | 1.19 (0.63) | 1.44 (0.41) | 1.19 (0.43) | 1.16 (0.53) | 0.88 | | 2026-10 | one factor for Italy | 1.78 | 0.89 | 0.83 | 0.84 (0.52) | 0.69 (0.30) | 0.50 (0.33) | 0.41 (0.32) | 0.71 | | 2026-10 | factor map | 1.35 | 0.94 | 0.86 | 0.91 (0.64) | 0.84 (0.47) | 0.73 (0.46) | 0.80 (0.63) | 0.78 | | 2026-11 | radar alone | 1.85 | 1.26 | 0.74 | 1.44 (0.57) | 2.35 (0.34) | 2.86 (0.26) | 2.35 (0.24) | 0.99 | | 2026-11 | one factor for Italy | 1.92 | 1.06 | 0.74 | 1.06 (0.49) | 1.34 (0.27) | 1.43 (0.25) | 0.70 (0.15) | 0.83 | | 2026-11 | factor map | 1.46 | 1.10 | 0.81 | 1.16 (0.63) | 1.44 (0.48) | 1.58 (0.38) | 0.95 (0.40) | 0.92 | # Rain climatology ![Three maps of Italy: the rain of 24 hours passed once in ten years, and the return period of the rain of the 24 hours to 2 November 2026 read on the radar alone and on the Merging](../images/climatology.png) ## `dpc_radar.climatology` How rare is this rain, here? A rain climatology of Italy from eight years of radar. Fifty millimetres in an hour are a storm of every summer in Genoa and a rare one in Bari. `rarity` says how rare a rain is at a place, for a window of 1, 3, 6 or 24 hours:: from dpc_radar import rarity, return_level, return_period rarity(24, 8.93, 44.41, 100.0).return_period # 1.7 Genoa: most years rarity(24, 16.87, 41.12, 100.0) # Bari: 32 years, between 9 and 50 or more return_level(24, 8.93, 44.41, 10) # Level(mm=203.1, low=166.6, high=264.1) years = return_period(srt1) # the return period of every pixel of a frame Two answers, in a `Rarity`: * `percentile`: the share of the windows of those years with less rain (99.9: one window in a thousand had more). It counts, it assumes nothing, and it stops at 99.99. * `return_period`: once in how many years the highest window of the year passes that rain, from a GEV distribution fitted to the highest window of each year, with the 90 % interval of the fit (`low`, `high`). It is 1 for the rain of every year and stops at `MAX_RETURN_YEARS`. `return_level` is the same read backwards: the millimetres of a return period. `return_period` does it for every pixel of an accumulation frame. **What it is made of.** The IT-DPC-SRI history (`dpc_radar.history`), from 2018 to 2025: the rain of every hour at 1 km, without the corrupted frames, summed over the windows that end at every hour. The map ships with the package (1.6 MB) in cells of 5 km: about 35,000 cells with a fit, wherever the mosaic has data in at least six of the eight years. In every cell the location of the GEV is the mean of its pixels, the spread over the location is the one of the 55 km around it, and the shape is one for the whole of Italy (0.20 for 1 h, 0.19 for 3 h, 0.17 for 6 h, 0.13 for 24 h): eight values a pixel cannot say more. `tools/build_climatology.py` builds it and measures it. **Why eight years and not sixteen.** The history is not one series. The highest hour of the year, over the location of the fit, has a median of 0.64 to 0.90 in the years 2010-2017 (1.14 in 2014, the year with most corrupted frames) and of 1.09 to 1.35 since 2018: until 2017 the mosaic read about two thirds of what it reads now. A fit on all the years puts 61 % of the pixels over their 2-year level in five months of 2026. So the map stands on the years that read like today, and pays for it with a wider doubt. **How far to trust it** (measured; the tables are in the reference): * Fitted on six years and asked about the other two, the levels are passed more often than they say: the 2-year level by 52 % of the pixels in a year (it should be 50), the 5-year by 24 % (20), the 10-year by 14 % (10), the 20-year by 8 % (5). What it calls "10 years" came about every 7, "20 years" every 13. Beyond that nothing can be checked with eight years: 50 years is an extrapolation, and no number is given further. * On the hourly radar frames of June-November 2026 (`SRT1`), which it was not built on, the 10-year level of 1 h was passed in five months by 12 % of the pixels, about what a held-out year does; the one of 24 h by 20 %: on long windows the frames of 2026 read more than the history. * The interval is the doubt of eight years only (the years drawn again, a hundred times). It does not know the errors of the radar. **It is in radar millimetres.** The history is radar alone, and the radar alone is not a rain gauge: in 2026 it read 20 % more rain than the «Merging» (`dpc_radar.bias`), much more in some places, less in others. So: * do not compare these levels with those of rain gauges (the official depth-duration-frequency curves): in the Po valley the radar reads 60 mm in an hour once in ten years; * on a radar-only frame (`SRT1`, `dpc_radar.radar_total`) the return period inherits the faults of the frame: in the 24 hours to 2 November 2026 09:00 UTC the radar alone was over the 10-year level on 35,000 km², the «Merging» on 19,000, and the highest radar pixel (382 mm) had 7 mm in the «Merging». Clean the frame first (`dpc_radar.RainGrid.quality`) and look at `dpc_radar.reliability`; * on a «Merging» frame (`CUM3`, `CUM6`, `CUM24`) the answer leans to "less rare" where the radar reads more than the gauges, which is most of the land. Where the radar is blind the map has less rain than falls, and outside the mosaic it has nothing (`None`, NaN). What the cleaning of the history did not catch is in the map: a ray of clutter west of the radar of Sicily shows in it. It is not a design rainfall and it does not replace the official alert. ### `class Level(mm: float, low: float, high: float)` The rain of a return period at a place, in mm, with its 90 % interval. ### `class Rarity(window: int, mm: float, return_period: float | None, low: float | None, high: float | None, percentile: float | None, years: int)` How rare `mm` of rain in `window` hours are at a place. `return_period` is in years, between 1 ("every year") and `MAX_RETURN_YEARS` ("that or more"); `low` and `high` are its 90 % interval. `percentile` is the share of the windows of those years with less rain, between 90 ("90 or less") and 99.99 ("that or more"). All `None` where the climatology has no data. ### `class Climatology(parts: dict[int, dict[str, np.ndarray]], transform: Affine, crs: CRS, built_on: str)` The climatology as arrays on a grid of 5 km cells (NaN: not known). `parts[window][band]` for every window of `WINDOWS` and band of `BANDS`: the GEV of the highest window of the year (`loc` and `scale` in mm, `shape` positive for a heavy tail), the `years` it stands on, the percentiles in mm, and the 90 % interval of the 2- and 50-year levels as ratios to the level of the fit. #### `Climatology.level(window: int, lon: float, lat: float, years: float) -> Level | None` The rain in `window` hours passed once in `years` years at a point. `years` between 1 (not included) and `MAX_RETURN_YEARS`; `None` where the climatology has no data. #### `Climatology.rarity(window: int, lon: float, lat: float, mm: float) -> Rarity` How rare `mm` of rain in `window` hours are at a point. #### `Climatology.like(grid: RainGrid, window: int | None = None) -> np.ndarray` The return period, in years, of the rain of every pixel of an accumulation frame. The window is the one of the product (`SRT1`: 1 h, `CUM3`: 3 h, ...) unless `window` says how many hours the millimetres of the frame were summed over (`dpc_radar.radar_total` of 24 hourly frames: 24). Between 1 and `MAX_RETURN_YEARS`; NaN where the frame or the climatology has no data. ### `climatology() -> Climatology` The climatology shipped with the package (read once). ### `rarity(window: int, lon: float, lat: float, mm: float) -> Rarity` How rare `mm` of rain in `window` hours (1, 3, 6 or 24) are at a point. ### `return_level(window: int, lon: float, lat: float, years: float) -> Level | None` The rain in `window` hours passed once in `years` years at a point. ### `return_period(grid: RainGrid, window: int | None = None) -> np.ndarray` The return period in years of the rain of every pixel of an accumulation frame. `window`: the hours the frame was summed over, when not those of its product. ## The measure, in full `uv run --extra history --with scipy python -m tools.build_climatology --history --work --drift --measure --archive `. ### The history is not one series For every year, the highest window of the year of every pixel over the location of the fit (2018–2025) at that pixel; the median over the pixels with a fit. 1 is "this year read like the map". | Year | 1 h | 3 h | 6 h | 24 h | |---|---|---|---|---| | 2010 | 0.76 | 0.74 | 0.73 | 0.70 | | 2011 | 0.64 | 0.68 | 0.69 | 0.67 | | 2012 | 0.71 | 0.73 | 0.74 | 0.77 | | 2013 | 0.90 | 0.80 | 0.75 | 0.69 | | 2014 | 1.14 | 1.20 | 1.24 | 1.19 | | 2015 | 0.75 | 0.77 | 0.78 | 0.85 | | 2016 | 0.84 | 0.85 | 0.86 | 0.83 | | 2017 | 0.74 | 0.76 | 0.76 | 0.78 | | 2018 | 1.22 | 1.15 | 1.11 | 1.13 | | 2019 | 1.30 | 1.29 | 1.29 | 1.24 | | 2020 | 1.35 | 1.30 | 1.28 | 1.25 | | 2021 | 1.16 | 1.11 | 1.08 | 1.06 | | 2022 | 1.13 | 1.08 | 1.05 | 0.99 | | 2023 | 1.11 | 1.10 | 1.09 | 1.11 | | 2024 | 1.23 | 1.21 | 1.20 | 1.18 | | 2025 | 1.09 | 1.18 | 1.25 | 1.35 | The step is between 2017 and 2018, in every window. 2014 stands out among the early years: it is also the year with most corrupted frames (250), and what `suspect` does not catch is likely still in it. ### Held-out years The eight years in four blocks of two. For every block, the map is fitted on the other six years, and the two years left out are counted: the share of pixel-years whose highest window passes the level. "Same years" is the share in the six years of the fit. | Window | Level | Expected | Held-out years | Same years | |---|---|---|---|---| | 1 h | 2 years | 0.500 | 0.515 | 0.529 | | 1 h | 5 years | 0.200 | 0.240 | 0.213 | | 1 h | 10 years | 0.100 | 0.135 | 0.097 | | 1 h | 20 years | 0.050 | 0.075 | 0.039 | | 3 h | 2 years | 0.500 | 0.521 | 0.536 | | 3 h | 5 years | 0.200 | 0.242 | 0.212 | | 3 h | 10 years | 0.100 | 0.136 | 0.094 | | 3 h | 20 years | 0.050 | 0.075 | 0.037 | | 6 h | 2 years | 0.500 | 0.522 | 0.536 | | 6 h | 5 years | 0.200 | 0.243 | 0.212 | | 6 h | 10 years | 0.100 | 0.136 | 0.091 | | 6 h | 20 years | 0.050 | 0.076 | 0.035 | | 24 h | 2 years | 0.500 | 0.523 | 0.534 | | 24 h | 5 years | 0.200 | 0.242 | 0.213 | | 24 h | 10 years | 0.100 | 0.138 | 0.091 | | 24 h | 20 years | 0.050 | 0.080 | 0.031 | A level that says "once in N years" should be passed by 1/N of the pixels in a year. The levels are passed more often than that out of the years of the fit, and the gap grows with the return period: six years say little about twenty. The map in the package is fitted on all eight, so it should do a little better than this, and there is no ninth year to say how much. ### The hourly frames of 2026 The `SRT1` frames kept from 9 June to 16 November 2026 (3829 hours), summed over the same windows, where the radar is [reliable](reliability.md) (score from 0.5). They are a different product from the history (the hourly rain of the DPC, not the sum of the intensity frames) and they are five months, not a year. | Window | Pixels | Highest window over the location of the fit | Over the 2-year level | 5-year | 10-year | 20-year | 50-year | |---|---|---|---|---|---|---|---| | 1 h | 574276 | 1.17 | 0.501 | 0.234 | 0.121 | 0.061 | 0.025 | | 3 h | 573194 | 1.22 | 0.541 | 0.279 | 0.157 | 0.087 | 0.037 | | 6 h | 571469 | 1.19 | 0.531 | 0.279 | 0.164 | 0.096 | 0.045 | | 24 h | 573834 | 1.22 | 0.550 | 0.307 | 0.203 | 0.135 | 0.073 | For one hour the frames of 2026 pass the levels about as often as a held-out year of the history (12 % against 14 % at 10 years). For 24 hours they pass them more often in five months than a held-out year does in twelve (20 % against 14 %): use the 24 h return period of a sum of `SRT1` frames with that in mind. ### One day The 24 hours to 2 November 2026 09:00 UTC, the widest rain of the archive against the map (the image at the top). | | 2 years or more | 10 years or more | 50 years or more | |---|---|---|---| | radar alone (24 `SRT1` hours), where the radar is reliable | 69,264 km² | 28,323 km² | 13,302 km² | | «Merging» (8 `CUM3` frames), same pixels | 30,572 km² | 13,763 km² | 8,221 km² | Where the radar alone says 10 years or more it has 100 mm on average and the «Merging» 47. Its highest pixel has 382 mm, and the «Merging» 7 mm in the same place. Most of the area is over the Tyrrhenian Sea, where there are no gauges and the «Merging» is the radar with another calibration. # 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. ```python 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. `storms` finds the patches of one frame and describes each one (`Storm`): centre, area, peak, mean. `track` follows them from frame to frame (`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 (`dpc_radar.reliability`) there are no storms to find. ### `class Storm(time: datetime, product: str, threshold: float, lon: float, lat: float, area_km2: float, peak: float, peak_lon: float, peak_lat: float, mean: float, bbox: BBox)` 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. ### `class Track(storms: tuple[Storm, ...])` One storm followed through the frames: its `Storm` at every frame it was seen. #### `Track.duration: timedelta` From the first frame to the last: a storm seen in one frame lasted zero. #### `Track.area_km2: float` The largest area it reached. #### `Track.path: list[tuple[float, float]]` The lon/lat of its centre, frame by frame. #### `Track.distance_km: float` From where it was first seen to where it was last seen, in a straight line. #### `Track.speed_kmh: float | None` Its mean speed along that line; `None` for a storm seen in one frame. #### `Track.heading: float | None` Where it goes, in degrees clockwise from north; `None` if it did not move. #### `Track.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(grid: RainGrid, *, threshold: float, min_area_km2: float = MIN_AREA_KM2) -> list[Storm]` The storms of one frame, the strongest first. ### `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. # Catalogue of rare rain ![A map of Italy with the 339 events of June to November 2026 at the ceiling of the climatology, full where the Merging confirms them, and their count by month and by window](../images/catalogue.png) ## `dpc_radar.catalogue` A catalogue of rare rain: where and when the radar saw rain that comes once in years. `rare_events` reads a run of hourly radar frames (`SRT1`) and, hour by hour, sums them over the windows of the climatology (1, 3, 6 and 24 hours). Where a sum reaches the level a place passes once in `years` years (`dpc_radar.climatology`) there is rare rain. The touching pixels over their level are one patch; patches that overlap from one hour to the next are the same `Event`, and two events that grow into each other become one. Each event says where and when its rain was rarest, how many millimetres fell there, in which window, the return period, and the area it covered. It is a list of places to look at, not a list of floods. The radar says where it rained too much for that place; whether there was damage is for someone to check on the ground or in the news. Three things keep the list honest: * pixels where the radar does not see well are left out (`dpc_radar.reliability`, `min_reliability`): there the radar millimetres are not rain; * patches smaller than `min_area_km2` are dropped: a few pixels over the level are more often clutter than a storm; * `with_merging` reads, from an archive, what the «Merging» (radar and rain gauges) says of the same hours at the same place. The radar alone reads echoes that are not rain: an event the «Merging» does not see (`Event.confirmed` false) is most likely one of those. What it cannot see: rain where the radar is blind or too far, rain the radar under-reads (the climatology is in radar millimetres, so a constant under-reading cancels, a storm behind a mountain does not), and anything shorter than the season it is given. It needs SciPy (extra `storms`). ### `class Event(time: datetime, window: int, lon: float, lat: float, mm: float, level_mm: float, return_period: float, first: datetime, last: datetime, area_km2: float, bbox: BBox, radar_mm: float | None = None, merging_mm: float | None = None)` Rain over the level of its place, followed while it stayed over it. `lon`/`lat` is where the rain was rarest: `mm` fell there in the `window` hours that end at `time`, against a `level_mm` passed once in the `years` the catalogue was asked for; `return_period` is what the climatology says of those millimetres (it stops at 50 years). It is not the single rarest pixel, which is too often an echo or hail: it is the pixel that closes the rarest `min_area_km2` of the event, so at least that much ground had rain as rare or rarer. `first` and `last` are the hours some window was over its level, `area_km2` the largest area over the level in one hour, `bbox` all the ground the event touched. `radar_mm` and `merging_mm` are filled by `with_merging`. #### `Event.start: datetime` When the rarest window began. #### `Event.times_level: float` The rain as a multiple of the level: it ranks events at the 50-year ceiling. #### `Event.confirmed: bool | None` Whether the «Merging» saw the rain too; `None` before `with_merging`. ### `rare_events(frames: Iterable[RainGrid], *, years: float = YEARS, min_area_km2: float = MIN_AREA_KM2, min_reliability: float = MIN_RELIABILITY, inside: np.ndarray | None = None, source: Climatology | None = None) -> list[Event]` The rare rain of a run of hourly frames, the rarest first. `frames`: one-hour accumulations (`SRT1`) on one grid, in order of time. An hour that is missing makes the windows over it unknown, so pass what there is and nothing else. `years`: the return period from which rain is rare. `min_reliability`: 0 keeps every pixel. `inside`: an array of the shape of the frames, true on the pixels to look at (the land, a region); the others are left out. `source`: a climatology other than the one shipped. ### `with_merging(event: Event, archive: MergingArchive) -> Event` `event` with what the radar alone and the «Merging» say of its rarest window. The «Merging» comes in three-hour blocks (`CUM3`), so both are summed over the blocks that cover the window, and each is the highest value within 5 km of the rarest pixel: the two grids are not the same, and a storm core falls a pixel apart in them. Unchanged when the archive lacks a frame. ## The measure, in full `uv run python -m tools.build_catalogue --archive --out events.csv`, on the hourly SRT1 frames from 9 June to 16 November 2026 (160 days; 3,825 hours read, 12 missing, 4 rejected by `quality`). The land is the alert zones of the criticality bulletin; the pixels are those with a reliability of 0.5 or more; an event is at least 10 km². The list is [rare-rain-2026.csv](../data/rare-rain-2026.csv) (CC BY-SA 4.0, derived from the DPC radar data). ### How many | Return period | Events | A month | Confirmed by the «Merging» | Not confirmed | Unknown | |---|---|---|---|---|---| | 10 years or more | 1,689 | 317 | 1,054 | 586 | 49 | | 20 years or more | 763 | 143 | 474 | 260 | 29 | | 50 years (the ceiling) | 339 | 64 | 214 | 109 | 16 | "Confirmed" is: over the three-hour blocks that cover the window, the «Merging» has at least half of what the radar alone has, within 0.05° of the point. "Unknown" is a block missing from the archive. Without the land mask the events over the 10-year level are 2,316. The events at the ceiling by month: 144 in June (101 of them of one hour), about 39 in July, 26 in August, 36 in September, 40 in October, 54 in the first half of November (most of them of 24 hours). Of the first hundred of the list, 63 are of one hour and 55 are of June, many in one cluster over the central Apennines: short summer storms, where hail can make the radar read more than the rain. The catalogue cannot tell; the «Merging» column and the news can. ### Why the list is long A return period is about one place, and Italy is many places: somewhere a "10-year" rain falls most weeks. And on the SRT1 of 2026 the levels are passed more often than their name says. The share of reliable pixels over a level at least once in the 160 days: | Window | 2 years | 10 years | 50 years | |---|---|---|---| | 1 h | 49.1 % | 11.8 % | 2.4 % | | 3 h | 53.4 % | 15.3 % | 3.6 % | | 6 h | 52.7 % | 15.9 % | 4.3 % | | 24 h | 54.8 % | 19.8 % | 6.9 % | | a whole year, if the name were exact | 50 % | 10 % | 2 % | In 160 days the pixels over their 10-year level are already as many as, or more than, a whole year should give. June to November holds most of the highest rains of the year, so the gap with a whole year is smaller than the days suggest; but the 24-hour level of 50 years is passed more than three times too often even so. A wet season, or an SRT1 that reads more than the history the map was fitted on: one season cannot tell. So **read the return period as a ranking** (this rain is among the heaviest this place has seen on the radar), not as "once in N years". ### The events we knew | Event | In the list | Why | |---|---|---| | Melito di Porto Salvo (RC), flood of 10 October 2026 | yes: rank 172 of 1,689, 113 among the confirmed. 6 hours from 00:00 UTC, 92.6 mm against a 10-year level of 49.6 (1.87 times), 788 km², «Merging» 139.9 mm | the radar saw less than the gauges, and still enough | | Lipari (ME), 2026 | no | reliability 0.42: the radar is nearly blind there, and the catalogue leaves the place out | The first of the list is the night of 20–21 October on the coast south of Rome («Bacini Costieri Sud», 12.90°E 41.45°N): 145.1 mm in 6 hours against a level of 32.0 (4.5 times), over 2,153 km², «Merging» 148.9 mm. An example of what the «Merging» column is for is rank 31, 1 November over Lessinia (11.01°E 45.57°N): 234.6 mm in 3 hours, radar 354.1 against «Merging» 89.8, not confirmed. It was first read as a fixed clutter pixel; the hourly frames say otherwise: a core of 140–180 mm in an hour that moves 8 km south in four hours, and over the season the place is wet as often as the land around it. The radar reads too much there, not something that is not there: the `agreement` of the [reliability map](reliability.md) is 0.52 at that point (the radar alone read about twice the «Merging» from June to November). ### What is not there - **Verified events.** The issue asked for "new verified events per month". The catalogue gives candidates, 317 a month at 10 years and 64 at the ceiling; whether one did damage is a fact-check on the news, and that count belongs to whoever does it. Start from the confirmed ones at the ceiling (214). - **Municipalities.** An event has a point, a box and the name of its alert zone. The bulletin lists the municipalities of a zone by name only, with no borders: join on the point with the borders of ISTAT. - **Blind places.** Where the reliability is under 0.5 nothing is found, by choice: Lipari is the cost. - **Other seasons.** One season of SRT1. On the history (2018–2025, radar only, no «Merging» to confirm) the same function runs on hourly sums of `SriHistory`, but it was not measured here. # The rain of the next two hours The radar shows rain that has already fallen. `nowcast` moves the latest SRI frame forward along the motion the rain had in the last half hour: a forecast for the next two hours, every five minutes. `rain_ahead` sums it into millimetres, `chance` turns it into a probability, `motion` says where the rain is going and how fast. ![Four maps of the Strait of Messina on 10 October 2026: the radar at 00:30 UTC, the rain forecast to 02:30, the rain the radar saw, and the chance of 20 mm](../images/nowcast.png) ```python from datetime import timedelta from dpc_radar import chance, motion, nowcast, rain_ahead # pip install "dpc-radar[nowcast]" now = await radar.latest("SRI") before = [await radar.at("SRI", now.time - timedelta(minutes=5 * k)) for k in range(6, 0, -1)] frames = [f for f in before if f] + [now] # the last half hour, the oldest first melito = [(15.78, 37.92)] motion(frames).at(*melito[0]) # (5.6, 82.9): km/h, and degrees from north: to the east rain_ahead(frames, minutes=120).sample(melito) # [44.7] mm forecast by 02:30 chance(frames, mm=20, minutes=120).sample(melito) # [0.40] for forecast in nowcast(frames, minutes=60): # twelve fields of mm/h print(forecast.time, forecast.lead, forecast.sample(melito)) ``` The numbers are those of 10 October 2026 at 00:30 UTC, the night of the flood of Melito di Porto Salvo; in the two hours that followed the radar saw 31.3 mm there. Every function returns a `Forecast`, never a `RainGrid`: it carries the time it was issued and how far ahead it looks, and it cannot be passed by mistake where observed rain is expected. Where the rain would come from outside the frame, or from a place the radar does not see, the forecast is `NaN`: not known, which is not dry. **How far to trust it.** The rain is moved, not changed. A storm born after the last frame is not in the forecast, one that dies is still there, and one that stays over a mountain while the others pass is moved away with them. So it is fair on where the rain area will be at 30 to 60 minutes and poor on where the peaks will be; `chance` says so with a number, and that number can be trusted more than the map of millimetres. Nothing here replaces the official DPC alert. ## `dpc_radar.nowcast` The rain of the next two hours: the radar field moved forward along its own motion. The radar shows rain that has already fallen. Over an hour or two most of what changes is where the rain is, not what it is: the field of now, moved along the motion it had in the last half hour, is a forecast (an *extrapolation*, the first step of pySTEPS and of every radar nowcast). * `motion` measures how the rain moved between the frames it is given. * `nowcast` gives the intensity (mm/h) at every step up to two hours. * `rain_ahead` sums it: the millimetres of the next `minutes`. * `chance` turns it into a probability: the chance of at least `mm` in the next `minutes` at every pixel. Everything here returns a `Forecast`, never a `dpc_radar.RainGrid`: it carries when it was issued and how far ahead it looks, and it cannot be passed by mistake where observed rain is expected. **How it works.** The motion is found by matching blocks of 192 km of the oldest frame of the last half hour with the latest one (the shift that makes them most alike, on the logarithm of the rain, up to 100 km/h); a block without rain takes the motion of the nearest one with rain. Each pixel of the forecast then takes the rain of the place the motion says it comes from (semi-Lagrangian, a step at a time, so a field that turns is followed along the turn). Where the rain would come from outside the frame, or from a place without data, the forecast is `NaN`: not known, which is not dry. **What it cannot do.** The rain is moved, not changed: a storm that is born after the last frame is not there, one that dies is still there, and one that stays over a mountain while the others pass is moved away with them. So the forecast is good on where the rain area will be and poor on where its peaks will be, and it gets worse with every minute: the numbers are in the reference. `chance` is not an ensemble: it is the share of the forecast around a pixel that is over the threshold, within a distance that grows by 0.2 km a minute, the distance that scored best on the storms of 2021-2025. It needs SciPy (extra `nowcast`, `pip install "dpc-radar[nowcast]"`) and frames in metres a few minutes apart: the SRI. ### `class Forecast(issued: datetime, lead: timedelta, unit: str, data: np.ndarray, transform: Affine, crs: CRS, window: timedelta | None = None, threshold: float | None = None)` Rain that has not fallen yet: one field, when it was issued and how far ahead it is. `unit` says what `data` holds: `"mm/h"` (the intensity at `time`), `"mm"` (the rain of the `window` that ends at `time`) or `"probability"` (between 0 and 1: the chance of at least `threshold` mm in the `window` that ends at `time`). `NaN` is "not known". #### `Forecast.time: datetime` The time the forecast is for. #### `Forecast.sample(points: list[tuple[float, float]]) -> list[float | None]` The forecast at each lon/lat point, as `dpc_radar.RainGrid.sample`. ### `class Motion(east: np.ndarray, north: np.ndarray, found: bool, transform: Affine, crs: CRS)` How the rain moved: km/h towards the east and the north of the grid, at every pixel. `found` is false when no block of the frames had rain enough to be followed: the motion is then zero everywhere, and a nowcast is the last frame, still. #### `Motion.at(lon: float, lat: float) -> tuple[float, float] | None` Speed (km/h) and heading (degrees from north, where the rain goes) at a point. ### `motion(grids: Iterable[RainGrid]) -> Motion` How the rain moved between the last frame and the oldest one of its last half hour. ### `nowcast(grids: Iterable[RainGrid], *, minutes: int = MAX_MINUTES) -> list[Forecast]` The intensity (mm/h) of the next `minutes`, one `Forecast` per step. `grids` are frames of intensity on one grid in order of time, the last one being now; the step is the interval between the last two (five minutes for the SRI). Give the frames of the last half hour: with only two the motion is measured on five minutes, and it is less sure. ### `rain_ahead(grids: Iterable[RainGrid], *, minutes: int = 60) -> Forecast` The millimetres of the next `minutes`: the nowcast, summed. `NaN` where any step of it is not known. ### `chance(grids: Iterable[RainGrid], *, mm: float, minutes: int = 60) -> Forecast` The chance (0 to 1) of at least `mm` in the next `minutes`, at every pixel. It is the share of `rain_ahead` that reaches `mm` within `SPREAD_KM_PER_MINUTE * minutes` km of the pixel (12 km for an hour): the forecast is rarely wrong on whether a storm is around, and often on where exactly. `NaN` where the forecast itself is not known. ## The measure, in full ```bash uv run --extra history python -m tools.measure_nowcast \ --history italian-radar-dpc-sri.zarr --cases 120 --seed 2026 ``` The tool draws moments at random from the IT-DPC-SRI history of 2021–2025 (a frame every five minutes), one per day at most, and keeps those with heavy rain somewhere (300 km² at 10 mm/h or more), the half hour before and the two hours after complete, and no corrupted frame. On each it runs the nowcast on the frames of the last half hour and compares it, pixel by pixel over the whole of Italy, with what the radar saw next. With seed 2026 these are 120 moments between 5 January 2021 and 2 December 2025; the rain moved at 17 km/h (the median over the cases, from 0 to 70). "Persistence" is the last frame left where it is: the forecast that knows nothing of motion, and the one every use of the radar makes without saying so. CSI is, of the pixels where rain over a threshold was forecast or seen, the share where it was both (1 is perfect); the bias is pixels forecast over pixels seen (1 is the right amount of rain). ### The intensity, minute by minute | mm/h | Minutes ahead | Nowcast: CSI (bias) | Persistence: CSI (bias) | |---|---|---|---| | 1 | 30 | 0.47 (1.02) | 0.38 (1.04) | | 1 | 60 | 0.34 (1.05) | 0.27 (1.08) | | 1 | 120 | 0.23 (1.06) | 0.19 (1.12) | | 5 | 30 | 0.25 (1.00) | 0.18 (1.03) | | 5 | 60 | 0.15 (1.06) | 0.10 (1.10) | | 5 | 120 | 0.08 (1.01) | 0.06 (1.08) | | 10 | 30 | 0.17 (0.96) | 0.10 (1.01) | | 10 | 60 | 0.08 (1.03) | 0.05 (1.10) | | 10 | 120 | 0.04 (0.99) | 0.03 (1.08) | The nowcast is better than persistence at every threshold and every lead, and it is still not good on heavy rain: at one hour, of the pixels where 10 mm/h were forecast or seen, 8 in 100 had both. A pixel is one kilometre, and a convective core is a few kilometres wide and lives less than an hour. ### The rain of the next hour | mm in the hour | Nowcast: CSI (bias) | Persistence: CSI (bias) | |---|---|---| | 5 | 0.34 (1.12) | 0.23 (1.22) | | 10 | 0.25 (1.18) | 0.15 (1.52) | | 20 | 0.17 (1.32) | 0.09 (2.24) | Sums are easier than instants. The bias over 1 is the storm that is not allowed to die: `rain_ahead` forecasts 20 mm on a third more pixels than get them. Persistence, the last frame multiplied by the hour, does it on more than twice as many. ### The chance `chance` is not an ensemble. It is the share of the pixels around a place, within a distance that grows by 0.2 km for every minute of lead (12 km at one hour), where `rain_ahead` is over the threshold: "the storm will be here, or a few kilometres from here". The Brier skill compares it with saying everywhere the share of pixels that got the rain (0 is no better than that, 1 is perfect); "yes or no" is `rain_ahead` read as a certainty. | mm | Minutes ahead | Pixels that got it | `chance`: Brier skill | Yes or no: Brier skill | |---|---|---|---|---| | 5 | 30 | 0.17 % | +0.33 | −0.01 | | 5 | 60 | 0.55 % | +0.33 | −0.05 | | 5 | 120 | 1.58 % | +0.31 | −0.08 | | 10 | 30 | 0.04 % | +0.20 | −0.26 | | 10 | 60 | 0.14 % | +0.20 | −0.31 | | 10 | 120 | 0.45 % | +0.17 | −0.41 | | 20 | 30 | 0.01 % | +0.18 | −0.37 | | 20 | 60 | 0.03 % | +0.10 | −0.64 | | 20 | 120 | 0.09 % | +0.08 | −0.78 | Read as a certainty, the map of forecast millimetres is worse than knowing nothing but how often it rains. Read as a chance, it is worth something at every threshold, less and less as the rain gets heavier. And the chance means what it says. Of the pixels given a chance for the next hour, the share where the rain came: | Chance given | 5 mm | 10 mm | 20 mm | |---|---|---|---| | 0–5 % | 0.09 % | 0.03 % | 0.01 % | | 5–20 % | 7.2 % | 6.3 % | 5.2 % | | 20–40 % | 20.9 % | 20.1 % | 19.1 % | | 40–60 % | 40.5 % | 39.0 % | 33.8 % | | 60–80 % | 60.9 % | 58.0 % | 42.2 % | | 80–100 % | 78.7 % | 68.9 % | 83.0 % | Each share should fall inside its row, and nearly all do, towards the low end: the chance is a little too sure of itself when it is high. The last two rows for 20 mm stand on 1,980 and 541 pixels out of 98 million, a handful of storms. ### One night: Melito di Porto Salvo, 10 October 2026 The SRI of that night, from the API, every half hour: what was forecast for the town (15.78° E, 37.92° N) for the two hours that followed, and what the radar then saw there. The motion was towards the east all night. | Issued (UTC) | Motion | Forecast, 2 h | Seen by the radar, 2 h | Chance of 20 mm | |---|---|---|---|---| | 23:30 | 6 km/h | 5.0 mm | 38.8 mm | 0.20 | | 00:00 | 1 km/h | 39.1 mm | 35.8 mm | 0.43 | | 00:30 | 6 km/h | 44.7 mm | 31.3 mm | 0.40 | | 01:00 | 11 km/h | 13.4 mm | 29.6 mm | 0.34 | | 01:30 | 8 km/h | 42.5 mm | 24.4 mm | 0.55 | | 02:00 | 3 km/h | 8.9 mm | 30.1 mm | 0.37 | | 02:30 | 5 km/h | 3.7 mm | 37.9 mm | 0.18 | | 03:00 | 7 km/h | 30.8 mm | 38.2 mm | 0.41 | | 03:30 | 9 km/h | 21.2 mm | 32.1 mm | 0.45 | | 04:00 | 6 km/h | 19.7 mm | 21.1 mm | 0.38 | It rained over 20 mm in every one of those two-hour windows. The millimetres forecast go from 4 to 45: the storm stood nearly still and was born again and again over the same place, which is what an extrapolation cannot know. The chance stayed between 0.2 and 0.55 all night, and it was at its lowest at 23:30, before the first cells, and at 02:30, between two of them. A chance of 0.4 of 20 mm in two hours, on a map where the usual value is under 0.001, is a warning; it is not a forecast of a flood. ### How the numbers in the code were chosen On 60 other storms of the same history (another seed), not on the 120 above. - **The motion over the last half hour**, not the last ten minutes: with a shorter baseline the shift is a pixel or two and its error is as large. - **Blocks of 192 km**: smaller blocks follow single cells, which are born and die, and the motion gets worse. - **A window that fades the edges of each block** (Hann) gave +0.005 of CSI on real storms and made a clean synthetic storm 12 % too slow. Left out. - **0.2 km a minute** for `chance`: the distance that scored best was about 6 km at 30 minutes, 12 km at 60 and 24–28 km at 120. ### What is not there - **Growth and decay.** The rain is only moved. This is the first step of [pySTEPS](https://pysteps.github.io/), not the whole of it. - **An ensemble.** `chance` is a neighbourhood, not a set of possible futures: it says nothing about two places together (a whole catchment), only about each pixel. - **A learned nowcast.** It needs years of frames and a GPU, and a measure like this one to beat first. - **A check on rare events.** The measure is on moments of heavy rain drawn at random, not on the [catalogue of rare rain](catalogue.md): the 2026 archive it comes from has hourly frames, and a nowcast needs one every five minutes. Only the night of Melito was fetched from the API. - **The gauges.** The forecast is in radar millimetres, of the SRI: what the radar is far from, [place by place](bias.md), it is far from too. # Criticality bulletins ## `dpc_radar.bulletins` The DPC criticality bulletin: the official hydro-geological alert, as data. Every day by 16:00 the Civil Protection Department publishes the national criticality bulletin (*bollettino di criticità e allerta*) in its GitHub repository `pcm-dpc/DPC-Bollettini-Criticita-Idrogeologica-Idraulica `_ (CC BY 4.0): one GeoJSON for today and one for tomorrow, with the ~190 alert zones of Italy. It is already structured: no language model reads it, it is imported. Each zone carries four levels, written in words in the file ("Ordinaria per rischio idrogeologico / ALLERTA GIALLA"): the one on the map, and the ones for hydro-geological risk (landslides), hydraulic risk (rivers) and thunderstorms. They become numbers: 0 none, 1 yellow, 2 orange, 3 red. This is the **official** alert. Whatever a model computes from the radar is not, and should be shown next to it, never instead of it. Needs `shapely` for the zone shapes: `pip install "dpc-radar[bulletins]"`. ### `level(text: str | None) -> int` «Ordinaria per rischio temporali / ALLERTA GIALLA» → 1; no alert → 0. ### `issued(name: str) -> datetime | None` When a bulletin was issued, from its file name (Italian time); `None` if not one. ### `class Zone(valid: date, name: str, level: int, hydrogeological: int, hydraulic: int, thunderstorms: int, municipalities: tuple[str, ...], geometry: Any)` One alert zone on one day. ### `zones_from_geojson(data: dict[str, Any], valid: date) -> list[Zone]` The zones of one bulletin file (today or tomorrow). Features with no name are skipped. ### `class Bulletin(name: str, issued: datetime, zones: list[Zone])` One bulletin: its name, when it was issued, and its zones for today and tomorrow. #### `Bulletin.days() -> list[date]` #### `Bulletin.zone_at(lon: float, lat: float, day: date | None = None) -> Zone | None` The zone that contains a point on `day` (the first day if omitted). #### `Bulletin.alerts(day: date | None = None, *, at_least: int = 1) -> list[Zone]` The zones at `at_least` (yellow by default) on `day`, highest first. ### `names_from(listing: dict[str, Any]) -> list[str]` Every bulletin name in a GitHub tree listing of `files/geojson`, oldest first. ### `latest_name_from(listing: dict[str, Any]) -> str | None` The newest bulletin name in a GitHub tree listing of `files/geojson`. ### `name_on(found: list[str], day: date) -> str | None` Of the names of `names`, the last bulletin issued on `day` (Italian time). ### `async names(client: httpx.AsyncClient | None = None, *, send: Send | None = None) -> list[str]` The file names of every bulletin the DPC keeps (`…_today.json`), oldest first. Three small calls to the repository tree instead of one recursive call: the archive holds thousands of files. Unauthenticated, GitHub allows 60 calls an hour; pass a client with a token header for more, or a `send` hook to use your own HTTP layer. For the bulletin of a past day: `name_on`, then `fetch`. ### `async latest_name(client: httpx.AsyncClient | None = None, *, send: Send | None = None) -> str | None` The file name of the newest bulletin (`…_today.json`), or `None`. ### `async fetch(name: str, client: httpx.AsyncClient | None = None, *, send: Send | None = None) -> Bulletin` Today and tomorrow of the bulletin `name` (`YYYYMMDD_hhmm_today.json`). ### `async latest(client: httpx.AsyncClient | None = None, *, send: Send | None = None) -> Bulletin` The newest bulletin. # MCP server: the rain as tools `dpc-radar mcp` gives an assistant (Claude, or any client of the [Model Context Protocol](https://modelcontextprotocol.io/)) eight tools on the rain over Italy. Someone asks "how much has it rained on Messina in the last three hours?" and the answer is computed from a frame, with the name of the product and the time of the frame: the model words it, it does not compute it. ```bash pip install "dpc-radar[mcp]" dpc-radar mcp # speaks MCP on standard input and output # Claude Code, with nothing to install first: claude mcp add dpc-radar -- uvx --from "dpc-radar[mcp]" dpc-radar mcp ``` For Claude Desktop, in `claude_desktop_config.json`: ```json { "mcpServers": { "dpc-radar": { "command": "uvx", "args": ["--from", "dpc-radar[mcp]", "dpc-radar", "mcp"] } } } ``` No key: the data are open. | Tool | What it answers | |---|---| | `latest()` | the newest frame of every product, and how often a new one comes | | `rain_at(lon, lat, hours=1)` | the rain of the last 1, 3, 6, 12 or 24 hours at a point: the median of 3×3 pixels, with the reliability of the radar there | | `area_summary(west, south, east, north, hours=1)` | over a box: maximum and where, mean, median, 95th percentile, km² over 1, 5, 10, 20, 50 and 100 mm | | `storm_now(west, south, east, north)` | the storms on the newest intensity frame (patches at 10 mm/h or more), with their motion; all of Italy without a box | | `rain_ahead(lon, lat, minutes=60, mm=20)` | the [nowcast](nowcast.md) at a point, labelled as a forecast, with the chance of at least `mm` | | `official_alert(lon, lat, place)` | the level of the [criticality bulletin](bulletins.md): the zone of a point, the zones of a municipality or with a name, or every zone on alert | | `rarity(lon, lat, hours, mm)` | the [return period](climatology.md) of an amount of radar rain at a place | | `radar_status(lon, lat)` | which radars the DPC viewer [reports as on](status.md): those in range of a point, or all of them. A hint from an undocumented file, `null` when not known | This is the answer of `rain_at(15.78, 37.92, hours=3)`: ```json { "lon": 15.78, "lat": 37.92, "hours": 3, "mm": 0.0, "measured": true, "method": "median of the 3x3 pixels around the point", "frame": { "product": "CUM3", "time": "2026-11-17T10:30Z", "unit": "mm", "hours": 3, "source": "radar and rain gauges («Merging»)" }, "quality": { "verdict": "consistent", "trusted_share": 1.0, "masked_pixels": 0, "reasons": {"jump": 0, "beyond_record": 0, "outlier": 0, "gauge_only": 0}, "newest_frame_rejected": null }, "reliability": { "score": 0.9, "reliable": true, "beam_height_m": 1100.0, "nearest_radar": "Catania Fontanarossa", "distance_km": 81.7 }, "note": "radar data, not an alert: the official alert is the DPC bulletin" } ``` **What keeps the numbers honest.** - Every answer carries its `frame`: product and time. One hour is the radar alone (`SRT1`), three hours and more are the «Merging»; the answer says which. - Each frame goes through [`quality`](quality.md) against the frame before it. If the newest frame is rejected, the answer is read from the one before and says so (`newest_frame_rejected`). Pixels that fail a rule are masked. - Not measured is `null`, with a note, never zero. - `rain_ahead` answers `"kind": "forecast"`, with its limits in words. - What the library refuses (a window that does not exist, half a box) reaches the model as an error it can read: `the DPC publishes the rain of [1, 3, 6, 12, 24] hours, not of 2`. - `radar_status` explains a hole in the data; it never says the data are good. A radar reported on may be missing from the mosaic. - The server's instructions tell the model not to add up or estimate numbers itself, and that nothing here is an alert. A model can still word a number badly: the server gives it the facts and the rules, it cannot read its answer. For a text that must be right, see the [event reports](report.md), where the text is checked. **`official_alert` and regions.** The bulletin names alert zones ("Versante Jonico Meridionale") and their municipalities, not regions. `place` matches a municipality (in Italian, the whole name) or part of a zone name; for a region, ask by point or read the list of zones on alert. The tools are the methods of `Facts`, which you can use from Python without the server: ```python from dpc_radar import RadarClient from dpc_radar.facts import Facts async with RadarClient() as radar: facts = Facts(radar) print(await facts.rain_at(15.78, 37.92, hours=3)) print(await facts.area_summary(15.5, 37.85, 16.2, 38.3, hours=24)) ``` ## `dpc_radar.mcp_server` The MCP server: the rain over Italy as tools an assistant can call. `dpc-radar mcp` speaks the Model Context Protocol on standard input and output. It needs the `mcp` extra (`pip install "dpc-radar[mcp]"`) and no key: the data are open. To add it to Claude Code:: claude mcp add dpc-radar -- uvx --from "dpc-radar[mcp]" dpc-radar mcp The tools are the methods of `dpc_radar.facts.Facts`: * `latest`: the newest frame of every product. * `rain_at`: the rain of the last 1, 3, 6, 12 or 24 hours at a point. * `area_summary`: the same over a box: maximum, mean, km² over thresholds. * `storm_now`: the storms on the newest intensity frame, and where they go. * `rain_ahead`: the nowcast at a point, labelled as a forecast. * `official_alert`: the level of the DPC criticality bulletin. * `rarity`: how rare an amount of rain is at a place. * `radar_status`: which radars the DPC reports on and off. Every answer names the product and the time of the frame it was read from: the model words the answer, it does not compute it. What the library refuses (a box outside Italy, a window the DPC does not publish) reaches the model as an error it can read and act on. ### `create_server(radar: Callable[[], Source] | None = None, *, bulletin: Callable[[], Awaitable[Bulletin]] | None = None) -> MCPServer[Any]` The MCP server, its tools bound to one `dpc_radar.facts.Facts`. `radar` builds the client on the first call (default: a `dpc_radar.RadarClient`); `bulletin` fetches the newest bulletin (default: `dpc_radar.bulletins.latest`). ### `run() -> None` Serve on standard input and output, until the client hangs up. ## `dpc_radar.facts` The numbers an assistant may quote, each with the frame it came from. A language model that is asked "how much did it rain in Florence?" will answer with a number, whether it has one or not. `Facts` gives it the number: every answer is a plain dictionary, ready for JSON, that names the product and the time of the frame it was computed from, how the value was read and how far the radar can be trusted there. The model words the answer; it does not compute it. This is what the MCP server (`dpc_radar.mcp_server`) serves, and it can be used as it is from Python:: async with RadarClient() as radar: facts = Facts(radar) await facts.rain_at(11.25, 43.77, hours=3) * `Facts.latest`: the newest frame of every product. * `Facts.rain_at`: the rain of the last 1, 3, 6, 12 or 24 hours at a point. * `Facts.area_summary`: the same over a box: maximum, mean, km² over thresholds. * `Facts.storm_now`: the storms on the newest intensity frame, and where they go. * `Facts.rain_ahead`: the nowcast at a point, always labelled as a forecast. * `Facts.official_alert`: the level of the DPC criticality bulletin. * `Facts.rarity`: how rare an amount of rain is at a place. * `Facts.radar_status`: which radars the DPC reports on and off. The rules every answer follows: * a point is read as the median of the 3x3 pixels around it, never as one pixel; * the newest frame goes through `dpc_radar.RainGrid.quality` against the one before it; if it is rejected the answer comes from the frame before, and says so; * `None` means not measured, which is not the same as dry; * millimetres are rounded to 0.1: the radar does not know more than that. Frames are kept in memory (`cache_frames` of them), so a conversation that asks about ten places downloads each frame once. ### `class Source()` Where the frames come from: a `dpc_radar.RadarClient`, or anything like it. #### `async Source.last_product(name: str | Product) -> LastProduct | None` #### `async Source.at(name: str | Product, time: datetime) -> RainGrid | Absent` ### `stamp(time: datetime) -> str` A time as the facts write it: `2026-10-10T06:00Z`, always UTC. ### `frame_of(grid: RainGrid) -> dict[str, Any]` Which frame a number came from. ### `lonlat(grid: RainGrid, row: int, col: int) -> tuple[float, float]` The centre of a pixel, in degrees. ### `describe(part: RainGrid, thresholds: tuple[int, ...] = THRESHOLDS) -> dict[str, Any]` The rain of a frame, or of a piece of one, as numbers. The mean, the median and the 95th percentile are of the pixels with data, each weighted by its area. `measured_share` is the share of the area that has data: a mean over half a box is the mean of that half. ### `trust(lon: float, lat: float) -> dict[str, Any]` How far the radar can be trusted at a point (`dpc_radar.reliability`). ### `rarity_of(lon: float, lat: float, hours: int, mm: float) -> dict[str, Any]` How rare `mm` in `hours` are at a point (`dpc_radar.rarity`). ### `zone_of(zone: Zone) -> dict[str, Any]` One alert zone on one day. ### `class Facts(radar: Source, *, bulletin: Callable[[], Awaitable[Bulletin]] | None = None, cache_frames: int = 24)` Answers about the rain over Italy, as dictionaries that name their frames. #### `async Facts.latest() -> dict[str, Any]` The newest frame of every product: its time, and how often a new one comes. #### `async Facts.rain_at(lon: float, lat: float, hours: int = 1) -> dict[str, Any]` The rain of the last `hours` (1, 3, 6, 12 or 24) at a point, in mm. #### `async Facts.area_summary(west: float, south: float, east: float, north: float, hours: int = 1) -> dict[str, Any]` The rain of the last `hours` over a box in degrees: maximum, mean, km². #### `async Facts.storm_now(west: float | None = None, south: float | None = None, east: float | None = None, north: float | None = None) -> dict[str, Any]` The storms on the newest SRI frame (patches at 10 mm/h or more), heaviest first. With a box, only those that touch it. `moving` is the motion of the rain around the storm over the last half hour: km/h, and the degrees from north of where it goes (90: east). #### `async Facts.rain_ahead(lon: float, lat: float, minutes: int = 60, mm: float = 20.0) -> dict[str, Any]` A forecast: the rain of the next `minutes` (5 to 120) at a point. The newest SRI frame moved along the motion of the last half hour (`dpc_radar.nowcast`), and the chance of at least `mm`. #### `async Facts.official_alert(lon: float | None = None, lat: float | None = None, place: str | None = None) -> dict[str, Any]` The level of the newest DPC criticality bulletin, for today and tomorrow. With `lon` and `lat`: the zone of that point. With `place`: the zones whose name contains it, or that hold a municipality of that name. With neither: every zone on alert (yellow or more). #### `Facts.rarity(lon: float, lat: float, hours: int, mm: float) -> dict[str, Any]` How rare `mm` of rain in `hours` (1, 3, 6 or 24) are at a point. #### `async Facts.radar_status(lon: float | None = None, lat: float | None = None) -> dict[str, Any]` Which radars the DPC reports on and off now (`dpc_radar.status`). With `lon` and `lat`: the radars whose range holds the point, the nearest first. Without: every radar of the status file. `known` false means there is no status to read, which is not "all on". # Event reports `dpc-radar report` writes the report of a day of rain over a box: the figures as data, a text that only quotes them, and two images. ```bash pip install "dpc-radar[report]" dpc-radar report --bbox 15.5,37.85,16.2,38.3 --day 2026-10-10 --out melito # melito/facts.json melito/report.md melito/map.png melito/hourly.png ``` The frames come from the API (the last five months: 33 requests) or, with `--archive folder`, from an archive kept with [`dpc_radar.archive`](archive.md). `--no-bulletin` skips the official alert, `--no-images` the images. ## One day: Melito di Porto Salvo, 10 October 2026 The command above, on an archive kept since September 2026. These are the images it wrote, and part of its text. ![Two maps of the rain of 10 October 2026 around the Strait of Messina: the radar alone, with its maximum of 176 mm on the coast to the east, and the Merging, with 207 mm over Melito di Porto Salvo, marked by a cross](../images/report-map.png) > **The «Merging»** (radar corrected with the rain gauges: the sum of 8 CUM3 > frames out of 8). The maximum is **206.7 mm**, at 15.785° E, 37.925° N. > Over the box the mean is 73.9 mm and the median 65.2 mm. Of the box, > 3094.8 km² got 20 mm or more, 2434.6 km² got 50 mm or more, 567.6 km² got > 100 mm or more, 1.0 km² got 200 mm or more. > > **The radar alone** (no rain gauges: the sum of 24 SRT1 frames out of 24). > The maximum is **176.4 mm**, at 16.1096° E, 37.9053° N. […] > > At 15.785° E, 37.925° N, read as the median of the nine pixels around it: > the «Merging» gives **190.8 mm** in the day; the radar alone gives > **115.1 mm**. > > | Hours | Radar rain | Ended at | Return period | > |---|---|---|---| > | 1 | 21.2 mm | 02:00 | about 2 years (between 2 and 5) | > | 3 | 49.8 mm | 04:00 | about 7 years (between 3 and 15) | > | 6 | 88.9 mm | 06:00 | about 31 years (between 10 and 50) | > | 24 | 114.6 mm | 00:00 | about 42 years (between 14 and 50) | > > How far to trust the radar there: its reliability is 0.9 on a scale from > zero to one, so a radar reading can be taken at face value. The nearest > radar is Catania Fontanarossa, 82.4 km away. > > The bulletin issued on 9 October 2026 at 16:15 (Italian time) put the > wettest place, in the zone «Versante Jonico Meridionale», at level > **orange** for 10 October 2026 (hydrogeological risk: orange; hydraulic: > orange; thunderstorms: orange). ![Bars of the radar rain at the wettest place for each hour of 10 October 2026: 16 to 21 mm an hour between 01:00 and 05:00 UTC, little after](../images/report-hourly.png) The whole of its figures is in [`facts.json`](../data/melito-2026-10-10.json). Over the whole box the radar alone and the «Merging» agree (the ratio of the two means is 1.01); at the place where it rained most the radar alone read 115 mm where the «Merging» has 191. ## The text cannot invent a number The text is written from a template, with no language model. Before anything is saved it is read back: every number in it must be one of the figures of `facts.json`, to the decimals it is written with ("191.8" matches 191.84, "190" does not). Product names (`CUM3`) are not numbers, and dates and times are matched against the times in the facts. The same check is there for a text written by someone else, a language model included: ```bash dpc-radar report --bbox … --day … --out melito --text mine.md # saved only if it passes dpc-radar check melito/report.md melito/facts.json # numbers that are not in the facts: 250 ``` ```python from dpc_radar.report import check_text check_text("It rained 250 mm.", report.facts) # ["250"]: the numbers that are not there ``` ## A number said of the wrong thing `check_text` knows that a number exists in the facts, not what it is said of: "the radar alone read 206.7 mm" passes, because 206.7 is there, as the maximum of the «Merging». `check_claims` reads the sentences of the template and ties each number to its fact: the totals of each product, the wettest place and its hours, the reliability, the hourly table, the frames. Two figures swapped between the «Merging» and the radar alone, or one rounded the wrong way, are refused, by `save` and by `dpc-radar check` alike: ```python from dpc_radar.report import check_claims check_claims("the «Merging» gives 115.1 mm in the day", report.facts) # [Misquote(said='the «Merging» gives 115.1 mm in the day', key='peak.merging_mm', fact=190.8)] ``` ```bash dpc-radar check mine.md melito/facts.json # numbers said of the wrong fact: # «the «Merging» gives 115.1 mm in the day»: peak.merging_mm is 190.8 ``` **What the checks do not do.** `check_claims` reads the template's own sentences: a model that writes in other words gets `check_text` only, and a swap in its sentences passes. Small whole numbers nearly always pass `check_text` (the facts hold a 2, a 3 and a 10 somewhere), and neither reads words ("twice as much", "a record"). A text from a model still needs a reader. How often a model quotes the facts faithfully is measured in [`benchmarks/faithful.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/benchmarks/faithful.py): on its hand-written answers with known faults, `check_text` lets through 8 of 17 wrong numbers, all of them swapped. Claude Opus 5.5, asked the same five questions, quoted 111 numbers and got 110 right; the one left is a 95th percentile read as "the wettest 5 %". `check_text` reads numbers as a model writes them: "3,510" is one number, and "99.99th" is 99.99 (`dpc_radar.report.numbers`). ## What is in the facts - **`event`**: the day (a UTC day), the box, the times. - **`frames`**: for the radar alone and the «Merging», the frames expected, used, missing and rejected, and how many pixel readings were masked. With a frame missing or rejected the total is marked not `complete`, and the text says "at least". - **`radar`**, **`merging`**: over the box, the maximum and its place, mean, median, 95th percentile, km² over 20, 50, 100 and 200 mm. - **`hourly`**: the radar alone for each hour: maximum, mean, km² at 10 mm or more. - **`peak`**: the wettest place (the maximum of the «Merging», or of the radar when there is none), read as the median of 3×3 pixels: both totals, the radar rain of each hour, the wettest 1, 3, 6 and 24 hours and their [return period](climatology.md), the [reliability](reliability.md) of the radar there. - **`bulletins`**: the level the [official bulletin](bulletins.md) gave to that place for that day, from the bulletin of the day and of the day before. Each `SRT1` frame is checked against the hour before it, and each `CUM3` against the radar of its three hours (a rain gauge gone wrong), with [`quality`](quality.md). The two totals are on two grids, each over the rectangle of its own pixels that holds the box, so their areas differ a little. **What is not there.** The report is one UTC day: a storm across midnight is two reports. There are no rain gauges of their own (the DPC does not publish them), no rivers, no damage. The return periods are in radar millimetres, from eight years. And it is a reading of radar data: the official account of an event is that of the Civil Protection. ## `dpc_radar.report` The report of a day of rain over a box: facts first, then a text that only quotes them. `dpc-radar report --bbox W,S,E,N --day YYYY-MM-DD --out folder` writes four files: `facts.json` (every figure, with the frames it came from), `report.md` (the text), `map.png` (the radar alone next to the «Merging») and `hourly.png` (the rain at the wettest place, hour by hour). From Python:: from dpc_radar.archive import MergingArchive from dpc_radar.report import build report = build(MergingArchive(folder).read, (15.5, 37.8, 16.2, 38.3), date(2026, 10, 10)) report.facts["peak"] # where, how much, how rare report.save(Path("melito")) **What is in the facts.** The day is a UTC day. The radar alone is the sum of its 24 hourly `SRT1` frames, each checked against the hour before it (`dpc_radar.RainGrid.quality`); the «Merging» is the sum of the eight `CUM3` frames of the day, each checked against the radar of its three hours (a gauge gone wrong). A frame that is missing or rejected is listed, and the total is then "at least". At the wettest place (the maximum of the «Merging», or of the radar when there is none): both totals, the wettest 1, 3, 6 and 24 hours of radar rain and how rare they are there (`dpc_radar.rarity`), how far the radar can be trusted (`dpc_radar.reliability`), and the level the official bulletin gave to that place for that day. **The text never holds a number that is not in the facts.** It is written from a template, with no language model, and before anything is saved `check_text` reads it back: every number in it must be one of the figures of `facts.json`, to the decimals it is written with. The same check is there for a text written by someone else, a model included (`report.save(folder, text=...)`, or `dpc-radar check report.md facts.json`): a text with a number of its own is refused. That check knows that a number exists, not what it is said of; `check_claims` reads the sentences of the template and ties each number to its fact, so two figures swapped between the «Merging» and the radar alone are refused too. A sentence in other words gets only the first check. The frames come from a local archive (`dpc_radar.archive.MergingArchive`) or, for the last five months, from the API (`download`). The images need matplotlib: `pip install "dpc-radar[report]"`. ### `day_of(text: str) -> date` `2026-10-10` as a date; `DpcRadarError` if it is not one. ### `hours_of(day: date) -> list[datetime]` The 24 hours that end inside a UTC day: 01:00, 02:00 … 00:00 of the next. ### `class Report(facts: dict[str, Any], radar: RainGrid | None, merging: RainGrid | None)` The facts of a day of rain, and the two totals they were read from. `radar` and `merging` are the rain of the day over the box, each on its own grid (`None` when no frame of it could be used). #### `Report.text() -> str` The report in Markdown: only words, and numbers of `facts`. #### `Report.save(folder: Path, *, text: str | None = None, images: bool = True) -> list[Path]` Write `facts.json`, `report.md` and the two images; the paths written. `text` replaces the text of the template: it goes through `check_text` and `check_claims`, and a number that is not in the facts, or that is said of a fact that holds another, is a `DpcRadarError` with nothing written. ### `check_text(text: str, facts: dict[str, Any]) -> list[str]` The numbers of `text` that are not in `facts`, as written (empty: all found). A number of the text is found when a figure of the facts, rounded to the decimals the text uses, is that number: `192` and `191.8` both match 191.84, `190` does not. Times and dates count by their parts (`03:00` on `10 October 2026` matches `2026-10-10T03:00Z`). Digits inside a word (`CUM3`) are not numbers. ### `numbers(text: str) -> list[str]` The numbers of a text, as written and in order. `3,510` is one number (a comma between groups of three digits is a thousands separator), `99.99th` is 99.99, `03:00` is two numbers, and digits inside a word (`CUM3`) are not a number. ### `class Misquote(said: str, key: str, fact: Any)` A number said of a fact that holds another one. `said` is the piece of the text, `key` the fact it speaks of (a path into `facts.json`: `peak.merging_mm`, `hourly[03:00].max_mm`), and `fact` what the facts hold there (`None` when nothing). ### `check_claims(text: str, facts: dict[str, Any]) -> list[Misquote]` The numbers of `text` said of the wrong fact (empty: none found). `check_text` asks whether a number is in the facts; this asks whether it is the number *of what the sentence says*. It reads the sentences of the template (`Report.text`): the totals of each product, the wettest place, its hours, the reliability, the hourly table, the frames. "The «Merging» gives 95.2 mm" where the facts give 95.2 mm to the radar alone is a misquote, and so is a figure rounded the wrong way ("118.1" for 118.04). A sentence written in other words is not read: a model that rephrases goes through `check_text` only. ### `build(read: Read, bbox: BBox, day: date, *, bulletins: Iterable[Bulletin] = ()) -> Report` The report of the rain of `day` (UTC) over `bbox`, from the frames `read` gives. `bulletins`: the criticality bulletins to look the wettest place up in (`bulletins_for`); those that do not cover the day are left out. ### `async download(radar: Source, day: date) -> Read` The frames of a day from the API, as a `read` for `build`. 33 requests: the 25 hourly `SRT1` frames (the hour before the day included) and the eight `CUM3`. A frame the DPC no longer keeps (older than about five months) is simply not there. ### `async bulletins_for(day: date, **http: Any = {}) -> list[Bulletin]` The bulletins that speak of `day`: the last one of the day before, and of the day. `http`: `client` or `send`, as in `dpc_radar.bulletins.fetch`. # Products and API ## `dpc_radar.products` The DPC radar products, and the requests and answers of the open radar API. Pure: nothing here does I/O. A client sends the requests built here and hands the answers back to the parsers. The API (`radar-api.protezionecivile.it`) has two calls that matter: * `GET /findLastProductByType?type=` gives the time of the latest frame and its period; * `POST /downloadProduct` with `{"productType", "productDate"}` gives a short-lived S3 link to the GeoTIFF of one frame. A frame the DPC no longer keeps (about five months back) does not answer 404: it answers **500** with S3's `403 Forbidden` in the body. `is_expired` tells the two failures apart, because an expired frame must not be retried. ### `class Product(name: str, hours: int | None, merging: bool, description: str)` One DPC radar product. #### `Product.period: timedelta` How often a new frame comes out: 30 minutes for the «Merging», 5 for radar only. The same as the `period` the API returns (`PT30M`, `PT5M`): the frame before one issued at `t` is the one issued at `t - period`. ### `product(name: str | Product) -> Product` The `Product` called `name`. ### `class LastProduct(product: Product, time: datetime, period: timedelta)` What `findLastProductByType` says about the latest frame. ### `last_product_url(name: str | Product, *, base: str = API_BASE) -> tuple[str, dict[str, str]]` URL and query parameters of the latest-frame request. ### `download_url(base: str = API_BASE) -> str` URL of the download-link request (a `POST`). ### `download_body(name: str | Product, at: datetime) -> dict[str, Any]` JSON body of the download-link request for the frame issued `at`. ### `to_epoch_ms(at: datetime) -> int` `at` as the API's milliseconds since the epoch; `at` must be aware. ### `from_epoch_ms(ms: int | float | str) -> datetime` The API's milliseconds since the epoch as an aware UTC datetime. ### `parse_period(text: str) -> timedelta` An ISO 8601 period of hours and minutes (`PT5M`, `PT30M`, `PT1H`). ### `parse_last_product(payload: dict[str, Any]) -> LastProduct | None` The latest frame, or `None` when the API lists none. ### `parse_download(payload: dict[str, Any]) -> str` The S3 link of a frame, from the download-link answer. ### `is_expired(status: int, body: str) -> bool` `True` when the API says the frame is no longer kept. That is a 500 carrying S3's 403 in the body, not a 404. Any other failure is worth retrying; this one never is. # Errors ## `dpc_radar.errors` The one exception this package raises. ### `class DpcRadarError()` An answer of the DPC radar API that this package cannot read, or a bad argument. # Riuso nella Pubblica Amministrazione dpc-radar legge dati aperti di un'amministrazione, il Dipartimento della Protezione Civile, e li rende usabili da chiunque. Questa pagina è per un ente che vuole usarlo: che cosa trova pronto, che cosa resta a lui, e come il progetto entra nel Catalogo del software di Developers Italia. ## La mappa sul sito del Comune La demo è una pagina fatta per stare sul sito di un ente. Usa [Bootstrap Italia](https://italia.github.io/bootstrap-italia/), il kit di interfaccia della PA, servito dalla pagina stessa senza CDN, ed è in italiano e in inglese. ![La pagina aperta sul Comune di Gioia del Colle](images/demo-comune.png) Si apre sulle coordinate dell'ente, con il nome dell'ente in testata, un segnaposto sul punto e la scheda di quel punto già aperta: - la pioggia di adesso e delle ultime 1, 3, 6, 12 e 24 ore; - quanto è rara quella pioggia in quel posto; - la previsione automatica delle prossime due ore, e la probabilità di pioggia; - i temporali entro 50 km, e dove vanno; - l'allerta ufficiale del bollettino di criticità per la zona, oggi e domani; - quanto ci si può fidare del radar in quel punto, e quali radar sono accesi. Senza coordinate la mappa si apre su Gioia del Colle, in Puglia. ```bash cp .env.example .env # nel file .env: # DPC_RADAR_LAT=40.7997 # DPC_RADAR_LON=16.9236 # DPC_RADAR_PLACE="Comune di Gioia del Colle" docker compose up ``` | Variabile | Che cosa fa | Senza | |---|---|---| | `DPC_RADAR_LAT`, `DPC_RADAR_LON` | le coordinate su cui la mappa si apre, in gradi decimali | Gioia del Colle | | `DPC_RADAR_ZOOM` | lo zoom di partenza, da 5 a 13 | 11 con le coordinate, 10 senza | | `DPC_RADAR_PLACE` | il nome mostrato in testata e sul segnaposto | «dpc-radar» | | `DPC_RADAR_LAYER` | che cosa mostra la mappa all'apertura: `now`, `1`, `3`, `6`, `12` o `24` | `now` | | `DPC_RADAR_TILES` | l'indirizzo delle tessere della mappa di sfondo | OpenStreetMap | | `DPC_RADAR_TILES_CREDIT` | l'attribuzione di quelle tessere | OpenStreetMap | Le stesse cose si possono dare nell'indirizzo, per incorporare la pagina in un'altra: ```html ``` Coordinate fuori dall'Italia, o scritte male, sono ignorate: la mappa si apre su Gioia del Colle. ## Che cosa resta all'ente Il progetto dà il software. Queste cose sono di chi lo pubblica. - **Non è un'allerta.** La pagina lo dice in fondo e in ogni scheda, e rimanda al bollettino di criticità. Non va presentata come servizio di allertamento. - **Attribuzione dei dati.** I dati radar sono del Dipartimento della Protezione Civile, CC BY-SA 4.0: la pagina lo scrive sulla mappa e in fondo, e va lasciato. - **La mappa di sfondo.** Le tessere vengono da OpenStreetMap, che così vede l'indirizzo IP di chi visita la pagina. Un ente che non vuole chiamate a terzi mette le proprie tessere in `DPC_RADAR_TILES`. È l'unica chiamata a terzi del browser: caratteri e stili sono serviti dalla pagina. - **Dati personali.** Il software non ne raccoglie: niente account, niente cookie, niente su disco. La lingua scelta resta nel browser di chi visita. - **Accessibilità.** La pagina ha il collegamento per saltare al contenuto, i comandi con nome e stato, e la scheda del punto come alternativa testuale alla mappa. Non ha avuto una verifica WCAG 2.1 AA completa: la dichiarazione di accessibilità è dell'ente, dopo la sua verifica. - **Ospitalità.** HTTPS, un limite alle richieste davanti all'API e l'aggiornamento dell'immagine sono di chi ospita (vedi `SECURITY.md`). ## Intelligenza artificiale Niente di ciò che la pagina e la libreria mostrano è scritto da un modello linguistico: i numeri sono calcolati dai dati radar con codice aperto, e la pagina lo dice in fondo. La previsione delle prossime due ore è l'ultima immagine radar spostata lungo il suo movimento. L'unico punto in cui il progetto chiama un modello, Claude di Anthropic, è un esperimento del benchmark, che si lancia a mano e con una chiave (`benchmarks/vision.py`). La tabella con i principi delle *Linee Guida per l'adozione di IA nella Pubblica Amministrazione* di AgID (versione 1.0, 9 novembre 2026) è nella [pagina iniziale](index.md#for-a-public-administration). La classe di rischio, la valutazione d'impatto e l'informativa agli utenti riguardano l'uso che l'ente ne fa, e sono sue. ## Il Catalogo di Developers Italia **Oggi: software open source di terze parti.** Il codice non è di una PA. Entra nel Catalogo con il file [`publiccode.yml`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/publiccode.yml) nel repository, con `codiceIPA` vuoto, e una segnalazione sul repository [`italia/catalogo-software`](https://github.com/italia/catalogo-software) con il modello «Aggiungi un software al Catalogo». **Domani: software a riuso.** Se un ente lo adotta e ne diventa titolare (art. 69 del CAD), lo dichiara con l'[onboarding](https://onboarding.developers.italia.it/) di Developers Italia; `codiceIPA` prende il codice dell'ente, e gli enti che lo usano vanno in `usedBy`. - [x] Repository pubblico, licenza Apache-2.0 - [x] README, documentazione, istruzioni di installazione con Docker - [x] `CONTRIBUTING.md`, `CHANGELOG.md`, `SECURITY.md` - [x] `publiccode.yml` valido per il validatore ufficiale, controllato a ogni modifica dalla CI - [x] Interfaccia con Bootstrap Italia - [ ] `publiccode.yml` sul ramo principale - [ ] Segnalazione su `italia/catalogo-software` - [ ] Verifica di accessibilità WCAG 2.1 AA della pagina La licenza è Apache-2.0, non EUPL-1.2: il Catalogo accetta le licenze open source approvate, e la EUPL è quella consigliata per il software di cui una PA è titolare. ## Fonti - [Developers Italia: pubblicare software per la PA](https://developers.italia.it/it/guide/pubblicare-software-per-la-pa) - [Catalogo del software](https://catalogo-software.developers.italia.it/) - [Lo standard publiccode.yml](https://yml.publiccode.tools/) - [AgID: linee guida su acquisizione e riuso di software per la PA](https://www.agid.gov.it/it/design-servizi/riuso-open-source/linee-guida-acquisizione-riuso-software-pa) - [Bootstrap Italia](https://italia.github.io/bootstrap-italia/) # Benchmark: known cases of the DPC radar data A small, fixed set of real frames where we already know the right answer. Every method that decides what to trust in a frame (a cleaning rule, a learned quality check, a reliability map) runs here before it reaches [Limen](https://github.com/agent-engineering-studio/limen). Without it, every improvement is an opinion. Tracked in [#2](https://github.com/agent-engineering-studio/dpc-radar/issues/2). ## The cases | Case | What happened | What a method must do | |---|---|---| | **Melito, 10 October 2026** | the Reggio Calabria storm: 175–185 mm in 24 h, forecast 20 mm | keep it: it is real | | **Lipari, same day** | a cloudburst the radar did not see | say the radar is not reliable there | | **The corrupted :30 series** | a smooth bell of up to 20,584 mm over Abruzzo in every CUM24 frame at :30, on 30/09–02/10, 08–11/10 and 21/10–03/11 ([limen#235](https://github.com/agent-engineering-studio/limen/issues/235)) | reject the frame, or at least every wrong pixel | | **The clean frame after it** | the :00 frame is right, but differs from the corrupted one before it | keep its pixels | | **Calm days, 4 and 6 October** | nothing | change nothing | | **A stuck rain gauge, 6–8 October** | 126.6 mm in every 3-hour frame for 33 hours on the Lazio–Abruzzo border (1,152 mm in CUM24), on a night the radar alone reads 0 | remove it: it is not rain | | **A gauge that fires at random, 29 September–26 October** | bursts of up to 130 mm in 3 hours north of Cassino, with a dry radar | remove it | | **A gauge stuck at 7 mm, 2–5 October** | 7.18 mm in 27 three-hour frames in a row east of L'Aquila, radar 0 | remove it | | **A gauge that always rains, 29 September–6 October** | 1 to 13 mm in 58 three-hour frames in a row in Irpinia, radar 0 | remove it | | **The same night, radar only (SRT1)** | nothing | change nothing | | **Melito, radar only (SRT1)** | one hour of the storm: 21 mm at Melito | keep it | | **Rain west of Sardinia, 20 October** | 59 mm at sea in round fields that do not move: it looked like sea clutter, it is a band of rain | keep it | | **The same band, radar only (SRT1)** | 21 mm in the hour it passes | keep it | Each case is one frame and the one before it (30 minutes for the «Merging», 5 for the radar-only `SRT1`), cropped to its area and committed in [`frames/`](frames/) (CC BY-SA 4.0, © Dipartimento della Protezione Civile). The DPC deletes frames after about five months: once committed, a case keeps working. ## Today's scores `limen-max-step` is what Limen does today: it throws away a pixel that moved more than 150 mm in 30 minutes. `accept-all` trusts everything. `jump-sign` is the first step of the frame quality check ([#6](https://github.com/agent-engineering-studio/dpc-radar/issues/6)): two frames 30 minutes apart can differ by at most half an hour of rain, so where they differ by more one of them is wrong, and the **sign** says which. The corruption always adds rain: the frame that jumps *up* is rejected whole, the one that jumps *down* (the clean frame after a corrupted one) is kept intact. `jump-sign-map` adds the reliability map ([#3](https://github.com/agent-engineering-studio/dpc-radar/issues/3)) to answer "can the radar be trusted here?". `quality` is what the library does today (`RainGrid.quality`): the same, plus three rules that need no frame before. The one that counts here compares the «Merging» with the radar alone over the same hours: rain that the radar did not see at all, where the radar sees well, is a rain gauge gone wrong. | Case | Check | `accept-all` | `limen-max-step` | `jump-sign` | `jump-sign-map` | `quality` | |---|---|---|---|---|---|---| | `melito-2026-10-10T06` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `melito-2026-10-10T06` | Melito di Porto Salvo: 100-300 mm | ✅ 174.7 mm | ✅ 174.7 mm | ✅ 174.7 mm | ✅ 174.7 mm | ✅ 174.7 mm | | `melito-2026-10-10T06` | Bagaladi: 80-250 mm | ✅ 113.1 mm | ✅ 113.1 mm | ✅ 113.1 mm | ✅ 113.1 mm | ✅ 113.1 mm | | `melito-2026-10-10T06` | Melito di Porto Salvo: the radar saw the storm: reliable | — no reliability | — no reliability | — no reliability | ✅ reliable | ✅ reliable | | `melito-2026-10-10T06` | Lipari: a cloudburst the radar did not see: not reliable | — no reliability | — no reliability | — no reliability | ✅ not reliable | ✅ not reliable | | `melito-2026-10-11T00` | Melito di Porto Salvo: 150-300 mm | ✅ 184.9 mm | ✅ 184.9 mm | ✅ 184.9 mm | ✅ 184.9 mm | ✅ 184.9 mm | | `bell-2026-10-11T0930` | frame rejected | ❌ usable | — no frame decision | ✅ rejected | ✅ rejected | ✅ rejected | | `bell-2026-10-11T0930` | the bell's peak (7,348 mm): 0-100 mm or not measured | ❌ 6180.7 mm | ✅ not measured | ✅ not measured | ✅ not measured | ✅ not measured | | `bell-2026-10-11T0930` | the bell's edge: 88 mm where the :00 frame reads 9: 0-30 mm or not measured | ❌ 87.7 mm | ❌ 87.7 mm | ✅ not measured | ✅ not measured | ✅ not measured | | `after-bell-2026-10-11T10` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `after-bell-2026-10-11T10` | Gran Sasso, the point of limen#235 (7.3 mm in the :00 series): 2-30 mm | ✅ 7.3 mm | ❌ not measured | ✅ 7.3 mm | ✅ 7.3 mm | ✅ 7.3 mm | | `bell-2026-10-09T0630` | frame rejected | ❌ usable | — no frame decision | ✅ rejected | ✅ rejected | ✅ rejected | | `bell-2026-10-09T0630` | the bell's peak (13,226 mm): 0-100 mm or not measured | ❌ 10184.8 mm | ✅ not measured | ✅ not measured | ✅ not measured | ✅ not measured | | `bell-2026-10-25T0630` | frame rejected | ❌ usable | — no frame decision | ✅ rejected | ✅ rejected | ✅ rejected | | `bell-2026-10-25T0630` | the bell's peak (10,861 mm): 0-100 mm or not measured | ❌ 6510.3 mm | ✅ not measured | ✅ not measured | ✅ not measured | ✅ not measured | | `calm-2026-10-04T06` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `calm-2026-10-04T06` | at most 0.1% of pixels masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.02% masked | | `calm-2026-10-06T06` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `calm-2026-10-06T06` | at most 0.1% of pixels masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.01% masked | | `steady-bump-2026-10-07T12` | the bump (1,152 mm): 0-300 mm or not measured | ❌ 999.9 mm | ❌ 999.9 mm | ❌ 999.9 mm | ❌ 999.9 mm | ✅ not measured | | `stuck-gauge-cum3-2026-10-07T06` | the stuck gauge (126.6 mm in 3 h, radar 0): 0-20 mm or not measured | ❌ 126.6 mm | ❌ 126.6 mm | ❌ 126.6 mm | ❌ 126.6 mm | ✅ not measured | | `burst-gauge-cum3-2026-10-02T06` | the gauge (129.9 mm in 3 h, radar 0): 0-20 mm or not measured | ❌ 129.9 mm | ❌ 129.9 mm | ❌ 129.9 mm | ❌ 129.9 mm | ✅ not measured | | `stuck-low-cum3-2026-10-04T06` | the gauge (7.2 mm in 3 h, 27 times in a row, radar 0): 0-1 mm or not measured | ❌ 7.2 mm | ❌ 7.2 mm | ❌ 7.2 mm | ❌ 7.2 mm | ❌ 7.2 mm | | `drizzle-gauge-cum3-2026-10-03T06` | the gauge (12.6 mm in 3 h, radar 0): 0-1 mm or not measured | ❌ 12.6 mm | ❌ 12.6 mm | ❌ 12.6 mm | ❌ 12.6 mm | ❌ 12.6 mm | | `stuck-gauge-srt1-2026-10-07T06` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `stuck-gauge-srt1-2026-10-07T06` | over the stuck gauge: dry: 0-1 mm | ✅ 0.0 mm | ✅ 0.0 mm | ✅ 0.0 mm | ✅ 0.0 mm | ✅ 0.0 mm | | `stuck-gauge-srt1-2026-10-07T06` | at most 0.1% of pixels masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | ✅ 0.00% masked | | `melito-srt1-2026-10-10T02` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `melito-srt1-2026-10-10T02` | Melito di Porto Salvo, one hour: 10-100 mm | ✅ 21.2 mm | ✅ 21.2 mm | ✅ 21.2 mm | ✅ 21.2 mm | ✅ 21.2 mm | | `melito-srt1-2026-10-10T02` | Bagaladi, one hour: 10-100 mm | ✅ 24.5 mm | ✅ 24.5 mm | ✅ 24.5 mm | ✅ 24.5 mm | ✅ 24.5 mm | | `sardinia-disks-2026-10-21T00` | at sea, inside the 'disks' (59 mm): 20-120 mm | ✅ 56.2 mm | ✅ 56.2 mm | ✅ 56.2 mm | ✅ 56.2 mm | ✅ 56.2 mm | | `sardinia-band-srt1-2026-10-20T13` | frame usable | ✅ usable | — no frame decision | ✅ usable | ✅ usable | ✅ usable | | `sardinia-band-srt1-2026-10-20T13` | at sea, under the band: 10-60 mm | ✅ 21.5 mm | ✅ 21.5 mm | ✅ 21.5 mm | ✅ 21.5 mm | ✅ 21.5 mm | | **Score** | confirmed · suspect | confirmed: 19/33 | confirmed: 14/33 | confirmed: 26/33 | confirmed: 28/33 | confirmed: 31/33 | "—" means the method does not decide; it counts as not passed. ### What the table says - **The 150 mm rule removes the bell's peak, but not its edges.** Around every peak, 5,000–7,000 pixels per corrupted frame are off by 10–150 mm and pass: on 11 October, 88 mm where the truth is 9. - **It also hurts the clean frame that follows a corrupted one**: Gran Sasso becomes "not measured" although the frame is right. A rule that compares two frames cannot tell which of the two is wrong. - **Nothing decides on the whole frame.** A corrupted :30 frame correlates 0.04–0.33 with the :00 one beside it; a frame-level check would drop it whole, and keep the clean one. - **A stuck gauge is invisible to a jump rule**: it does not move between frames. Only `quality` removes it, because it looks at the radar alone: the «Merging» reads 126.6 mm, the radar 0, and the radar sees that valley well. - **Two faulty gauges pass every method.** One is stuck at 7.2 mm, one reads 1 to 13 mm for a week, both with a dry radar. `quality` asks for 30 mm before it calls a patch a gauge fault, because under that a single frame cannot tell a gauge from light rain the radar missed. What gives them away is the series of the place: the same value to the hundredth 27 times, rain in 58 frames in a row. No method here reads a series yet. - **It does not pay for it with real rain.** Melito, the band off Sardinia and Lipari stay as they are. Lipari is the hard one: 31 mm in the «Merging» and nothing on the radar, like a faulty gauge, but there the radar is blind and the rule stays silent. - **The "calm" days were not all calm.** On 4 and 6 October `quality` masks 193 and 59 pixels (0.02 % and 0.01 % of the frame): two more places where the «Merging» reads 67–77 mm under a radar that reads nothing. - **The radar-only frames are clean.** No method breaks the three `SRT1` cases, and in 3,838 hourly frames from June to November 2026 the highest value is 204 mm in an hour, in a summer storm: nothing like the bell. - **The 7,348 mm "isolated pixel"** that Limen's 3×3 median was meant to remove is the peak of the corrupted bell: its 3×3 neighbours have a median of 6,381 mm. The median does not remove it; the 150 mm rule does. - **Without a map nobody knows where the radar is blind.** With `dpc_radar.reliability` Lipari scores 0.42: the lowest beam that reaches it passes 3,500 m above the island, over the top of a low cloudburst. Melito, 60 km away, where the radar measured what the gauges did, scores 0.90: a map that called everything unreliable would not pass. ### Checked on whole frames, not only on the cases Fourteen cases are few, and they are cropped. `benchmarks.season` runs a method on every pair of whole frames in a folder. On the 96 pairs of CUM24 frames kept from 25 September to 4 November 2026, `jump-sign` rejects **44 frames, all at :30, all on the days the :30 series is known to be corrupted**, and **no frame at :00**, not even during the Melito storm. It also catches what the daily check missed: smaller corruptions in the evening of 11 October (:30 frames at 370–430 mm where the :00 ones read ~170) and one :30 frame on 7 October. ```bash uv run --group bench python -m benchmarks.season .cache/dpc-radar/CUM24 jump-sign ``` **The limits of the jump rule.** It needs the frame before. It assumes a corruption adds rain: a corruption that removes it would be read the wrong way round. A real cloudburst of more than 150 mm in 30 minutes on five pixels would be rejected (that is near the Italian records for 30 minutes). And it cannot see what does not move between frames: for the stuck gauge it takes the radar alone. The gauge rule of `quality` was measured the same way, on the 1,270 three-hour «Merging» frames (`CUM3`) kept from 9 June to 16 November 2026, each against the sum of its three hourly radar frames. It masks 10,266 pixels in 154 frames: 2.4 % of the pixels with 30 mm or more. They are not spread at random: they fall in 79 places, and seven come back again and again. One, near 13.985°E 41.685°N, is in more than 30 frames from July to October, often between 06 and 09 UTC, with up to 136 mm under a sky that is dry for 100 km around. Another, near 10.685°E 44.195°N, is in 16 frames in a row on 4–6 August. The outlier rule masks 4 pixels in those 1,270 frames and none in 1,280 hourly radar frames; no value is beyond the Italian record. A whole frame takes about 0.17 s. **The limits of the gauge rule.** We have no gauge readings: that a place is a faulty gauge is what the radar says, confirmed by hand only for the stuck gauge of 6–8 October. A radar that is on but reads 0 under real rain, where the map says it sees well, would make the rule remove real rain: the `visibility` and `coverage` of the map are there to avoid it, and they describe 2026. Where the radar is blind a faulty gauge is kept. A gauge that reads too little is not seen at all. And there is no trained model: fourteen cases are too few to train one, so these are rules with thresholds that can be read in [`quality.py`](https://github.com/agent-engineering-studio/dpc-radar/blob/main/src/dpc_radar/quality.py). ### Two cases we had read wrong Both were *suspect* until November 2026. The hourly radar frames (`SRT1`) and the 3-hour «Merging» (`CUM3`) of the same days, kept in a local archive, settled them without a rain gauge. - **The steady bump is a stuck rain gauge.** `CUM3` reads 126.6 mm at the same point in every window from 6 October 12 UTC to 7 October 09 UTC (126.62, 126.63, 126.63, 126.79 in the last four) and 114–143 mm until 21 UTC: about 1,400 mm in 33 hours. The radar alone reads 0.0 in all those hours, and on 8 October the point is back to 0. The «Merging» spread that gauge over more than 350 km². So the gauges can be wrong too, not only the radar. - **The Sardinia disks are rain.** We took the round fields at sea for sea clutter. Hour by hour the radar shows a band of rain crossing from west to east between 10 and 15 UTC: 19, 22 and 2 mm at the point of the case, 0 before and after. The circles are the edges of the radars' range, where the mosaic ends. The case now asks the opposite: a method must **keep** that rain. Over the sea there is no gauge, so the amount is the radar's own. ## Run it ```bash uv sync --group bench uv run --group bench python -m benchmarks.run # every method uv run --group bench python -m benchmarks.run limen-max-step # one method uv run --group bench python -m benchmarks.run --markdown # the table above ``` CI runs `python -m benchmarks.run --check`: it fails when an outcome differs from [`results.json`](results.json), so a change in a case or a method is always a visible decision. After an intended change, run it with `--record` and commit `results.json`. ## An experiment: the cases as pictures The rules above see numbers, not shapes. [`vision.py`](vision.py) asks whether a model that looks at the map sees more: it draws every case as the frame before, the frame and the radar alone, sends the picture to the Claude API, and scores the answer on the same checks. ```bash uv run --group vision python -m benchmarks.vision render out/ # the pictures: no key uv run --group vision python -m benchmarks.vision ask # call the API, save the answers uv run --group vision python -m benchmarks.vision score # the table, from the answers ``` `ask` needs `ANTHROPIC_API_KEY` and spends money (14 requests, one picture each). The answers are saved in `vision-answers.json`, one set per model, so `score` is free and repeatable. The model gets the picture and the name of the product: not the title of the case, not its date, not a number above the 500 mm where the scale stops. It does not answer "can the radar be trusted here?", so its ceiling was 28 of the 30 checks of that day. It is not in `METHODS` and CI does not run it: it needs a key, and the same picture can get two answers on two days. **The first run** (18 November 2026, `claude-opus-5-5`, 14 requests, 31,542 tokens in and 7,612 out): **26 of 30**, of the 28 it can reach. - It rejected the three corrupted frames and kept the clean one after them. - It masked the stuck gauge in both frames, with the right reason: a smooth patch the radar alone does not see. - It kept the rain west of Sardinia, round edges included, and every frame of the Melito storm. - **It failed the two calm days**, where it masked 0.59 % and 0.13 % of the pixels (the limit is 0.1 %). What it masked are four smooth patches of the «Merging», up to 67, 66, 26 and 27 mm in 24 hours, where the radar alone reads 0.0 on every pixel. - In the clean frame after the bell it also boxed a patch of 222 mm that the case does not ask about. **Checked on the 3-hour frames** (580 frames of `CUM3` and `SRT1`, 29 September to 13 October and 23 to 27 October 2026): the patches are three rain gauges gone wrong, and the two "calm" days are not calm. | Where | What the «Merging» (`CUM3`) says | The radar alone, same hours | |---|---|---| | 13.725 E, 42.365 N | 7.2 mm in each of 27 blocks in a row, from 2 October 12 UTC to 5 October 18 UTC; then 14 to 15 mm a block until 7 October 06 UTC | 0.0 | | 13.985 E, 41.685 N | bursts with no pattern, up to 130 mm in 3 hours (2 October 06 UTC), from 29 September to at least 26 October: this is also the 222 mm of 11 October | 0.0 in the bursts | | 15.385 E, 41.215 N | rain in every block for a week, 58 in a row, 1 to 13 mm, from 29 September 09 UTC to 6 October 12 UTC, then nothing | 0.0 | The three are now cases of the benchmark, so `score` lists them as not asked: the saved answers are older than them. `quality` removes the second and lets the other two pass, as the table above says. The known stuck gauge (13.795 E, 41.805 N) was already wrong two days before the date of its case: 2.1 mm a block from 4 October 06 UTC. `quality` already removes the heart of the first two, where the «Merging» has 30 mm or more (`GAUGE_MIN_MM`): 193 pixels on 4 October, 59 on the 6th. It keeps what is under 30 mm: the rim of those patches, and the whole of the third. A fault of 3 mm a block, every block for a week, is 26 mm in a day and no threshold on one frame sees it; what gives it away is that it never stops. That is a rule on the series, not on the frame, and it is not written yet. Nor are these three cases in `cases.toml` yet. So the picture did not beat the rules on the cases we knew, and it pointed at three faults we had not looked at. That is the use it is good for here: proposing cases, which a person then confirms on the numbers. ## How faithfully a text quotes the facts The tools of the MCP server answer with facts; a model turns them into words. [`faithful.py`](faithful.py) measures what it does with the numbers. The set, [`faithful.json`](faithful.json), holds five questions on the night of Melito (the rain at a point over one and three hours, over a box, how rare it is, the report of the day), the facts the tools gave, recorded once from the archive, and answers. For every number of an answer the set says what the sentence says it is (a path into the facts), and the score is arithmetic: | Kind | The number, against the fact it is said of | |---|---| | `faithful` | the fact, to the decimals written, or the key it is said of (20 in "205.1 km² got 20 mm or more") | | `approximate` | a round number, the fact rounded to its zeros ("about 3,000 km²" for 3,002): not a fault | | `question` | not a fact: it repeats the question | | `rounded` | within one unit of the last digit, and not the fact (118.1 for 118.04) | | `swapped` | another figure of the same facts | | `invented` | none of these | ```bash uv run python -m benchmarks.faithful score --check # free, no network uv run --group vision python -m benchmarks.faithful ask # a model writes (API key) uv run --group vision python -m benchmarks.faithful label # a second model reads ``` Ten answers are written by hand, one faithful and one with known faults per question; `score --check` fails if they do not score as written, and runs in CI. Then a model: Claude Opus 5.5 answered the five questions (`ask`), and Claude Sonnet 5.5 read what each number is said of (`label`), on 22 November 2026: | Author | Answers | Numbers | faithful | approximate | rounded | swapped | invented | faults `check_text` misses | |---|---|---|---|---|---|---|---|---| | hand, faithful | 5 | 46 | 46 | 0 | 0 | 0 | 0 | - | | hand, with faults | 5 | 40 | 23 | 0 | 4 | 8 | 5 | 8 of 17 | | claude-opus-5-5 | 5 | 111 | 105 | 5 | 0 | 1 | 0 | 1 of 1 | **What the table says.** On the hand answers `check_text` refuses the invented and the badly rounded numbers, and lets every swapped one through: that is what the set is for. The model quoted 111 numbers and got 110 right: 105 as they are in the facts, 5 rounded to a round number on purpose ("about 3,000 km²" of land over 50 mm, for 3,002; "around 600 km²" for 646). The one counted as swapped is not a fault: "only the wettest 5 % of the area got more than 20.7 mm" reads the 95th percentile from the other side, and the score knows the 95 only as the name of a fact. No invented number, no wrong rounding, no swap. Five questions are few: this says the model can be faithful, not that it always is. **The reader.** Sonnet's labels give the 86 numbers of the hand answers the same score as the hand's on 84, and the same verdict (a fault or not) on all 86. The two that differ are a date read as part of the question instead of as a fact: both are no fault. Once, on the rarity answer, it gave one label too many; `label` reads again any answer whose labels do not follow its numbers. **Found on the way.** The model writes thousands with a comma (3,510 km²) and ordinals (99.99th): `check_text` read "3,510" as 3 and 510, and "99.99th" as 99. `dpc_radar.report.numbers` now reads them as written, and `check_text` with it. As in Limen's reviewer (`fedelta`), the reader only says what a number is about; whether it is right is arithmetic. Running `ask` and `label` again costs about 20 short requests. ## Add a method A method answers three questions about a frame and the one before it (`radar` is the radar-only rain over the same window, for the cases that have `radar = true`; `None` for the others) (see `Method` in [`bench.py`](bench.py)): ```python @dataclass(frozen=True) class MyCheck: name: str = "my-check" description: str = "what it does, in one line" def frame_ok( self, frame: Frame, previous: Frame, radar: Frame | None ) -> bool | None: ... # is the frame usable at all? None: no decision def clean( self, frame: Frame, previous: Frame, radar: Frame | None ) -> np.ndarray: ... # the frame with untrusted pixels set to NaN def reliable( self, lon: float, lat: float ) -> bool | None: ... # can the radar be trusted here? None: no decision ``` Register it in `METHODS` in [`methods.py`](methods.py), run it, and compare. Points are read as Limen reads them: the median of the valid 3×3 pixels. ## Add a case 1. Add a `[[case]]` to [`cases.toml`](cases.toml): the product, the frame time, the area, where the truth comes from, and its checks. Mark it `suspect` until the answer is confirmed (rain gauges, the news, the DPC, the radar-only frames of the same hours). With `radar = true` the case also gets the radar-only rain of the same window (for a «Merging» product). 2. `uv run --group bench python -m benchmarks.fetch` downloads and crops it (only frames younger than about five months still exist). 3. Run the benchmark, check the outcomes, `--record`, commit. # Roadmap and AI Where dpc-radar goes next, and how AI and machine learning can make the radar data better. Nothing here is a promise. Every item has an issue: comment there before you start. The whole plan is tracked in [#10](https://github.com/agent-engineering-studio/dpc-radar/issues/10). !!! note "Where this stands (November 2026)" Every phase of this plan is in the library, and #10 is closed. dpc-radar is a library on its own: install it, or run it with [Docker and the demo](index.md#run-it-on-your-machine), with no other project. This page is the record of the plan and of what each phase measured. The plan was written for the library's first user, Limen, and its goal is the yardstick below; what is still open on that side (adopting the new functions, the history before 2018, the faulty gauges, the news check of the catalogue) is tracked in [limen#643](https://github.com/agent-engineering-studio/limen/issues/643). dpc-radar was born inside [Limen](https://github.com/agent-engineering-studio/limen), an open early-warning system for landslides, floods and wildfires in Italy. Limen uses the DPC radar three ways: as a **trigger** (heavy rain on the radar starts a run at once), as **rain already fallen** (the «Merging» totals feed the flood score and the wildfire drought codes), and as **history** (radar rain from 2010 to 2025 replays past landslides). Every improvement below lands in this library first, for everyone, and Limen gets it by updating one pin. ## The goal we measure against Limen has one goal that decides whether it is useful ([limen#345](https://github.com/agent-engineering-studio/limen/issues/345)): **anticipate within 72 hours 90 % of the landslides, floods and wildfires reported in the news, with at most 10 % of municipality-days on alert.** The two numbers always go together: without the second, it is easy to catch everything by putting everything on alert. On 29 October 2026 Limen anticipated **0 of 4** landslides and **0 of 4** floods. The radar is part of the reason, and of the fix. ## What limits Limen today | Problem | Where it shows | What the radar has to do with it | |---|---|---| | **Alerts were the background, not a forecast** | the four landslides were ≥ Moderate for 64–80 h, but so were ordinary days ([limen#345](https://github.com/agent-engineering-studio/limen/issues/345)) | one national rain threshold cannot work: 50 mm is common in Liguria, exceptional in Apulia | | **Too few events to measure** | "eight events are an anecdote, not a statistic" | the radar sees every storm, including the ones nobody has verified yet | | **Corrupted frames** | pixels moving 900–20,584 mm between frames ([limen#235](https://github.com/agent-engineering-studio/limen/issues/235)) | today a fixed rule, `max_step_mm: 150`, throws them away | | **A blind radar reads as dry** | the cloudburst on Lipari, 10/10/2026, which the radar did not see | Limen cannot tell "no rain" from "no radar here" | | **The radar arrives late** | Melito, 10/10/2026: forecast 20 mm, radar 152 mm | the radar only shows rain that has already fallen | | **A biased history** | the radar-only archive read 10–80 % of the gauges in Apulia in 2016 | landslide backtests ([limen#243](https://github.com/agent-engineering-studio/limen/issues/243)) rest on it | ## How we introduce AI ```mermaid flowchart LR B["Benchmark
known cases"] --> P0["Phase 0
reliability map
climatology
storm catalogue"] P0 --> P1["Phase 1
frame quality check"] P1 --> P2["Phase 2
nowcasting
radar–gauge bias"] P2 --> P3["Phase 3
MCP · llms.txt
event reports"] P0 & P1 & P2 & P3 -.->|"one pin: dpc-radar~=x.y"| L["Limen
measured on its 72 h goal"] ``` 1. **Benchmark first, then models.** A fixed set of cases where we already know the answer. Every method passes it before it reaches Limen. 2. **Machine learning on the data, language models only on language.** Statistics, gradient boosting and optical flow work on the frames. A language model may read news, choose what to compute and explain the result in words. 3. **Measured on Limen's goal.** Each item says which number of limen#345 it should move, and how we check it. !!! warning "Ground rule for every AI feature" Rain values come from DPC frames, read by code that is tested. A language model never produces a millimetre, a time or a place itself. Every answer names the product and the frame time it came from. Nothing this library produces is an official warning: the official one is the DPC criticality bulletin, and every AI output links to it. --- ## Phase 0 · now, without touching Limen's code This phase works on notebooks, data and the benchmark. Limen's radar code (`grid`, `client`) can move here at any time: Limen is not in operation yet, so there is no date to wait for. ### Benchmark of known cases · [#2](https://github.com/agent-engineering-studio/dpc-radar/issues/2) · ✅ first version Fourteen real cases in [`benchmarks/`](benchmark.md): the Melito storm and the Lipari miss of 10 October 2026, the corrupted :30 CUM24 series (found on 30/09–02/10, 08–11/10 and 21/10–03/11), the clean frame right after a corrupted one, two calm days, a stuck rain gauge (1,152 mm in CUM24 on a dry night), a band of rain at sea that looked like clutter, and three hours of radar only (`SRT1`). Limen's rule today passes **14 of 33** checks: it has no frame-level decision, lets the edges of the corrupted bell through (88 mm where the truth is 9), throws away good pixels after a corrupted frame, and cannot see steady artefacts or blind spots. The library passes 31 since the frame quality check (#6), which removes the stuck gauge; the two it misses are gauges wrong by a few millimetres, added in November 2026, that only the series of a place can show. No case is *suspect* any more: the two that were have been settled on the hourly radar frames (one was not rain, one was). Still missing: a check against the rain gauges themselves, which the DPC does not publish. ### Radar reliability map · [#3](https://github.com/agent-engineering-studio/dpc-radar/issues/3) · ✅ first version [`dpc_radar.reliability(lon, lat)`](api/reliability.md) gives a score between 0 and 1 and its parts, from a map shipped with the package (720 kB, 1 km): - **visibility**: the height above the ground of the lowest beam that reaches the point without being cut by a mountain, from the 24 radar sites and an open terrain model; - **coverage**: how often the mosaic has data there. From June to November 2026 the radars of Calabria and Apulia were on 36–61 % of the time, and the west of Sicily was never covered; - **agreement**: the radar alone (SRT1) against the «Merging» (CUM3) over the same months: around Palermo the radar read 29 % of the gauge-corrected rain. Since [#44](https://github.com/agent-engineering-studio/dpc-radar/issues/44) it leaves out the windows of a rain gauge gone wrong, and is not known on the 2,660 km² around gauges that report rain under a dry radar most of the time (Foggia went from 0.18 to 0.93). **Check:** Lipari scores 0.42 (beam at 3,500 m), Melito 0.90; the benchmark case passes, with a second check that a map calling everything unreliable would fail. **What is not there.** The density of rain gauges: the DPC does not publish the gauges that enter the «Merging». The positions of seven radars come from the DPC's table; the others were found by fitting their range circles on the mosaic's no-data mask, and four that are always hidden under the others come from the literature. Coverage and agreement describe five months, not a climate. Which radars are on at a time is read from the file of the DPC viewer ([`radar_status`](api/status.md)): it is not documented and does not always agree with the mosaic, so it does not enter the score. Limen does not use the map yet. ### Rain climatology · [#4](https://github.com/agent-engineering-studio/dpc-radar/issues/4) · ✅ first version: eight years, in radar millimetres [`dpc_radar.rarity(window, lon, lat, mm)`](api/climatology.md) answers "this rain is a 1-in-N-years event here" for 1, 3, 6 and 24 hours: a percentile and a return period with its 90 % interval. `return_level` gives the rain of a return period, `return_period(frame)` the return period of every pixel. The map ships with the package (1.6 MB, cells of 5 km): a GEV of the highest window of the year, the location from the cell, the spread from the 55 km around it, one shape for Italy. What the history says first: **it is not one series**. Until 2017 the mosaic read about two thirds of what it reads since 2018 (the highest hour of the year over today's map: 0.64–0.90 before, 1.09–1.35 after). A map on all sixteen years puts 61 % of the pixels over their 2-year level in five months of 2026. So the map stands on 2018–2025, and fewer than one frame in a thousand, corrupted, is left out (`history.suspect`). **Check:** fitted on six years and asked about the other two. The 2-year level is passed by 52 % of the pixels in a year (it should be 50), the 5-year by 24 % (20), the 10-year by 14 % (10), the 20-year by 8 % (5): "10 years" came about every 7, "20 years" every 13. On the hourly frames of 2026 the 1 h levels behave the same; the 24 h levels are passed more. The [tables](api/climatology.md#the-measure-in-full) are in the reference. **What was tried and dropped.** A fit pixel by pixel, and one with the shape of each cell: on held-out years the 20-year level was passed by 9–10 % of the pixels. A shape by area (55 km, 205 km): no better than one for Italy, and a blotchy map. **What is not there.** - **More years.** Eight years cannot say what a 50-year rain is; the map stops there and its interval is wide (at 50 years, from 0.8 to 1.5 times the level). The years before 2018 could be used only after bringing them to today's scale, and nothing here says how. - **Rain-gauge millimetres.** The levels are those of the radar alone, which reads more than the gauges over most of the land (#8). They are not the official rainfall curves, and on a radar-only frame the return period brings the faults of the frame: on 2 November 2026 the radar alone was over the 10-year level on twice the area of the «Merging». - **Limen.** Nothing here measures limen#345: whether judging rain against the place gives fewer municipality-days on alert without losing events is to be measured in Limen, on held-out seasons. The 2018 step also touches its backtests on the history ([limen#243](https://github.com/agent-engineering-studio/limen/issues/243)). ### Storm catalogue · [#5](https://github.com/agent-engineering-studio/dpc-radar/issues/5) · ✅ first version: candidates, not yet verified [`dpc_radar.storms(frame, threshold=)`](api/storms.md) gives the patches of rain of a frame as objects (centre, area, peak) and `track` follows them from frame to frame (duration, path, speed, water). [`dpc_radar.rare_events(frames)`](api/catalogue.md) reads hourly frames, sums them over 1, 3, 6 and 24 hours and gives the rain over the level of its place (#4) as events, the rarest first; `with_merging` adds what the «Merging» says of each. `tools/build_catalogue.py` writes the list as a CSV. **Check:** on the 160 days of 2026 in the archive, on land and where the radar is reliable: 1,689 events over the 10-year level (317 a month; the «Merging» confirms 1,054), 339 at the 50-year ceiling (64 a month; 214 confirmed). Of the two events of the season we knew, the flood of Melito di Porto Salvo is found (rank 172; 113 among the confirmed) and Lipari is not: the radar is nearly blind there. The [tables](api/catalogue.md#the-measure-in-full) and the [list](data/rare-rain-2026.csv) are in the reference. **What it taught.** The list is long. A return period is about one place, and on the hourly frames of 2026 the levels of the climatology are passed two to five times more often than their name says: the return period is a ranking. The single rarest pixel is often an echo, so an event is ranked by the level its rarest 10 km² reach. June is full of one-hour summer storms over the Apennines, where hail may make the radar read too much. **What is not there.** - **Verified events.** "New verified events per month" is still to count: the catalogue gives candidates, and the check in the news is Limen's. Its eight verified events live in its database, so how many of them the catalogue finds was not measured. - **Municipalities.** An event carries the name of its alert zone and a point; the join with the municipalities is Limen's. - **The history.** Only the 2026 season was listed. --- ## Phase 1 · now that `grid` and `client` are here ### Frame quality check · [#6](https://github.com/agent-engineering-studio/dpc-radar/issues/6) · ✅ first version, rules not a model [`RainGrid.quality`](api/quality.md) gives a score per frame, a mask per pixel and the reason for each masked pixel. Four rules, each with a threshold measured on the frames kept from June to November 2026: - **jump**: where two frames 30 minutes apart differ by more than half an hour of rain, the one that jumps up is rejected whole (`jump-sign`). On 96 pairs of whole frames it rejects the 44 corrupted :30 frames and no :00 frame; - **beyond the record**: more than the most rain ever measured in Italy over the window. It needs no frame before; - **outlier**: a pixel far above the 5×5 around it; - **gauge only**: «Merging» rain that the radar alone did not see, where the radar sees well. It removes the stuck gauge, and on 1,270 three-hour frames it finds the same fault in 154, mostly at seven places that come back. **Check:** the benchmark, 31 of 33 (Limen today: 14); the calm days lose 0.02 % of their pixels, and those are two more faulty gauges. **What is not there.** A trained model: fourteen labelled cases are too few, and the rules are the features it would use. Symmetry around a radar site and rain over the sea against the land nearby: the one case we had for them turned out to be rain. A check against the gauges themselves, which the DPC does not publish: that a gauge is faulty is the radar's word, confirmed by hand once. A faulty gauge where the radar is blind is kept. The `agreement` part of the reliability map leaves those gauges out since [#44](https://github.com/agent-engineering-studio/dpc-radar/issues/44). Limen does not use `quality` yet. **For Limen:** fewer false triggers and one rule for flood, wildfire and the trigger. ### Foundations: the code that comes from Limen | Module | What it does | Status | |---|---|---| | `products` | the six products, the API requests and answers, `is_expired` | ✅ done | | `grid` | `RainGrid`: read a frame, sample a point with the **3×3 median**, peak, crop, `check` against the frame before (`jump-sign`) and `quality` | ✅ done | | `client` | `RadarClient.latest(product)`, `.at(product, time)` → a grid or `ABSENT`; injectable `httpx` client, retries, `send=` hook | ✅ done | | `archive` | `archive()` and `MergingArchive`: save the «Merging» before the DPC deletes it; hourly rain, SRT1 rescaled to CUM3 | ✅ done | | `history` | `SriHistory`: the IT-DPC-SRI archive (2010–2025) with no zarr or xarray | ✅ done, extra `[history]` | | `bulletins` | the daily DPC criticality bulletin as data: levels per zone, municipalities, zone at a point | ✅ done, extra `[bulletins]` | --- ## Phase 2 · more lead time, a better history ### Nowcasting 0–2 hours · [#7](https://github.com/agent-engineering-studio/dpc-radar/issues/7) · ✅ first version: the rain moved, not changed [`dpc_radar.nowcast(frames)`](api/nowcast.md) moves the latest SRI frame forward along the motion the rain had in the last half hour, every five minutes up to two hours; `rain_ahead` sums it into millimetres, `chance` gives the chance of at least so many millimetres at every pixel, `motion` the speed and heading. Everything is a `Forecast`, never a `RainGrid`: a forecast cannot be taken for observed rain. On 120 moments of heavy rain drawn from the history of 2021–2025 it beats the last frame left still at every threshold and lead: for rain of 1 mm/h the CSI is 0.47, 0.34 and 0.23 at 30, 60 and 120 minutes (persistence: 0.38, 0.27, 0.19); for 10 mm/h it is 0.17, 0.08 and 0.04 (0.10, 0.05, 0.03). The chance is reliable: of the pixels given 40–60 % of 10 mm in the next hour, 39 % got them. The [tables](api/nowcast.md#the-measure-in-full) are in the reference. **What is still open:** - **Growth and decay.** A storm that is born after the last frame is not in the forecast. On the night of Melito di Porto Salvo the storm was born again and again over the same place: the two-hour forecast for the town went from 4 to 45 mm while the radar saw 21 to 39, and the chance of 20 mm stayed between 0.2 and 0.55. - **An ensemble** (STEPS): `chance` is the share of the forecast around a pixel, not a set of possible futures, and says nothing about a catchment as a whole. - **The check on the storm catalogue**: the 2026 archive has hourly frames, and a nowcast needs one every five minutes. - **limen#345**: whether a trigger on `chance` anticipates more events, and at what cost in municipality-days on alert, is measured in Limen. - A deep-learning nowcast stays a research notebook. ### Radar–gauge bias model · [#8](https://github.com/agent-engineering-studio/dpc-radar/issues/8) · ✅ first version: a map, not a model, and not for the history [`dpc_radar.correct(frame)`](api/bias.md) multiplies a radar-only frame by a factor measured place by place: the rain of the «Merging» (CUM3) over the rain of the radar alone (three SRT1 hours) from June to November 2026, over 9 km, on land. The map ships with the package (110 kB). What the archive says first: the radar alone read **20 % more** rain than the «Merging» (33 % more on land) and passed 30 mm in three hours 1.70 times as often. Around Milan, Genoa and Rome it read 1.6–1.7 times the «Merging»; around Palermo less than half. **Check:** every month corrected with the map of the other months, against CUM3. Mean error from 1.91 to 1.55 mm; total from 1.20 to 1.00; 30 mm passed 0.89 times as often as the «Merging» instead of 1.70. One factor for the whole of Italy leaves the error where it was (1.94 mm): the bias is local. The [full table](api/bias.md#the-measure-in-full) is by region, intensity and month. **What was tried and dropped.** The hour of the day: the ratio stays within 1.18–1.23. The season: it moves (1.11–1.33 by month), but five months are not a season to learn from. A model on place, beam height, hour and month (gradient boosting): about the same mean error, but it passed 50 mm 0.40 times as often as the «Merging» and almost never 100 mm. **What is not there.** - **The corrected history.** The factor describes 2026. In 2016 the radar-only history read *less* than the gauges in Apulia, in 2026 the radar reads *more* than the «Merging» almost everywhere: the bias changed, and there is no «Merging» of 2010–2025 to test a correction on. `SriHistory` is left as it is. Closing this needs rain gauges of those years (the regional networks), not more radar. - **Heavy rain.** Where the «Merging» has 30 mm or more, the corrected radar reads 0.75 of it (the radar alone 0.91); in July and August it passes 30 mm half to two thirds as often. For the peak of a storm the radar alone, or the next «Merging», is better. - **One hour and five minutes.** The factor was measured on three hours; on SRT1 and SRI it is an assumption. - **Sicily**, where it helps little, and wherever the radar is blind. - **An independent truth.** The «Merging» contains the radar, and the DPC does not publish the gauges. Found on the way: rain gauges that report 1–6 mm every three hours under a dry radar for weeks (near Foggia, in 504 of 573 wet windows). They are too small for the `gauge_only` rule of `quality` (30 mm); the map leaves 2,660 km² around such gauges without a factor. Limen does not use `correct` yet. --- ## Phase 3 · AI for people and agents ### MCP server, `llms.txt`, event reports · [#9](https://github.com/agent-engineering-studio/dpc-radar/issues/9) · ✅ first version: facts as data, a text that is checked - **MCP server** `dpc-radar mcp`, extra `[mcp]`: `latest`, `rain_at(lon, lat, hours)`, `area_summary(box, hours)`, `storm_now(box)`, `rain_ahead(lon, lat, minutes)`, `official_alert(lon, lat, place)`, `rarity(lon, lat, hours, mm)`. Someone asks "how much has it rained on Messina in the last three hours?" and the answer is computed from a frame, with its product and time, after the [quality check](api/quality.md). The tools are the methods of `dpc_radar.facts.Facts`: the same dicts from Python. [How it works](api/mcp.md). - **`llms.txt`, `llms-full.txt` and an agent skill**, as in [egms-client](https://agentengineering.it/egms-client/), built with the site: [`llms.txt`](https://agentengineering.it/dpc-radar/llms.txt), the whole documentation as text, and [`SKILL.md`](https://agentengineering.it/dpc-radar/skills/dpc-radar/SKILL.md) with the traps a model gets wrong when it writes radar code from memory. - **Event reports** `dpc-radar report --bbox … --day …`, extra `[report]`: the map of the radar alone next to the «Merging», the hourly chart, the wettest place and how rare its rain was, the official bulletin, and a text written from a JSON of computed figures. Every number in the text is checked against the JSON before the report is saved. [The report of Melito, 10 October 2026](api/report.md). **What is different from the plan.** - `official_alert` takes a point, a municipality or a zone name, not a region: the bulletin does not name regions. - The text of a report comes from a template, not from a language model. The check is there for a text a model writes (`--text`, `dpc-radar check`), and it knows that a number is in the facts, not that it is said of the right thing. - `rain_ahead` was added: the nowcast of #7, labelled as a forecast. **What is not there.** A measure of how faithfully a model words the tools' answers (Limen has one for its briefings; here the server gives the facts and the rules, and cannot read the answer). Reports across midnight, or of a whole event of several days. A hosted server: `dpc-radar mcp` runs on the machine of whoever asks. **For Limen:** the same facts for its assistant and briefings, which run on a local model (faithfulness eval: 16 of 16 briefings with no invented number), as structured data instead of prose ([limen#371](https://github.com/agent-engineering-studio/limen/issues/371)). Limen does not use them yet. ### In the development loop | Idea | What | Effort | |---|---|---| | **Weekly live test** | a scheduled job that calls the real API and fails when an answer changes shape, like the `origin` header that stopped being required in 2026 | S | | **Issue on failure** | when the live test fails, an agent opens an issue with the old and new answer side by side | S | | **Parity test with Limen** | the same frame sampled by Limen and by the library gives the same values on the cells of Melito and the Reggio area | S | --- ## What Limen gains, in one table | Limen today | With dpc-radar | Issue | Number of limen#345 it should move | |---|---|---|---| | one national rain threshold | rain judged against the climate of each cell: `rarity` (done); its use in Limen (open) | #4 | fewer municipality-days on alert, to be measured | | 8 verified events | candidate events from the catalogue: `rare_events` (done, 317 a month); their check in the news (open) | #5 | a denominator worth measuring | | radar zero read as dry where the radar is blind | a reliability map | #3 | fewer missed events | | a fixed 150 mm rule for bad frames | a score per frame and pixel, with the reason | #6 | fewer false alarms | | a trigger on rain already fallen | the rain and the chance of rain of the next two hours: `nowcast`, `chance` (done); a trigger on them in Limen (open) | #7 | more events anticipated, to be measured | | a radar-only history that under-estimates | a factor for the radar alone of 2026 (done); the history needs gauges of those years (open) | #8 | radar-only rain closer to the «Merging»; backtests still on biased rain | | facts written into prose | facts as data, each with its frame: `Facts`, the MCP tools, `facts.json` of a report (done); their use in Limen's assistant (open) | #9 | — | # Contributing Issues and pull requests are welcome. - Run `make check` before pushing: ruff, `mypy --strict` and pytest must be clean, the same gate CI runs. - Commits follow [Conventional Commits](https://www.conventionalcommits.org/). - Contributions are accepted under the project's license, Apache-2.0 (section 5 of the license: inbound = outbound). No separate CLA. --- name: dpc-radar description: Read the rain over Italy from the open radar data of the Italian Civil Protection (DPC) in Python with the dpc-radar library - latest frames, rain at a point or over a box, frame quality checks, the radar-gauge «Merging», storms, nowcast, return periods, the official criticality bulletin, event reports. Use when code or an answer needs rainfall, radar or weather-alert data for Italy, or mentions DPC, Protezione Civile, radar-dpc, SRI, SRT1, CUM24 or dpc-radar. --- # dpc-radar `dpc-radar` is a typed, async Python client for the radar platform of the Italian Civil Protection (`https://radar-api.protezionecivile.it`). Use it rather than raw HTTP: the API is small, undocumented and full of traps (a frame that is gone answers 500, two products live on two different grids, published frames can be corrupted). The library already handles them. Full documentation: https://agentengineering.it/dpc-radar/ · everything as plain text: https://agentengineering.it/dpc-radar/llms-full.txt ## Setup ```bash pip install dpc-radar # the client, grids, quality, climatology pip install "dpc-radar[storms,nowcast,bulletins]" # + storms, the next two hours, the alert pip install "dpc-radar[mcp]" # + the MCP server: dpc-radar mcp pip install "dpc-radar[report]" # + event reports: dpc-radar report ``` Python 3.12 or newer. No account and no key: the data are open (CC BY-SA 4.0, credit "Dipartimento della Protezione Civile"). ## The data, in one paragraph - **`SRI`**: rain intensity now, mm/h, every 5 minutes. **`SRT1`**: the rain of the last hour, mm, radar alone. Both on a **1 km grid in a Transverse Mercator projection**. - **`CUM3`, `CUM6`, `CUM12`, `CUM24`**: the rain of the last 3 to 24 hours, mm, every 30 minutes: the **«Merging»**, radar corrected with the rain gauges. On a **0.01° grid in EPSG:4326**. There is no `CUM1`. - A frame is a `RainGrid`: `product`, `time` (UTC, when the window ends), `data` (float array, **NaN = not measured**), `transform`, `crs`. - The DPC keeps frames for about **five months**. The radar-only history since 2010 is another dataset (IT-DPC-SRI, `dpc_radar.history`). - Any frame since 2010, and products the API does not serve (`VMI`, `VIL`, `ETM`, `CAPPI2`-`8`, `OPERA`), come from the ARCO Data Hub: `dpc_radar.arco.ArcoClient`, extra `arco`. It needs a **free account** (`ARCODATAHUB_USERNAME`, `ARCODATAHUB_ACCESS_KEY`) and fair use: it is the only part of the library that is not open without a key. In a reflectivity `-inf` is *no echo* (measured, nothing there) and `NaN` is not measured. ## Recipes ```python import asyncio from datetime import timedelta from dpc_radar import ABSENT, RadarClient, radar_total, reliability from dpc_radar.climatology import rarity async def main() -> None: async with RadarClient() as radar: # The rain of the last 24 hours at a place: lon, lat in degrees. now = await radar.latest("CUM24") before = await radar.at("CUM24", now.time - now.product.period) q = now.quality(None if before is ABSENT else before) # never trust one frame alone rain = q.grid # None if the frame is rejected: then use `before` print(rain.sample([(15.78, 37.92)]), now.product.name, now.time) # [mm or None] # Over a box (west, south, east, north): highest value, pixels over a threshold. print(rain.peak((15.5, 37.85, 16.2, 38.3), threshold=50)) # The radar alone over three hours: the sum of the hourly frames. hours = [await radar.at("SRT1", now.time - timedelta(hours=h)) for h in range(3)] if not any(h is ABSENT for h in hours): total = radar_total(hours) print(reliability(15.78, 37.92).score) # 0 to 1: how far to trust the radar there print(rarity(24, 15.78, 37.92, 100.0).return_period) # years, None outside the map asyncio.run(main()) ``` - In Jupyter a loop is already running: write `await ...` at the top level instead of `asyncio.run`. - A frame at a given time: `await radar.at("CUM3", time)` gives a `RainGrid` or `ABSENT` (the DPC no longer keeps it). Times must be aware datetimes. - The facts with their sources, ready to print or to hand to a model: `from dpc_radar.facts import Facts`, then `await Facts(radar).rain_at(lon, lat, hours=3)`, `area_summary`, `storm_now`, `rain_ahead`, `official_alert`. Every answer is a dict with the product and the time of its frame. - Storms as objects: `from dpc_radar import storms, track`. The next two hours: `from dpc_radar import nowcast, rain_ahead, chance, motion` on the `SRI` frames of the last half hour, the oldest first. - The official alert: `from dpc_radar import bulletins`, then `(await bulletins.latest()).zone_at(lon, lat)`. Levels: 0 none, 1 yellow, 2 orange, 3 red. - Hourly «Merging» rain from frames you saved: `dpc_radar.archive` (`archive(folder, radar)` every night, `MergingArchive(folder).hourly(...)`). `await init()` (or `dpc-radar init`) fills the library's folder, `$DATA_ROOT/dpc-radar` or `~/.cache/dpc-radar`, and `MergingArchive()` with no folder reads it. - The report of a day over a box, from a shell: `dpc-radar report --bbox W,S,E,N --day YYYY-MM-DD --out folder` writes `facts.json`, `report.md` and two images. If you rewrite the text, run `dpc-radar check report.md facts.json`: a number that is not in the facts is refused. ## Rules (each one is a real failure) 1. **There is no `CUM1`.** Asking for it gives an empty list, not an error. The shortest «Merging» is `CUM3`; for one hour use `SRT1` (radar alone). 2. **NaN and `None` mean "not measured", not "dry".** Never write that it did not rain because a value is missing. Check `reliability(lon, lat)`: where the radar is blind (behind mountains, far from every radar), a zero is not evidence of a dry sky either. 3. **Never trust one frame alone.** Published frames have carried up to 20,584 mm of false rain for days. Use `frame.quality(previous)` (or `check`) and read places with `sample`, the median of 3×3 pixels, never one pixel. 4. **Two grids.** `SRI`/`SRT1` are 1 km Transverse Mercator; `CUM*` are 0.01° EPSG:4326. Never add, subtract or index one array with the other: use `sample`, `peak`, `crop`, which take degrees on both. 5. **A frame that is gone answers HTTP 500** with S3's `403 Forbidden` in the body, not 404. `radar.at` returns `ABSENT`: do not retry it. 6. **The radar alone is not the truth.** In 2026 it read 20 % more than the «Merging» on average, up to 1.7 times in places. Prefer `CUM*`; for `SRT1`/`SRI` of 2026, `correct(frame)`. Always say which one a number is. 7. **A gauge can be wrong too**: stuck gauges have put 126.6 mm every three hours into the «Merging» on a dry night. `frame.quality(radar=...)` with the radar total of the same window masks them. 8. **Times are UTC**, the time of a frame is the end of its window, and the API speaks epoch milliseconds (`to_epoch_ms` / `from_epoch_ms`). The bulletin is in Italian time. 9. **Return periods are in radar millimetres**, from eight years (2018–2025), capped at 50 years: "50 years or more" is not a number, and these are not the levels of the official rainfall curves. 10. **A nowcast is a forecast.** `nowcast`, `rain_ahead` and `chance` return a `Forecast`, never a `RainGrid`: do not present them as measured rain. They are fair on where rain will be in 30–60 minutes and poor on peaks. 11. **Errors:** `DpcRadarError` is an answer the library cannot read or a bad argument (a point outside the grid, a window that does not exist). Its message says what to change: show it rather than retrying blindly. ## Without writing code If the user only needs answers (not code), the MCP server may already be connected: tools `latest`, `rain_at`, `area_summary`, `storm_now`, `rain_ahead`, `official_alert`, `rarity` and `radar_status` from `dpc-radar mcp` (extra `mcp`). Prefer them to downloading frames by hand. To add it to Claude Code: ```bash claude mcp add dpc-radar -- uvx --from "dpc-radar[mcp]" dpc-radar mcp ``` ## When reporting results State the product, the time of the frame (UTC) and whether the number is radar alone or «Merging». Do not compute numbers the tools did not give you. Radar rain is evidence, not an alert: the official alert is the DPC criticality bulletin and the messages of the regional civil protection. For danger to people, point to them and to 112, never to a radar reading. Data: Dipartimento della Protezione Civile, CC BY-SA 4.0.