Skip to content

Download CHIRPS rainfall for Ethiopia

This lesson is the practical starting point for Session 1.1 in Module 1 — Observational climate pipeline: you will fetch CHIRPS daily rainfall, optionally clipped to Ethiopia, and merge multiple years into a single NetCDF for downstream QC and VECTRI preparation.


About CHIRPS

CHIRPS (Climate Hazards Group InfraRed Precipitation with Station data) is a quasi-global precipitation product (roughly 50°S–50°N) that blends satellite estimates with in-station rain gauges.

Aspect Detail
Version used here CHIRPS v2.0 global daily NetCDF
Temporal coverage 1981–present (updated regularly)
Temporal resolution Daily
Spatial resolution p25 = 0.25° (~28 km) or p05 = 0.05° (~5.5 km)
Format NetCDF (one file per calendar year, global extent)
Source UCSB Climate Hazards Center — data served over HTTPS

For Ethiopia seasonal work, 0.25° (p25) is often enough for regional pipelines and smaller files; use p05 when you need finer hillslope-scale detail and can afford larger downloads.

Official information: CHIRPS data page · CHC publications


What the download script does

The project script download_chirps.py automates:

  1. Builds download URLs for each year and resolution (p25 or p05) from the CHC public file layout.
  2. Streams each yearly NetCDF to disk with chunked downloads and atomic rename (.part → final file).
  3. Optionally clips each year to a latitude/longitude box North, South, West, East (degrees), then writes *_clip.nc per year with zlib compression.
  4. Merges all selected yearly files (raw or clipped) into one NetCDF along the time dimension using xarray.open_mfdataset, with coordinate names normalized (lat/lon, south-to-north latitude).
flowchart LR
  A[Years start–end] --> B[Download yearly CHIRPS NetCDF]
  B --> C{Clip to N,S,W,E?}
  C -->|Yes| D[Clip each year → *_clip.nc]
  C -->|No| E[Use full global yearly files]
  D --> F[Merge with xarray]
  E --> F
  F --> G[Single merged NetCDF in --outdir]

Requirements

Install these Python packages (same environment you use for the rest of the workshop):

pip install requests xarray netCDF4 numpy
Package Role
requests HTTP download with streaming
xarray Open NetCDF, clip, merge along time
netCDF4 NetCDF engine for xarray read/write
numpy Used inside xarray / clipping helpers

You also need a working internet connection to reach data.chc.ucsb.edu.

Disk: one global year at p25 is typically hundreds of MB; p05 is much larger. Clipping to Ethiopia reduces size per year.


Usage (command line)

From the repository root (or any directory if you pass full paths), run:

python docs/scripts/download_chirps.py --start YEAR --end YEAR --outdir OUTPUT_DIR

Arguments

Argument Meaning
--start First year (required)
--end Last year, inclusive (required)
--outdir Folder for yearly files + merged output (default: chirps_downloads)
--res p25 (default) or p05
--clip N S W E Optional bounding box in degrees: North, South, West, East
--merge-name Optional filename for the merged file (only the basename is used)
--overwrite Re-download / re-clip even if outputs exist

Example: Ethiopia bounding box, 2018–2020, 0.25°

Approximate Ethiopia extent (adjust if your domain definition differs):

python docs/scripts/download_chirps.py --start 2018 --end 2020 ^
  --res p25 ^
  --clip 15 3 33 48 ^
  --outdir data/chirps_ethiopia_p25 ^
  --merge-name chirps_ethiopia_2018-2020_p25_clip.nc

On Linux or macOS use \ line continuation instead of ^.

This writes:

  • Yearly files under data/chirps_ethiopia_p25/
  • Clipped yearly *_clip.nc files
  • One merged file chirps_ethiopia_2018-2020_p25_clip.nc in the same folder

Example: full global yearly files (no clip), merge only

python docs/scripts/download_chirps.py --start 2018 --end 2020 --outdir data/chirps_p25_global

Notebook walk-through

For a step-by-step, cell-by-cell explanation of the same logic (build URL → download → optional clip → merge), open the companion notebook:

01_download_chirps_ethiopia.ipynb

Use it in JupyterLab or VS Code to experiment with a single year before running the full CLI over many years.



Next steps (Module 1)

  1. CHIRPS ingestion, preprocessing, and QC — session 1.2 style workflow.
  2. Ethiopia target grid and land mask — session 1.3.
  3. Standardization for downstream / VECTRI — sessions 1.4–1.5.
  4. Documentation and reproducibility — wrap-up.

See also the module overview.

In Partnership With