Skip to content

Repository files navigation

Crop Calendar Climate Shift Analyser 🌧️🌽

Has Malawi's planting season shifted since 1990?

A data science project using ERA5 reanalysis and CHIRPS rainfall data to detect shifts in onset-of-rains (OOR) dates across Malawi's districts from 1990–2024, with implications for smallholder maize farming.


Research Question

Climate change is altering rainfall seasonality across sub-Saharan Africa. This project quantifies how much and where Malawi's agricultural calendar has shifted by:

  1. Extracting onset-of-rains (OOR) dates per district (1990–2024)
  2. Fitting linear trends to detect statistically significant shifts
  3. Mapping spatial patterns of change
  4. Generating an interactive Streamlit dashboard and Quarto report

Project Structure

crop-calendar-shift/
│
├── data/
│   ├── raw/                  # Downloaded ERA5 / CHIRPS NetCDF files
│   └── processed/            # Cleaned CSVs ready for analysis
│
├── scripts/
│   ├── python/
│   │   ├── 01_download_chirps.py     # Download CHIRPS rainfall via API
│   │   ├── 02_extract_oor_dates.py   # Compute onset-of-rains per district
│   │   └── 03_export_for_r.py        # Export clean CSV for R analysis
│   └── r/
│       ├── 04_trend_analysis.R       # Linear trend fitting + Mann-Kendall
│       └── 05_visualisations.R       # ggplot2 maps and charts → outputs/
│
├── dashboard/
│   └── app.py                # Streamlit interactive dashboard
│
├── report/
│   ├── report.qmd            # Quarto report (rendered to HTML/PDF)
│   └── references.bib
│
├── outputs/
│   ├── figures/              # All saved plots
│   └── tables/               # Trend result tables (CSV)
│
├── environment.yml           # Conda environment
├── requirements.txt          # pip requirements
├── renv.lock                 # R package lockfile (generated by renv)
└── README.md

Quickstart

1. Set up Python environment

conda env create -f environment.yml
conda activate crop-calendar

Or with pip:

pip install -r requirements.txt

2. Download rainfall data

python scripts/python/01_download_chirps.py
python scripts/python/02_extract_oor_dates.py
python scripts/python/03_export_for_r.py

3. Run R analysis

source("scripts/r/04_trend_analysis.R")
source("scripts/r/05_visualisations.R")

4. Launch dashboard

streamlit run dashboard/app.py

5. Render Quarto report

quarto render report/report.qmd

Methodology

Onset-of-Rains Definition

Following FAO/FEWS NET standards, OOR is defined as the first day after October 1st when:

  • Cumulative rainfall ≥ 25mm over 3 consecutive days
  • No dry spell > 10 days in the following 20 days

Trend Detection

  • Sen's slope estimator — robust linear trend (mm/year or days/decade)
  • Mann-Kendall test — non-parametric significance test (p < 0.05)
  • Applied per district, significance mapped spatially

Data Sources

Dataset Variable Resolution Source
CHIRPS v2.0 Daily precipitation 0.05° UCSB CHG
ERA5-Land 2m temperature, ET 0.1° Copernicus CDS
GADM Malawi District boundaries Vector GADM

Author

George Sichinga
MSc Applied Data Science (Environment & Climate Modelling)
LUANAR, Malawi
georgesichinga.github.io


License

MIT

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages