Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Disaster Data Analytics

Recipe 4 — Time-Series Decomposition

IFRC

What you will learn:

  1. Configure hazard-taxonomy codes for floods and cyclones across GLIDE, EM-DAT, and UNDRR-ISC 2025 taxonomies.

  2. Build CQL2-JSON server-side filters with a_overlaps, t_during, and s_intersects.

  3. Stream results year-by-year to CSV for memory-efficient processing on Binder.

  4. Perform STL (Seasonal-Trend-Loess) decomposition Cleveland et al. (1990).

  5. Run Mann–Kendall trend tests Mann (1945) and interpret pp-values.

Environment Setup

Binder
Google Colab
Local

All dependencies are pre-installed. Click Launch Binder at the top of the page — no setup needed.

✅ Libraries imported successfully

Step 2 — Configuration: Region, Time Period, and Hazard Codes

Region
Hazard Taxonomy
Time Window

South Asia bounding box covering Pakistan, India, Bangladesh, Nepal, Sri Lanka, Bhutan, and the Maldives.

======================================================================
CONFIGURATION SUMMARY
======================================================================
Region: South Asia (bbox: [60, 5, 100, 37])
Time Period: 2014-06-30 to 2024-06-30
Collections: ['gdacs-events', 'emdat-events', 'glide-events']

Flood codes: 15 codes
Cyclone codes: 8 codes
======================================================================

Step 3 — Connect to the Montandon STAC API

======================================================================
AUTHENTICATION REQUIRED
======================================================================

The Montandon STAC API requires a Bearer Token for authentication.

How to get your token:
  1. Visit: https://goadmin-stage.ifrc.org/
  2. Log in with your IFRC credentials
  3. Generate an API token from your account settings

======================================================================

 Connected to: https://montandon-eoapi-stage.ifrc.org/stac
 API Title: stac-fastapi
 Authentication: Bearer Token (OpenID Connect)

 Connected to: https://montandon-eoapi-stage.ifrc.org/stac
 API Title: stac-fastapi
 Authentication: Bearer Token (OpenID Connect)

Step 4 — CQL2-JSON Filter Builders

Three composable filter functions form the query backbone:

FunctionCQL2 OperatorPurpose
build_datetime_filtert_duringRestrict to a calendar-year window
build_bbox_filters_intersectsClip to the South-Asia bounding box
build_hazard_filtera_overlapsMatch any of the listed hazard codes
✅ CQL2-JSON filter functions initialized

Example flood filter structure:

Step 5 — Memory-Efficient Search Function

✅ Search function initialized

Step 6 — Fetch Flood Events

The search uses FLOOD_CODES (GLIDE FL/FF, EM-DAT nat-hyd-flo-*, UNDRR-ISC MH06XX) as the a_overlaps argument.

======================================================================
FETCHING FLOOD EVENTS (CQL2-JSON SERVER-SIDE FILTERING)
======================================================================
Streaming to floods_south_asia.csv...
Hazard codes: ['FL', 'FF', 'MH0600', 'MH0601', 'MH0602']...
   2014: 66 events (Total: 66)
   2014: 66 events (Total: 66)
   2015: 59 events (Total: 125)
   2015: 59 events (Total: 125)
   2016: 64 events (Total: 189)
   2016: 64 events (Total: 189)
   2017: 45 events (Total: 234)
   2017: 45 events (Total: 234)
   2018: 36 events (Total: 270)
   2018: 36 events (Total: 270)
   2019: 63 events (Total: 333)
   2019: 63 events (Total: 333)
   2020: 82 events (Total: 415)
   2020: 82 events (Total: 415)
   2021: 88 events (Total: 503)
   2021: 88 events (Total: 503)
   2022: 93 events (Total: 596)
   2022: 93 events (Total: 596)
   2023: 109 events (Total: 705)
   2023: 109 events (Total: 705)
   2024: 118 events (Total: 823)

✅ Finished! Total events saved: 823

Time: 134.2 seconds
======================================================================
   2024: 118 events (Total: 823)

✅ Finished! Total events saved: 823

Time: 134.2 seconds
======================================================================

Step 7 — Fetch Cyclone Events

Same pipeline, substituting CYCLONE_CODES (GLIDE TC/EC, EM-DAT nat-met-sto-*, UNDRR-ISC MH03XX).

======================================================================
FETCHING CYCLONE EVENTS (CQL2-JSON SERVER-SIDE FILTERING)
======================================================================
Streaming to cyclones_south_asia.csv...
Hazard codes: ['TC', 'EC', 'MH0306', 'MH0307', 'MH0308']...
   2014: 3 events (Total: 3)
   2014: 3 events (Total: 3)
   2015: 4 events (Total: 7)
   2015: 4 events (Total: 7)
   2016: 6 events (Total: 13)
   2016: 6 events (Total: 13)
   2017: 12 events (Total: 25)
   2017: 12 events (Total: 25)
   2018: 6 events (Total: 31)
   2018: 6 events (Total: 31)
   2019: 9 events (Total: 40)
   2019: 9 events (Total: 40)
   2020: 11 events (Total: 51)
   2020: 11 events (Total: 51)
   2021: 10 events (Total: 61)
   2021: 10 events (Total: 61)
   2022: 4 events (Total: 65)
   2022: 4 events (Total: 65)
   2023: 16 events (Total: 81)
   2023: 16 events (Total: 81)
   2024: 21 events (Total: 102)

✅ Finished! Total events saved: 102

Time: 31.1 seconds
======================================================================
   2024: 21 events (Total: 102)

✅ Finished! Total events saved: 102

Time: 31.1 seconds
======================================================================

Step 8 — Load Data into DataFrames

Parse the CSV files, convert datetime to a proper DatetimeIndex, and sort chronologically for the time-series analysis that follows.


📊 FLOODS: 823 events
   Date range: 2014-02-06 00:00:00+00:00 to 2024-12-17 01:00:00+00:00
   Countries: 16
Loading...

📊 CYCLONES: 102 events
   Date range: 2014-07-18 00:00:00+00:00 to 2024-12-01 00:00:00+00:00
   Countries: 9
Loading...

Step 9 — Seasonality Analysis


======================================================================
SEASONALITY ANALYSIS
======================================================================
<Figure size 1200x500 with 1 Axes>
Peak month: Jul (151 events)
<Figure size 1200x500 with 1 Axes>
Peak month: May (32 events)

Step 10 — STL Time-Series Decomposition

STL (Seasonal-Trend-Loess) Cleveland et al. (1990) decomposes a time series into three additive components:

Yt=Tt+St+RtY_t = T_t + S_t + R_t

where TtT_t is the trend, StS_t the seasonal component, and RtR_t the residual.


======================================================================
STL DECOMPOSITION
======================================================================
<Figure size 1400x1000 with 4 Axes>

📈 Flood Events (Monthly) - Decomposition Insights:
   Trend range: 2.9 to 10.4
   Seasonal amplitude: 12.6
<Figure size 1400x1000 with 4 Axes>

📈 Cyclone Events (Monthly) - Decomposition Insights:
   Trend range: 0.2 to 1.7
   Seasonal amplitude: 3.2

Step 11 — Country-Level Distribution

Horizontal bar charts of the top 10 countries by event count, helping prioritise which national societies have the highest exposure.


======================================================================
COUNTRY-LEVEL DISTRIBUTION
======================================================================
<Figure size 1000x600 with 1 Axes>
<Figure size 1000x600 with 1 Axes>

Step 12 — Yearly Trend Analysis (Mann–Kendall)

The Mann–Kendall test Mann (1945) detects monotonic trends in time-series data without assuming normality. The test statistic SS is:

S=∑k=1n−1∑j=k+1nsgn(xj−xk)S = \sum_{k=1}^{n-1} \sum_{j=k+1}^{n} \text{sgn}(x_j - x_k)

A pp-value below 0.05 indicates a statistically significant trend. The Sen slope estimates the median linear rate of change (events per year).


======================================================================
YEARLY TREND ANALYSIS
======================================================================
<Figure size 1200x500 with 1 Axes>

📈 MANN-KENDALL TREND TEST: Floods in South Asia
   Trend: INCREASING
   P-value: 0.0127 (Significant at 0.05)
   Slope: 6.25 events/year
   Total events: 823
   Average per year: 74.8
<Figure size 1200x500 with 1 Axes>

📈 MANN-KENDALL TREND TEST: Cyclones in South Asia
   Trend: INCREASING
   P-value: 0.0188 (Significant at 0.05)
   Slope: 1.33 events/year
   Total events: 102
   Average per year: 9.3

Step 13 — Comparative Analysis: Floods vs Cyclones

Side-by-side monthly distributions and summary statistics for a quick operational comparison of the two hazard types.


======================================================================
COMPARATIVE ANALYSIS: FLOODS vs CYCLONES
======================================================================
<Figure size 1400x500 with 2 Axes>

======================================================================
SUMMARY STATISTICS
======================================================================

Metric                                  Floods        Cyclones
------------------------------------------------------------
Total Events                               823             102
Countries Affected                          16
Peak Month                                 Jul
Countries Affected                                           9
Peak Month                                                 May
======================================================================

Conclusion & Key Findings

Floods
Cyclones
Technical Notes
  • Peak during monsoon season (June–September)

  • India, Bangladesh, and Pakistan most affected

  • Seasonal pattern tightly linked to the Southwest Monsoon


References
  1. European Commission Joint Research Centre. (2024). Global Disaster Alert and Coordination System (GDACS). https://www.gdacs.org
  2. Guha-Sapir, D. (2024). EM-DAT: The Emergency Events Database. Centre for Research on the Epidemiology of Disasters (CRED). https://www.emdat.be
  3. Asian Disaster Reduction Center. (2024). GLobal IDEntifier Number (GLIDE). https://glidenumber.net
  4. Cleveland, R. B., Cleveland, W. S., McRae, J. E., & Terpenning, I. (1990). STL: A Seasonal-Trend Decomposition Procedure Based on Loess. Journal of Official Statistics, 6(1), 3–73.
  5. Mann, H. B. (1945). Nonparametric Tests Against Trend. Econometrica, 13(3), 245–259. 10.2307/1907187