CGHI
Climate & Global Health InitiativeA Duke Global Health Institute initiative

A Duke Global Health Institute Initiative

Tutorial & Methods Guide

Linking Hourly Climate Data to Weekly Health Outcomes

A Sri Lanka guide for transforming hourly gridded climate data into epidemiology-ready weekly features.

← Back to Resources
Methods GuideSri LankaERA5 ReanalysisClimate & Health

Purpose & Scope

An end-to-end guide for converting hourly gridded climate data into epidemiology-ready weekly features, with Sri Lanka as a worked example.

Who This Is For

Health researchers seeking to incorporate climate context into their work (e.g., disease surveillance for leptospirosis, dengue) without requiring prior meteorology or GIS expertise.

What You Will Learn

The process of transforming hourly gridded climate data into epidemiology-ready weekly features, the rationale behind each step, and strategies to prevent common pitfalls.

Detailed Description & References

This guide provides a practical, end-to-end pathway for converting hourly, gridded climate fields into district-week exposure features aligned to public-health surveillance. The method addresses three recurring challenges — spatial assignment, unit semantics, and time alignment— then builds epidemiology-ready features, validates them with quick QA checks, and outlines modeling strategies for delayed and seasonal climate–health relationships.

References & AppendicesIn-text citations direct readers to sources for methodological and data background. Appendix A offers a condensed, end-to-end walkthrough most useful after reading background sections. Appendix B summarizes climate variables in greater detail.

Scale Mismatches & Three Questions to Answer

Climate data and health surveillance operate at different spatial, temporal, and semantic scales. Three questions determine whether the resulting exposure makes epidemiologic sense.

W
Where(Space)

Surveillance units are administrative areas, not grid cells. Area-weighted overlays in an equal-area projection ensure each cell contributes in proportion to its land area overlap.

W
What(Quantity)

Variables behave differently. Temperature retains meaningful variation as daily mean/min/max. Precipitation requires explicit unit checks — accumulated depth vs. average rate.

W
When(Time)

Convert timestamps to local civil time before any day/week roll-ups to avoid “day-splitting” of night-time observations. Align to jurisdictional epidemiological weeks.

Details & Caveats
Residual Exposure ErrorEven with careful alignment, residual exposure error — especially for tropical precipitation — can attenuate associations. Small effects warrant caution and should be stress-tested across alternative exposure definitions and aggregation choices.
Sri Lanka ContextThe Sri Lanka example instantiates these steps (district overlays, ERA5 inputs, Asia/Colombo time) but the logic extends to other diseases, geographies, and data sources. Code and data pointers are available at the project GitHub.

Data Inventory & Conventions

Climate data sources differ in coverage, resolution, and accuracy. This section inventories the variables and conventions used throughout.

What “Climate Data” Usually Means

Surface Stations

+ Direct observation

− Sparse coverage, varying quality, siting issues

Satellites

+ Broad coverage, consistent methods

− Indirect retrievals, algorithm changes, orbital sampling

Reanalyses (e.g., ERA5)

+ Spatial/temporal completeness, many variables

− Model biases; precipitation less constrained than temperature

Grids, Levels & Variables

Grid:Most reanalyses store data on latitude–longitude grids (e.g., ~0.25° for ERA5, ~28 km near the equator). Grid cells shrink toward the poles — compute statistics in an equal-area projection when aggregating to districts.

Levels: Some variables are at the surface (2-m air temperature, 10-m wind); others at pressure levels aloft. For health applications focused on human exposure, surface or near-surface variables are typical.

ERA5 Variables Used in This Guide

Much of climate–health variability can be captured with a compact set of meteorological indicators delivered as hourly gridded fields, aggregated to daily and weekly periods.

TA

2-m Air Temperature

Hourly near-surface air temperature representing conditions people and vectors actually experience.

Why it matters: Governs human thermal stress, agricultural growth, and biological rates for pathogens and vectors.

TD

2-m Dewpoint Temperature

The temperature at which air becomes saturated — a direct measure of atmospheric moisture.

Why it matters: Moisture shapes mosquito survival, biting activity, and pathogen persistence.

TP

Total Precipitation

Hourly accumulation of liquid-equivalent precipitation, summed to daily and weekly totals.

Why it matters: Drives runoff, flooding, and standing water forming exposure pathways for water-borne diseases.

MTPR

Mean Precipitation Rate

Average intensity of precipitation within an hour, integrated to daily and weekly totals.

Why it matters: Distinguishes intense short-duration events from prolonged light rain.

SSRD

Surface Shortwave Radiation

Solar energy reaching the surface, expressed as daily or weekly means of hourly values.

Why it matters: Controls surface heating, soil drying, and evaporation rates modifying habitat suitability.

U10/V10

10-m Wind Components

Horizontal wind components at 10 m height, combined into wind speed and direction.

Why it matters: Affects vector dispersal, pathogen transport, and indicates synoptic weather systems.

Sri Lanka Data SourcesClimate:ERA5 reanalysis at hourly resolution on a ~0.25° grid. Two precipitation series (tp and mtpr) are cross-checked.
Health:Weekly case counts by district from Sri Lanka’s Weekly Epidemiological Reports (WER).
Spatial: GADM administrative districts (ADM2).
Time Zone: ERA5 UTC shifted to Asia/Colombo before aggregations.

Spatial Setup for District-Level Aggregation

Gridded climate data must be mapped onto irregular administrative boundaries. An equal-area projection and area-weighted overlay ensure physically consistent district values.

Coordinate Reference Systems (CRS)

Why CRS Matters

Latitude–longitude describes angles, not areas. For area-weighted statistics, use an equal-area projection (e.g., EPSG:6933) so one square meter near the coast counts the same as one inland.

Coastal BiasIn degrees, coastal grid cells can straddle land and ocean. Without accounting for land fraction, coastal districts inherit ocean bias (e.g., cool, dry), distorting comparisons.
From Cells to Districts — 3-Step Process
  1. 1Build polygons for all cells intersecting the study region.
  2. 2Intersect cell polygons with district polygons in an equal-area CRS.
  3. 3Use overlap area as weights to compute district-level means/sums.
Plain-Language ExampleIf a grid cell overlaps Colombo by 40% of its land area and Gampaha by 60%, then 40% of that cell’s daily rainfall contributes to Colombo’s total and 60% to Gampaha’s.
Resampling vs. Overlay Rationale

Resampling (nearest/bilinear) selects or blends values at centers. Acceptable for intensive variables (e.g., temperature) but can distort totals for extensive variables (e.g., precipitation).

Area-weighted overlay respects geometry and conservation: each cell contributes in proportion to its land area. Preferred for district-level summaries, especially rainfall.

Practical Implementation Notes
  • CRS: Project both districts and grid polygons to EPSG:6933.
  • Coastal Cells: Keep only the land fraction inside each district when forming weights.
  • Performance:Precompute and cache the cell×district weight table once; reuse across years/variables.
  • QA:District-area-weighted precipitation summed over all districts ≈ country total. No district receives contributions from cells entirely over ocean.

Workflow: Hourly Grid → District-Day → District-Week

Seven steps transform raw hourly reanalysis fields into a merge-ready district-week feature table. Expand each step for full details.

Step 1 — Convert to Local Time, Then Aggregate to Daily

Shift ERA5 timestamps from UTC to Asia/Colombolocal time, then compute cell-level daily statistics. This is not optional — aggregating in UTC can split nocturnal events across calendar days and push storms into the wrong epidemiological week.

For each grid cell and local day, compute:

  • • Temperature (t2m): daily mean, minimum, and maximum from 24 hourly values
  • • Dewpoint (d2m): daily mean of hourly values
  • • Precipitation (tp): sum all hourly accumulations within the local day, converting from meters to mm (×1000). Clip small negative artifacts to zero.
  • • Precipitation rate (mtpr): integrate hourly rate to daily depth (m/s → mm/day)
  • • Radiation (ssrd): sum hourly values to MJ/m² per day
  • • Wind (u10, v10): daily mean (and max) wind speed
If you skip the timezone conversion, you risk “day-splitting” — a storm that occurs at 11 PM local time gets counted in the next UTC day, which may fall in the wrong week entirely.
Step 2 — Build Area Weights Once

Construct polygons for each ERA5 grid cell from its center coordinates. Intersect these cell polygons with district (ADM2) polygons — both projected to an equal-area CRS (EPSG:6933)— and compute overlap area in square meters.

The result is a cell × district weight tablethat tells you what fraction of each cell’s land area falls inside each district. Store this table and reuse it across all variables and all dates — it only needs to be computed once.

Example:If a grid cell overlaps Colombo by 40% of its land area and Gampaha by 60%, then 40% of that cell’s daily rainfall contributes to Colombo’s total and 60% to Gampaha’s.
Why equal-area?In geographic coordinates, one degree of longitude near the equator covers ~111 km, but grid cells are not equal in area. If you compute statistics in degrees, coastal cells with large extent but little land can dominate district averages, introducing ocean bias (cooler, drier) into your estimates.
Step 3 — Make Daily District Values

For each district and each local day, apply the area weights from Step 2 to convert cell-level daily statistics into district-level daily values:

  • • State variables (temperature, humidity, radiation, wind): compute the area-weighted mean across all contributing cells
  • • Flux variables (precipitation): compute the area-weighted sum to preserve physical totals

After weighting, clip any remaining small negative precipitation values to zero (these are numerical artifacts from the reanalysis). At this point you have a clean district × day table for every variable.

For Sri Lanka, this produces daily series for 25 districts, with temperature in °C, precipitation in mm/day, radiation in MJ/m²/day, and wind in m/s.
Step 4 — Create Weekly Features Aligned to Surveillance

Using the WER’s week-ending rule (Saturday–Friday for Sri Lanka), gather the days in each local-time epidemiological week and compute:

Precipitation

  • • Weekly total (precip_tp_sum_week)
  • • Wet-day count (≥10 mm threshold)
  • • Longest wet spell (consecutive wet days)
  • • Max 3-day precipitation total

Temperature & Other

  • • Weekly mean temperature (tmean_mean)
  • • Mean of daily maxima (tmax_mean)
  • • 95th percentile of daily maxima (tmax_p95)
  • • Weekly mean RH, VPD, radiation, wind

Always record n_days_week(the number of valid days in each week). Rather than discarding incomplete weeks, apply minimum-coverage rules during analysis — this preserves data at period boundaries.

Step 5 — Add Short-Term Memory (Lags, Rolling Windows, EWAP)

Disease outcomes often reflect recent climate history — vector life cycles, environmental pathogen persistence, and reporting delays mean conditions from prior weeks still matter. Build three types of memory features:

Lags (Discrete Delays)

Create separate predictors for weeks t−1 through t−6 (*_lag1 … *_lag6). Use 0–2 week lags for leptospirosis–precipitation and 2–6 weeks for dengue–heat/moisture as starting windows, then refine with cross-validation.

Rolling Windows (Short Aggregates)

Summarize the last N weeks including the current week (*_roll2w_mean, *_roll4w_sum). Use tolerant windows (≥50% for 2-week, ≥75% for 4-week) to limit NA propagation. These capture sustained wetness or heat rather than single-week spikes.

EWAP (Exponentially Weighted Antecedent Precipitation)

A single index that weights recent rain more than older rain — like a sponge that dries over time. Tune α (0.7–0.9; higher = longer memory) and K (3–6 week horizon). Compresses multi-week history into one predictor, useful with small samples.

No-Leakage RuleBuild features for week t using only weeks ≤ t; never include data from t+1 onward. Left-align all windows.
Sri Lanka settings: lags 1–6 for precip_tp_sum_week, precip_mtpr_sum_week, tmean_mean, and vpd_mean_week. EWAP on tp and mtpr with α ∈ {0.7, 0.8, 0.9} and K ∈ {3, 4, 5, 6}.
Step 6 — Derive Climatologies and Anomalies

For each district and week-of-year (ISO week), compute a baseline (“normal”) using the 1991–2020 period (following WMO guidance). This yields x_normal(district, week_of_year) for each variable. Then derive:

  • • Anomaly: x_anom = x_obs − x_normal
  • • Percent-of-normal: x_pct_normal = x_obs / max(x_normal, ε) with ε = 1 mm for precipitation to avoid divide-by-zero in dry weeks

Why departures matter: Levels indicate absolute exposure, but departures indicate unusualness for the season, which often aligns better with biological and behavioral responses (e.g., an early wet spell during a typically dry season).

Guardrails:Require ≥15 years with data per district/week to form a normal; otherwise mark as missing. Apply a clamp flag when x_normal < ε and document ε in methods.
Step 7 — Join to Health and Population

Harmonize district namesacross all data sources. This is a common source of merge failures — for example, Sri Lanka’s WER uses “Nuwara-Eliya” while GADM may use a different spelling. Standardize names so merges are lossless.

Merge the weekly climate feature table to the WER case counts by district + week. The merge keys are: district, date_start, date_end, year, week_of_year, plus n_days_week.

Add mid-year population by district to compute rates (per 100,000) and to furnish an offset term in Poisson or negative binomial count models. The population offset ensures that districts with more people are not automatically treated as having higher risk.

The final output is a tidy, merge-ready table with one row per district-week, containing climate features (levels, anomalies, lags, rolling windows, EWAP), health case counts, population, and coverage metadata — ready for modeling.

Derived Features

Derived features transform ERA5’s native variables into epidemiology-ready signals. The order of operations matters to avoid leakage.

Leakage PreventionLeakage occurs when features for week t use information from after week t or from the outcome itself. Prevent it by (1) left-aligning windows, (2) computing intra-week metrics strictly within week boundaries, and (3) fitting transforms inside the training fold only.
Humidity & Heat-Stress Metrics (RH, VPD, WBGT)

Relative Humidity (RH) from t2m/d2m; Vapor Pressure Deficit (VPD) from saturation minus actual vapor pressure. Daily values averaged from hours; weekly values are means of daily values.

Avoid co-modeling RH and VPD without strong rationale due to algebraic linkage.
Precipitation Event Descriptors
  • Wet-Day Count:Days ≥ threshold (default 10 mm; also 5 and 20 mm for sensitivity).
  • Longest Wet Spell: Longest run of consecutive wet days within the week.
  • Maximum 3-Day Total: Largest sliding 3-day sum within the week.
The pattern of rain within a week (frequency, clustering, run length) can change risk even when weekly totals are identical.
Climatology and Anomalies
  • Anomaly:x_anom = x_obs − x_normal
  • Percent-of-Normal:x_pct_normal = x_obs / max(x_normal, ε)

Levels indicate absolute exposure; departures indicate unusualness for the season, which often aligns with biological and behavioral responses.

Short-Term Memory: Lags, Rolling Windows, EWAP

Lags

Separate predictors for previous weeks (*_lag1 … *_lag6). Supports DLNM to map exposure–lag responses.

Rolling Windows

Summarize the last N weeks (*_roll2w_mean, *_roll4w_sum). Capture background conditions instead of a single spike.

EWAP

Exponentially Weighted Antecedent Precipitation — weights recent rain more than older rain. α controls decay (0.7–0.9 typical); K sets horizon (3–6 weeks).

Order of Operations
  1. Build weekly base features and record n_days_week.
  2. Compute weekly RH/VPD and event descriptors from daily inputs.
  3. Construct climatologies; then anomalies/percent-normal from weekly bases.
  4. Create lags/rolls/EWAP from levels (and from anomalies, only if required).
  5. Preserve exact naming per the variable dictionary.

Quality Assurance & Diagnostics

Quick sanity checks catch unit errors, merge failures, and pipeline bugs before they propagate into model results.

QA Checks

Range / Sign Checks

Negative precipitation after clipping should be zero; dew point ≤ air temperature; near-saturated RH should align with very low VPD.

One-Week Hand Check

For a chosen district/week, recompute the weekly precipitation sum from daily values to confirm builder logic.

Cross-Source Check

Compare ERA5 weekly precipitation totals against station-derived weekly totals in a few districts. Order-of-magnitude mismatches usually indicate unit or integration errors.

Reproducibility Pins

Record CRS codes, time-zone handling, random seeds, and package versions.

Modeling Weekly Outcomes

Strategies for linking weekly climate features to health outcomes, including count models, delayed effects, and interpretable machine learning.

Count Models

Robust starting points include negative binomial or quasi-Poisson with a population offset. Handle seasonality with smoothers and evaluate with blocked/forward-chaining cross-validation to respect time order.

Delayed / Nonlinear Effects

Use Distributed Lag Non-Linear Models (DLNM)to estimate exposure–lag–response surfaces. For transient risks, consider case-crossover or the case time-series design.

Measurement Error & MAUP

Assigning gridded exposures to districts induces spatial misalignment; classical error tends to attenuate coefficients; Berkson error inflates variance. Area-weighted overlays reduce, but do not eliminate, this issue.

Interpretable ML (Optional)

For early-warning tasks, prefer ALE for global structure and apply SHAP cautiously with correlated predictors.

Worked Example — Colombo, Sri Lanka

A concrete walkthrough applying every workflow step to a single district-week, illustrating the full pipeline from raw ERA5 to a merge-ready row.

Colombo District — Week Ending 2020-05-08
1

Localize Time

Convert ERA5 hours UTC → Asia/Colombo.

2

Define Week Window

Saturday–Friday in local time.

3

Cell-Day Statistics

Daily means for t2m, RH, VPD, ssrd; daily min/max for temperature; sum tp (m→mm) and integrate mtpr; clip tiny negatives.

4

Area-Weight to District-Day

Apply EPSG:6933 weights; means for state variables, sums for precipitation.

5

Weekly Features

Total precipitation, wet days (≥10 mm), longest wet spell, max 3-day total, weekly mean temperature, mean of daily maxima, 95th percentile of daily maxima, n_days_week.

6

Short-Term Memory

Add lag-1 and lag-2 precipitation and temperature.

7

Contextualize

Compute anomalies and percent-normal for week-19 using 1991–2020 climatology.

8

Join to Health

Merge the climate feature row to the WER case count for Colombo for that week.

Appendix A: Sri Lanka Implementation Details

Condensed implementation notes specific to the Sri Lanka case study, including data sources, spatial boundaries, and the variable dictionary.

Health Data: Weekly Epidemiological Reports

Weekly case counts by district from Sri Lanka’s WER. Each record carries a district name and week-ending date. District names are harmonized (e.g., standardizing “Nuwara-Eliya”) to ensure lossless merges.

Climate Data: ERA5 Reanalysis

ERA5 at hourly resolution on a ~0.25° grid. Two precipitation series: tp (accumulated depth) and mtpr (average rate). Weekly sums are computed for both and cross-checked, with small negatives clipped to zero.

Spatial Boundaries: GADM Districts

Administrative districts (ADM2) from GADM. Geometry validated, names standardized, overlaps computed in EPSG:6933 so weights are in true square meters.

Variable Dictionary (Illustrative Selection)
VariableDescription
tmean_meanWeekly mean temperature
tmax_meanMean of daily maximum temperatures
tmax_p9595th percentile of daily max temp
rh_mean_weekWeekly mean relative humidity
vpd_mean_weekWeekly mean vapor pressure deficit
precip_tp_sum_weekWeekly precipitation total (tp)
precip_mtpr_sum_weekWeekly precipitation total (mtpr)
wet_days_ge10_tpWet days ≥ 10 mm
max3d_tpLargest 3-day precipitation total
wet_spell_maxlen_tpLongest consecutive wet-day run
*_lag1 … _lag61–6 week lags
*_roll2w_mean2-week rolling mean
ewap_tpExponentially weighted antecedent precip
n_days_weekValid days in week

Appendix B: Climate Variables in Detail

Reference table of ERA5 variables with native units, daily aggregation methods, and weekly roll-up strategies. Expand individual variables for deeper discussion.

VariableNative UnitsDaily Agg.Weekly Agg.
2-m Air Temp (T2M)K → °CMean, min, maxMean of daily means; quantiles
2-m Dewpoint (D2M)K → °CMean of hourlyMean of daily means
Total Precip (TP)m/hr → mmSum → mm/daySum → mm/week
Mean Precip Rate (MTPR)m/s → mm/hrIntegrate → mm/daySum → mm/week
Shortwave Rad (SSRD)J/m² → MJ/m²Sum → MJ/m²/dayMean of daily
10-m Wind (U10, V10)m/sMean (& max) speedMean of daily means
2-m Air Temperature (TA)

Modeled dry-bulb air temperature 2 m above the surface. Convert from Kelvin with °C = K − 273.15. Key determinant of heat stress, thermoregulation, crop growth, and vector/pathogen development rates.

2-m Dewpoint Temperature (TD)

Temperature at which air becomes saturated. More stable than RH (less diurnal swing), making it robust for weekly summaries. Negative dewpoints are valid and signal very dry air.

Total Precipitation (TP)

Accumulated depth of liquid water equivalent per hour. Convert meters to mm (×1000). Small negative values from reanalysis noise should be clamped to zero. ERA5’s 0.25° grid smooths localized convective rainfall.

Mean Total Precipitation Rate (MTPR)

Time-averaged precipitation intensity per hour. Reported as m/s; multiply by 3600 for m/hr, then ×1000 for mm/hr. Provides an independent estimate of depth for cross-checking TP.

Surface Shortwave Radiation (SSRD)

Total incoming solar radiation reaching the surface. Accumulated per hour in J/m²; convert to MJ/m² by dividing by 10⁶. Cloud cover strongly modulates SSRD.

10-m Wind Components (U10, V10)

East–west (U10) and north–south (V10) horizontal wind at 10 m. Wind speed = √(u² + v²). ERA5 fields are generally reliable but local terrain is not resolved at 0.25°.

References

Methodological and data sources cited throughout this guide, covering reanalysis products, statistical methods, and climate-health linkage.

Full Reference List

Apley, D. W., & Zhu, J. (2020). Visualizing the effects of predictor variables in black box supervised learning models. JRSS-B, 82(4), 1059–1086.

Bergmeir, C., & Benítez, J. M. (2012). On the use of cross-validation for time series predictor evaluation. CSDA, 70, 324–335.

Bhaskaran, K., et al. (2013). Time series regression studies in environmental epidemiology. IJE, 42(4), 1187–1195.

Carroll, R. J., et al. (2006). Measurement error in nonlinear models (2nd ed.). Chapman & Hall/CRC.

Dormann, C. F., et al. (2013). Collinearity: A review of methods. Ecography, 36(1), 27–46.

Fotheringham, A. S., & Wong, D. W. S. (1991). The modifiable areal unit problem. Environment and Planning A, 23(7), 1025–1044.

Gasparrini, A. (2010). Distributed lag non-linear models. Statistics in Medicine, 29(21), 2224–2234.

Gasparrini, A. (2021). The case time series design. Epidemiology, 32(6), 829–837.

Gryparis, A., et al. (2009). Measurement error caused by spatial misalignment. Biostatistics, 10(2), 258–274.

Hersbach, H., et al. (2020). The ERA5 global reanalysis. QJRMS, 146(730), 1999–2049.

Karl, T. R., et al. (1999). CLIVAR/GCOS/WMO workshop on indices and indicators for climate extremes. Climatic Change, 42(1), 3–7.

Liljegren, J. C., et al. (2008). Modeling the wet bulb globe temperature. JOEH, 5(10), 645–655.

Mennis, J. (2003). Generating surface models of population using dasymetric mapping. The Professional Geographer, 55(1), 31–42.

Peng, R. D., et al. (2006). Model choice in time series studies of air pollution and mortality. JRSS-A, 169(2), 179–203.

Simmons, A. J., et al. (2018). A reassessment of temperature variations and trends from global reanalyses. QJRMS, 144(713), 29–49.

WMO (2017). Guidelines on the calculation of climate normals (WMO-No. 1203).

Zhang, X., et al. (2011). Indices for monitoring changes in extremes. WIREs Climate Change, 2(6), 851–870.

Zou, H., & Hastie, T. (2005). Regularization and variable selection via the elastic net. JRSS-B, 67(2), 301–320.

Contact CGHIGuide