rainfall-thresholds 0.1.0__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,508 @@
1
+ Metadata-Version: 2.4
2
+ Name: rainfall-thresholds
3
+ Version: 0.2.0
4
+ Summary: Rainfall intensity-duration thresholds for shallow landslides (Caine power law, frequentist fitting)
5
+ Keywords: landslide,rainfall threshold,intensity-duration,caine,hydrology,natural hazards,italy,italica
6
+ Author: Giuseppe Zileni
7
+ Author-email: Giuseppe Zileni <giuseppe.zileni@gmail.com>
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
13
+ Classifier: Topic :: Scientific/Engineering :: Hydrology
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.12
20
+ Project-URL: Homepage, https://github.com/agent-engineering-studio/rainfall-thresholds
21
+ Project-URL: Issues, https://github.com/agent-engineering-studio/rainfall-thresholds/issues
22
+ Project-URL: Changelog, https://github.com/agent-engineering-studio/rainfall-thresholds/blob/main/CHANGELOG.md
23
+ Description-Content-Type: text/markdown
24
+
25
+ # rainfall-thresholds
26
+
27
+ **How much rain does it take to set off a landslide?**
28
+ A small, dependency-free Python library that answers that question with the
29
+ rainfall thresholds used in landslide science: turn an hourly rain-gauge
30
+ series into rainfall events, compare them with a threshold, and fit your own
31
+ threshold from past landslides. It ships ready-to-use thresholds for Italy,
32
+ fitted on 5,974 real landslides.
33
+
34
+ > **A threshold exceeded is not an alert.** It says the rain is like the rain
35
+ > that triggered landslides before. The official alert in Italy is the
36
+ > criticality bulletin of the
37
+ > [Dipartimento della Protezione Civile](https://rischi.protezionecivile.gov.it/it/meteo-idro/allertamento/).
38
+
39
+ **What it does not do.** It does not fetch rain: you bring the series, from a
40
+ gauge, a radar or a model. It does not say where a landslide will happen, and
41
+ it does not issue warnings. It does not know whether your radar can see:
42
+ mark the hours it could not measure as `None`.
43
+
44
+ [![ci](https://github.com/agent-engineering-studio/rainfall-thresholds/actions/workflows/ci.yml/badge.svg)](https://github.com/agent-engineering-studio/rainfall-thresholds/actions/workflows/ci.yml)
45
+ [![PyPI](https://img.shields.io/pypi/v/rainfall-thresholds)](https://pypi.org/project/rainfall-thresholds/)
46
+ [![Python](https://img.shields.io/pypi/pyversions/rainfall-thresholds)](https://pypi.org/project/rainfall-thresholds/)
47
+ [![Dependencies: none](https://img.shields.io/badge/dependencies-none-brightgreen)](https://github.com/agent-engineering-studio/rainfall-thresholds/blob/main/pyproject.toml)
48
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/agent-engineering-studio/rainfall-thresholds/blob/main/LICENSE)
49
+
50
+ <picture>
51
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/id-plane-dark.png">
52
+ <img alt="Log-log chart of rainfall duration against mean intensity. Thousands of grey dots, each a rainfall event that triggered a landslide in Italy, sit above a blue line, the T5 threshold. A red star marks an example storm of 82 mm in 10 hours, well above the line." src="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/id-plane-light.png">
53
+ </picture>
54
+
55
+ <sub>Every grey dot is a storm that triggered a landslide in Italy (e-ITALICA
56
+ catalogue). The blue line is the threshold this library fits: only 5 % of
57
+ those storms fall below it. The red star is the storm from the
58
+ [quick start](#quick-start).</sub>
59
+
60
+ ---
61
+
62
+ ## Contents
63
+
64
+ - [The idea in 30 seconds](#the-idea-in-30-seconds)
65
+ - [How it works](#how-it-works)
66
+ - [Install](#install)
67
+ - [Quick start](#quick-start)
68
+ - [Step by step](#step-by-step)
69
+ - [1. From hourly rain to rainfall events](#1-from-hourly-rain-to-rainfall-events)
70
+ - [2. Comparing an event with a threshold](#2-comparing-an-event-with-a-threshold)
71
+ - [3. Fitting your own threshold](#3-fitting-your-own-threshold)
72
+ - [Thresholds for Italy](#thresholds-for-italy)
73
+ - [Recipe: check a rain gauge](#recipe-check-a-rain-gauge)
74
+ - [API at a glance](#api-at-a-glance)
75
+ - [Benchmark](#benchmark)
76
+ - [Good to know](#good-to-know)
77
+ - [References](#references) · [Citing](#citing) · [Contributing](#contributing)
78
+
79
+ ## The idea in 30 seconds
80
+
81
+ Shallow landslides start when the soil gets too wet. What makes it too wet
82
+ is a mix of **how hard** it rains and **for how long**:
83
+
84
+ - a short, violent downpour can do it: 30 mm in 2 hours;
85
+ - so can a long, gentle rain: 60 mm over three days.
86
+
87
+ In 1980 Nels Caine noticed that, on a log-log chart of *duration* against
88
+ *mean intensity*, the storms that triggered landslides sit above a straight
89
+ line. That line is the **rainfall threshold**:
90
+
91
+ ```
92
+ I = α · D^(-β)
93
+
94
+ I mean rainfall intensity (mm/h)
95
+ D rainfall duration (hours)
96
+ α how high the line sits β how fast it drops with duration
97
+ ```
98
+
99
+ Above the line: rain like the rain that triggered landslides in the past.
100
+ Below it: rain that very rarely did. That is all a threshold says, and it is
101
+ why thresholds are at the heart of many landslide early-warning systems.
102
+
103
+ This library gives you the three pieces around that line, in plain Python
104
+ with no dependencies.
105
+
106
+ ## How it works
107
+
108
+ ```mermaid
109
+ flowchart LR
110
+ A["🌧️ Hourly rain<br/>(timestamp, mm)"] -->|reconstruct_events| B["Rainfall events<br/>duration · total · intensity"]
111
+ B -->|strongest_event| C["Event that matters"]
112
+ C -->|"threshold.exceedance()"| D{"Above the<br/>threshold?"}
113
+ D -->|"> 0"| E["⚠️ Conditions like<br/>past landslides"]
114
+ D -->|"< 0"| F["✅ Below the line"]
115
+
116
+ G["📚 Past landslides<br/>(duration, intensity)"] -->|fit_threshold| H["PowerLawThreshold<br/>α, β"]
117
+ I["🇮🇹 ITALICA_T5<br/>ready-made for Italy"] --> H
118
+ H --> D
119
+ ```
120
+
121
+ | Step | What you have | What you call | What you get |
122
+ |---|---|---|---|
123
+ | 1 | an hourly rain series | `reconstruct_events`, `strongest_event` | rainfall events, each with duration, total and intensity |
124
+ | 2 | an event and a threshold | `PowerLawThreshold.intensity` / `.cumulated` / `.exceedance` | how much rain the threshold needs, and how far above or below it you are |
125
+ | 3 | a catalogue of landslide-triggering events | `fit_threshold` | your own threshold |
126
+
127
+ ## Install
128
+
129
+ ```bash
130
+ pip install rainfall-thresholds
131
+ ```
132
+
133
+ Python 3.12 or newer. No dependencies: not even NumPy.
134
+
135
+ ## Quick start
136
+
137
+ A storm over Calabria, southern Italy: 82 mm in about ten hours. Is it
138
+ landslide weather?
139
+
140
+ ```python
141
+ from datetime import UTC, datetime, timedelta
142
+
143
+ from rainfall_thresholds import ITALICA_T5, macroregion_of, reconstruct_events, strongest_event
144
+
145
+ # Hourly rain from a gauge, in mm
146
+ start = datetime(2026, 10, 10, tzinfo=UTC)
147
+ hourly_mm = [0, 2, 8, 15, 22, 18, 9, 4, 0, 1, 3, 0, 0]
148
+ series = [(start + timedelta(hours=h), mm) for h, mm in enumerate(hourly_mm)]
149
+
150
+ # 1. Pick the threshold for the region
151
+ threshold = ITALICA_T5[macroregion_of("Calabria") or "italy"] # "southern"
152
+
153
+ # 2. Cut the series into rainfall events and take the one that matters
154
+ events = reconstruct_events(series, no_rain_break_hours=6, min_event_mm=2.0)
155
+ event = strongest_event(events, threshold)
156
+ assert event is not None
157
+
158
+ # 3. Compare
159
+ print(f"{event.total_mm:.0f} mm in {event.duration_hours:.0f} h = {event.intensity_mm_h:.1f} mm/h")
160
+ print(f"T5 at that duration: {threshold.intensity(event.duration_hours):.1f} mm/h")
161
+ print(f"{threshold.exceedance(event.intensity_mm_h, event.duration_hours):+.2f} decades")
162
+ ```
163
+
164
+ ```
165
+ 82 mm in 10 h = 8.2 mm/h
166
+ T5 at that duration: 2.0 mm/h
167
+ +0.62 decades
168
+ ```
169
+
170
+ The storm is about four times as intense as the threshold (10^0.62 ≈ 4.2):
171
+ it is the red star in the chart at the top.
172
+
173
+ ## Step by step
174
+
175
+ ### 1. From hourly rain to rainfall events
176
+
177
+ A rain gauge gives you one number per hour. A threshold needs *events*: a
178
+ start, an end, a total. `reconstruct_events` cuts the series with two
179
+ simple rules:
180
+
181
+ - **`no_rain_break_hours`**: this many dry hours in a row end an event;
182
+ - **`min_event_mm`**: events with less rain than this are dropped as noise.
183
+
184
+ An event runs from its first to its last wet hour, so short dry spells
185
+ inside a storm stay in the same event.
186
+
187
+ <picture>
188
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/event-reconstruction-dark.png">
189
+ <img alt="Bar chart of 36 hours of rain. Hours 1 to 9 form event 1, 30 mm in 9 hours, despite a 2-hour dry gap. Eight dry hours close it. A 1 mm drizzle at hours 18 and 19 is dropped. Hours 28 to 33 form event 2, 33 mm in 6 hours." src="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/event-reconstruction-light.png">
190
+ </picture>
191
+
192
+ ```python
193
+ threshold = ITALICA_T5["southern"]
194
+ events = reconstruct_events(series, no_rain_break_hours=6, min_event_mm=2.0)
195
+ for e in events:
196
+ print(e.start, e.end, e.duration_hours, e.total_mm, e.intensity_mm_h)
197
+
198
+ current = strongest_event(events, threshold) # the event furthest above the threshold
199
+ ```
200
+
201
+ **Which event?** A storm, six dry hours and then a little drizzle are two
202
+ events. `latest_event` gives the drizzle; `strongest_event` gives the storm.
203
+ For monitoring, pass the events of the window you watch (for example the last
204
+ 48 hours) to `strongest_event`, so an old storm does not stay forever.
205
+
206
+ Each event is a frozen `RainfallEvent` with `start`, `end`,
207
+ `duration_hours`, `total_mm`, `unmeasured_hours`, `source` and the
208
+ `intensity_mm_h` and `fully_measured` properties.
209
+
210
+ > **Not measured is not dry.** The series should be hourly and without gaps:
211
+ > a dry hour is `0`, an hour that was not measured (a missing frame, a gauge
212
+ > that did not report, a place the radar cannot see) is `None`. A `None` hour
213
+ > adds no rain and does not count towards the dry break, so a gap never splits
214
+ > an event. The event counts it in `unmeasured_hours`, and its total is then a
215
+ > lower bound. If your gauge skips dry hours, fill them in with `0`.
216
+
217
+ Give the events a `source` (`reconstruct_events(..., source="DPC SRT1")`):
218
+ the Italian thresholds are fitted on rain gauges, and radar rain is not gauge
219
+ rain. The label is carried, never interpreted.
220
+
221
+ ### 2. Comparing an event with a threshold
222
+
223
+ A `PowerLawThreshold` answers three questions for an event of a given
224
+ duration:
225
+
226
+ | Method | Question | Unit |
227
+ |---|---|---|
228
+ | `intensity(D)` | How intense must rain be, on average, to reach the line? | mm/h |
229
+ | `cumulated(D)` | How much rain in total must fall to reach the line? | mm |
230
+ | `exceedance(I, D)` | How far above (+) or below (−) the line is this event? | decades |
231
+
232
+ `cumulated` is usually the easiest to talk about. With the threshold for
233
+ northern Italy:
234
+
235
+ ```python
236
+ from rainfall_thresholds import ITALICA_T5
237
+
238
+ t = ITALICA_T5["northern"]
239
+ for d in (1, 6, 24, 72):
240
+ print(f"{d:>3} h {t.cumulated(d):5.1f} mm {t.intensity(d):5.2f} mm/h")
241
+ ```
242
+
243
+ ```
244
+ 1 h 6.4 mm 6.40 mm/h
245
+ 6 h 15.3 mm 2.55 mm/h
246
+ 24 h 30.0 mm 1.25 mm/h
247
+ 72 h 51.3 mm 0.71 mm/h
248
+ ```
249
+
250
+ Longer rain needs more water in total, but less per hour.
251
+
252
+ **Reading `exceedance`.** It is `log10(I / I(D))`, so it is scale-free and
253
+ easy to put on a dashboard. Four 24-hour events against the national
254
+ threshold (28 mm in 24 h):
255
+
256
+ | Rain in 24 h | Mean intensity | `exceedance` | In words |
257
+ |---:|---:|---:|---|
258
+ | 12 mm | 0.5 mm/h | −0.37 | well below the line |
259
+ | 24 mm | 1.0 mm/h | −0.07 | just below |
260
+ | 58 mm | 2.4 mm/h | +0.31 | twice the threshold intensity |
261
+ | 288 mm | 12 mm/h | +1.01 | ten times: an extreme event |
262
+
263
+ A dry event (zero intensity) gives `-inf`.
264
+
265
+ ### 3. Fitting your own threshold
266
+
267
+ Have a list of landslides and the rain that triggered them? Fit a threshold
268
+ for your own area:
269
+
270
+ ```python
271
+ from rainfall_thresholds import fit_threshold
272
+
273
+ # (duration in hours, mean intensity in mm/h) of rain that triggered landslides
274
+ triggering_events = [
275
+ (3, 9.0),
276
+ (5, 4.0),
277
+ (6, 6.5),
278
+ (10, 5.5),
279
+ (12, 3.1),
280
+ (24, 2.4),
281
+ (30, 1.4),
282
+ (48, 1.1),
283
+ (72, 1.0),
284
+ (96, 0.6),
285
+ ]
286
+
287
+ fit = fit_threshold(triggering_events, percentile=5)
288
+ t = fit.threshold
289
+ print(f"T5: I = {t.alpha:.2f} · D^-{t.beta:.3f} ({fit.n_events} events)")
290
+ print(f"at 24 h: {t.intensity(24):.2f} mm/h, i.e. {t.cumulated(24):.0f} mm")
291
+ ```
292
+
293
+ ```
294
+ T5: I = 14.78 · D^-0.737 (10 events)
295
+ at 24 h: 1.42 mm/h, i.e. 34 mm
296
+ ```
297
+
298
+ (Ten events are enough for an example, not for a real threshold: published
299
+ thresholds use hundreds.)
300
+
301
+ What `fit_threshold` does, in two steps:
302
+
303
+ 1. **Best-fit line.** Least squares on `log I` against `log D` through all
304
+ the events: the orange line below, returned as `fit.central`.
305
+ 2. **Lower it.** Slide the line down, keeping its slope, until only
306
+ `percentile` % of the events sit beneath it: the blue line, returned as
307
+ `fit.threshold`. With `percentile=5` this is the **T5** threshold.
308
+
309
+ <picture>
310
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/fitting-dark.png">
311
+ <img alt="Left: the e-ITALICA events on a log-log chart with an orange best-fit line and a parallel blue line lower down, the T5 threshold. Right: a histogram of the distance of each event from the best-fit line; the lowest 5 percent, left of -0.45, are highlighted in blue." src="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/fitting-light.png">
312
+ </picture>
313
+
314
+ This is the frequentist method of Brunetti et al. (2010) and Peruccacci et
315
+ al. (2012), with one difference: they take the percentile from a Gaussian
316
+ fitted to a kernel density of the residuals; this package takes it straight
317
+ from the residuals. The two agree when the residuals are close to normal,
318
+ and the empirical one makes no assumption about their shape.
319
+
320
+ ## Thresholds for Italy
321
+
322
+ `ITALICA_T5` holds four T5 thresholds fitted with `fit_threshold(percentile=5)`
323
+ on the 5,974 events of [e-ITALICA](https://doi.org/10.5281/zenodo.14204473)
324
+ v4 with a positive duration and cumulated rainfall:
325
+
326
+ | Key | α (mm/h) | β | Events | Rain needed in 24 h | in 72 h |
327
+ |---|---:|---:|---:|---:|---:|
328
+ | `"italy"` | 7.193 | 0.5685 | 5,974 | 28.3 mm | 45.5 mm |
329
+ | `"northern"` | 6.400 | 0.5134 | 2,659 | 30.0 mm | 51.3 mm |
330
+ | `"central"` | 7.953 | 0.6085 | 1,890 | 27.6 mm | 42.4 mm |
331
+ | `"southern"` | 8.754 | 0.6449 | 1,425 | 27.1 mm | 40.0 mm |
332
+
333
+ <picture>
334
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/macroregions-dark.png">
335
+ <img alt="Line chart of the rain needed to reach T5 against duration, up to 168 hours, for Italy and its three macroregions. The lines overlap up to about 12 hours; after that the northern threshold needs the most rain, about 78 mm in a week, and the southern the least, about 54 mm." src="https://raw.githubusercontent.com/agent-engineering-studio/rainfall-thresholds/main/docs/img/macroregions-light.png">
336
+ </picture>
337
+
338
+ For short bursts the regions behave alike; over days, the north needs
339
+ noticeably more rain than the south before landslides start.
340
+
341
+ Pick the threshold from the region name with `macroregion_of`:
342
+
343
+ ```python
344
+ from rainfall_thresholds import ITALICA_T5, macroregion_of
345
+
346
+ macroregion_of("Liguria") # "northern"
347
+ macroregion_of("Abruzzo") # "central"
348
+ macroregion_of("Bavaria") # None: not an Italian region
349
+
350
+ threshold = ITALICA_T5[macroregion_of("Sicilia") or "italy"]
351
+ ```
352
+
353
+ > **Abruzzo and Molise are in the centre**, unlike the ISTAT "Sud". Use
354
+ > `macroregion_of` (or `MACROREGIONS`) rather than an ISTAT table, or the
355
+ > threshold will not be the one fitted on that region's landslides.
356
+
357
+ These numbers are **reproducible, not copied**: the catalogue ships with the
358
+ tests and `tests/test_italy.py` refits all four thresholds from it on every
359
+ run. They are not the thresholds published by the e-ITALICA authors, who use
360
+ their own method and partitions; they are what this package's method gives
361
+ on their data.
362
+
363
+ ## Recipe: check a rain gauge
364
+
365
+ Read an hourly CSV, find the current rainfall event and see where it stands:
366
+
367
+ ```python
368
+ import csv
369
+ from datetime import datetime
370
+
371
+ from rainfall_thresholds import ITALICA_T5, macroregion_of, reconstruct_events, strongest_event
372
+
373
+ with open("gauge.csv", encoding="utf-8") as f: # columns: time, rain_mm (empty: not measured)
374
+ series = [
375
+ (datetime.fromisoformat(r["time"]), float(r["rain_mm"]) if r["rain_mm"] else None)
376
+ for r in csv.DictReader(f)
377
+ ]
378
+
379
+ threshold = ITALICA_T5[macroregion_of("Liguria") or "italy"]
380
+ events = reconstruct_events(series, no_rain_break_hours=6, min_event_mm=2.0, source="rain gauge")
381
+ event = strongest_event(events, threshold)
382
+
383
+ if event is None:
384
+ print("No rain event in the window")
385
+ else:
386
+ e = threshold.exceedance(event.intensity_mm_h, event.duration_hours)
387
+ needed = threshold.cumulated(event.duration_hours)
388
+ print(
389
+ f"{event.start:%d %b %H:%M} → {event.end:%H:%M}: {event.total_mm:.0f} mm "
390
+ f"(T5 needs {needed:.0f} mm in {event.duration_hours:.0f} h) → {e:+.2f}"
391
+ )
392
+ ```
393
+
394
+ ```
395
+ 10 Oct 01:00 → 07:00: 78 mm (T5 needs 16 mm in 7 h) → +0.67
396
+ ```
397
+
398
+ Run it every hour on the last two or three days of data and you have the
399
+ rainfall part of a simple monitoring loop: a number to watch, not an alert.
400
+
401
+ ## API at a glance
402
+
403
+ | Name | Kind | What it is |
404
+ |---|---|---|
405
+ | `PowerLawThreshold(alpha, beta)` | frozen dataclass | `I = α·D^(-β)`, with `.intensity(D)`, `.cumulated(D)`, `.exceedance(I, D)` |
406
+ | `reconstruct_events(series, *, no_rain_break_hours, min_event_mm, source=None)` | function | hourly `(datetime, mm or None)` pairs → `list[RainfallEvent]`; `None` is not measured |
407
+ | `strongest_event(events, threshold)` | function | the event furthest above the threshold, or `None` |
408
+ | `latest_event(events)` | function | the event that ended last, or `None` |
409
+ | `RainfallEvent` | frozen dataclass | `start`, `end`, `duration_hours`, `total_mm`, `unmeasured_hours`, `source`, `.intensity_mm_h`, `.fully_measured` |
410
+ | `fit_threshold(events, *, percentile=5.0)` | function | `(D, I)` pairs → `ThresholdFit` |
411
+ | `ThresholdFit` | frozen dataclass | `threshold`, `central`, `percentile`, `n_events` |
412
+ | `percentile_of(values, percentile)` | function | linear-interpolation percentile, same as NumPy's default |
413
+ | `ITALICA_T5` | read-only mapping | `"italy"`, `"northern"`, `"central"`, `"southern"` → `PowerLawThreshold` |
414
+ | `MACROREGIONS` | read-only mapping | macroregion → set of region names (e-ITALICA spelling) |
415
+ | `macroregion_of(region)` | function | region name → macroregion, or `None` |
416
+
417
+ Everything is fully typed (`py.typed`) and checked with `mypy --strict`.
418
+
419
+ ## Benchmark
420
+
421
+ A fixed set of known cases runs in CI: the storm of Melito di Porto Salvo on
422
+ 10 October 2026 on the DPC radar, six e-ITALICA landslides, and two cases
423
+ built to test one rule each. 0.1.0 passed **9 of 16** checks: it forgot a
424
+ storm when a little drizzle followed it, and could not take an hour that was
425
+ not measured. With `strongest_event` and `None` the library passes **13 of
426
+ 16**. The three it misses are landslides under T5, as T5 allows by
427
+ construction. The details, and what is not there yet, are in
428
+ [`benchmarks/`](https://github.com/agent-engineering-studio/rainfall-thresholds/tree/main/benchmarks).
429
+
430
+ ```bash
431
+ uv run python -m benchmarks.run
432
+ ```
433
+
434
+ ## Good to know
435
+
436
+ - **A threshold is not a forecast.** Rain above T5 means "conditions like
437
+ those that triggered landslides before", not "a landslide will happen
438
+ here". Slope, soil, vegetation and antecedent wetness all matter. Use it
439
+ as one input to a warning system, alongside expert judgement.
440
+ - **T5 is deliberately low.** By construction, 95 % of past triggering
441
+ events sit above it: it favours catching events over avoiding false
442
+ alarms.
443
+ - **Event reconstruction is simplified.** It follows Melillo et al. (2018),
444
+ whose CTRL-T tool also varies the dry gap with the season. The e-ITALICA
445
+ durations come from that fuller procedure, so applying the Italian
446
+ thresholds to events from `reconstruct_events` mixes the two: fine for
447
+ monitoring, worth knowing for a study.
448
+ - **Units are fixed:** hours, millimetres, millimetres per hour.
449
+
450
+ ## Where it's used
451
+
452
+ Extracted from [Limen](https://github.com/agent-engineering-studio/limen),
453
+ which uses it for the rainfall component of its landslide score. Using it
454
+ somewhere else? [Open an issue](https://github.com/agent-engineering-studio/rainfall-thresholds/issues)
455
+ and tell us: we'd love to list it here.
456
+
457
+ ## References
458
+
459
+ - Caine N. (1980). The rainfall intensity-duration control of shallow
460
+ landslides and debris flows. *Geografiska Annaler A* 62, 23-27.
461
+ - Brunetti M.T. et al. (2010). Rainfall thresholds for the possible
462
+ occurrence of landslides in Italy. *NHESS* 10, 447-458.
463
+ - Peruccacci S. et al. (2012). Lithological and seasonal control on
464
+ rainfall thresholds for the possible initiation of landslides in central
465
+ Italy. *Geomorphology* 139-140, 79-90.
466
+ - Melillo M. et al. (2018). A tool for the automatic calculation of
467
+ rainfall thresholds for landslide occurrence. *Environmental Modelling &
468
+ Software* 105, 230-243.
469
+ - Peruccacci S. et al. (2023). ITALICA: an ITAlian rainfall-induced
470
+ LandslIdes CAtalogue. *ESSD* 15, 2863-2877.
471
+ - Brunetti M.T. et al. (2024). e-ITALICA (enhanced ITAlian rainfall-induced
472
+ LandslIdes CAtalogue), v4. Zenodo,
473
+ [doi:10.5281/zenodo.14204473](https://doi.org/10.5281/zenodo.14204473).
474
+
475
+ ## Citing
476
+
477
+ If this library helps your work, please cite the method and data papers
478
+ above, and link to this repository:
479
+
480
+ ```
481
+ Zileni G. rainfall-thresholds: rainfall intensity-duration thresholds for
482
+ shallow landslides (Python). https://github.com/agent-engineering-studio/rainfall-thresholds
483
+ ```
484
+
485
+ ## Contributing
486
+
487
+ Issues and pull requests are welcome: new regional thresholds, better event
488
+ reconstruction, examples from other countries. See
489
+ [CONTRIBUTING.md](https://github.com/agent-engineering-studio/rainfall-thresholds/blob/main/CONTRIBUTING.md). To set up and run the checks:
490
+
491
+ ```bash
492
+ uv sync
493
+ make check # ruff, mypy --strict, pytest with 100 % coverage
494
+ make figures # redraw the README charts (docs/make_figures.py)
495
+ ```
496
+
497
+ ⭐ If you find it useful, a star helps others find it.
498
+
499
+ ## Data licence
500
+
501
+ The test fixture `tests/fixtures/italica_v4_dur_rain.csv` is e-ITALICA v4
502
+ (Brunetti et al. 2024), [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/),
503
+ reduced to four columns (id, region, duration, cumulated rainfall). The
504
+ charts in `docs/img/` are drawn from it.
505
+
506
+ ## License
507
+
508
+ Code: [Apache-2.0](https://github.com/agent-engineering-studio/rainfall-thresholds/blob/main/LICENSE).