In this notebook we demonstrate how to fetch CHIRPS v3 daily precipitation for a DHIS2 organisation unit level, download only the needed spatial bounding box, and open and inspect the downloaded files as an xarray object (ready for aggregation/analytics in a later step).
This notebook mirrors the ERA5-Land download flow, but rather than requesting a bounding box from a remote service, it reads only the needed spatial window directly from efficiently tiled global GeoTIFF files.
import geopandas as gpd
import xarray as xr
from dhis2eo.data.chc import chirps3Load organisation units¶
Load organisation units for Sierra Leone. The resulting GeoDataFrame is used to derive a bounding box.
org_units = gpd.read_file('../../data/sierra-leone-districts.geojson')
org_unitsDownload CHIRPS v3 daily precipitation for the org unit bounding box¶
CHIRPS v3 daily data are distributed in an online archive of daily precipitation GeoTIFFs. For easier access and analysis, we can use the dhis2eo.data.chc.chirps3 module to download the daily data and save them as monthly NetCDF datasets for more efficient storage.
Parameters¶
We define the start and end parameters to only get precipitation data for the months of July, August, and September 2025, and set the bounding box (bbox) to only get data for the spatial extent of the org units.
We also specify a dirname for where the data should be saved and a prefix for naming the downloaded files.
start = "2025-07"
end = "2025-09"
bbox = org_units.total_bounds
dirname = '../../data/local'
prefix = 'chirps3-daily'Download the files¶
Running the download function will save the data files as monthly NetCDF files to the specified location. After downloading, the function returns a list of file paths, which in our case consists of three NetCDF files for July, August, and September:
files = chirps3.daily.download(start=start, end=end, bbox=bbox, dirname=dirname, prefix=prefix)
filesINFO - 2026-01-15 13:34:43,562 - dhis2eo.data.chc.chirps3.daily - Fetching CHIRPS v3 daily from 2025-7 to 2025-9 (inclusive)
INFO - 2026-01-15 13:34:43,563 - dhis2eo.data.chc.chirps3.daily - Stage/flavor: final/rnl
INFO - 2026-01-15 13:34:43,565 - dhis2eo.data.chc.chirps3.daily - BBox: [-13.3035 6.9176 -10.2658 10.0004]
INFO - 2026-01-15 13:34:43,567 - dhis2eo.data.chc.chirps3.daily - Month 2025-7
INFO - 2026-01-15 13:34:43,569 - dhis2eo.data.chc.chirps3.daily - File already downloaded: C:\Users\karimba\Documents\Github\climate-tools\docs\guides\data\local\chirps3-daily_2025-07.nc
INFO - 2026-01-15 13:34:43,571 - dhis2eo.data.chc.chirps3.daily - Month 2025-8
INFO - 2026-01-15 13:34:43,574 - dhis2eo.data.chc.chirps3.daily - File already downloaded: C:\Users\karimba\Documents\Github\climate-tools\docs\guides\data\local\chirps3-daily_2025-08.nc
INFO - 2026-01-15 13:34:43,576 - dhis2eo.data.chc.chirps3.daily - Month 2025-9
INFO - 2026-01-15 13:34:43,579 - dhis2eo.data.chc.chirps3.daily - File already downloaded: C:\Users\karimba\Documents\Github\climate-tools\docs\guides\data\local\chirps3-daily_2025-09.nc
[WindowsPath('C:/Users/karimba/Documents/Github/climate-tools/docs/guides/data/local/chirps3-daily_2025-07.nc'),
WindowsPath('C:/Users/karimba/Documents/Github/climate-tools/docs/guides/data/local/chirps3-daily_2025-08.nc'),
WindowsPath('C:/Users/karimba/Documents/Github/climate-tools/docs/guides/data/local/chirps3-daily_2025-09.nc')]The download function treats the files saved under the given dirname and prefix as a cache, so it can safely be rerun multiple times without re-downloading. To ignore the cache and fetch fresh data you can set overwrite=True.
Inspect the data¶
There are many ways to work with the downloaded files. One way is to pass the list to xr.open_mfdataset which will open them as single xarray dataset:
ds = xr.open_mfdataset(files)If we inspect the contents of the dataset, we see that the main variable is precipitation (precip), and contains daily data from the July, August, and September month files in the time dimension:
dsFinally, let’s see what the precipitation data looks like for 31 August:
ds.sel(time='2025-08-31', method='nearest')['precip'].plot(cmap='YlGnBu')
Next steps¶
This notebook has showed how to download daily CHIRPS v3 precipitation data to your local file system conveniently stored as monthly NetCDF files. For guidance on what to do with the data after downloading, see:
If you want an example of how this can be integrated into a complete workflow, see this example notebook that goes through all the steps to download and import CHIRPS v3 data into DHIS2.