Statistical analysis of weather drivers of PM2.5 in four East African cities, via the OpenAQ and Open-Meteo APIs, with an interactive Dash dashboard.
# NEMA · Weather & Air Quality in East African Cities
A data-analytics consultancy engagement for the **National Environment Management
Authority (NEMA)**, quantifying how weather conditions drive fine-particulate
pollution (PM2.5) in **Nairobi, Kampala, Kigali, and Addis Ababa**, using two public
APIs. The emphasis is a defensible, end-to-end analytics workflow, from API
acquisition through data-quality assessment, statistical modelling, and
evidence-linked recommendations, surfaced in an interactive dashboard.
> **Headline result.** Weather has statistically robust *associations* with PM2.5
> (rain scavenging, wind dispersion) but limited standalone *predictive* skill at the
> daily scale. The analysis is careful to distinguish the two.
---
## Table of contents
- Data sources
- Quickstart
- Running the pipeline
- The dashboard
- Testing & coverage
- Project structure
- Methodology
- Key findings
- Reproducibility & data notes
---
## Data sources
Two independent APIs are merged into a single **city–day panel** on `city + date`,
with timestamps aligned to each city's local timezone before joining.
| Role | API | Endpoint(s) | Variables |
|------|-----|-------------|-----------|
| Dependent variable | **OpenAQ v3** (`api.openaq.org`) | `GET /v3/locations`, `GET /v3/sensors/{id}/measurements` | `pm25` (µg/m³) |
| Independent variables | **Open-Meteo Historical** (`archive-api.open-meteo.com`) | `GET /v1/archive` (`daily` + `hourly`) | temperature, precipitation, wind speed, relative humidity |
- **OpenAQ** requires a free API key (register at openaq.org).
Requests are split into date chunks with retry/back-off, because large multi-year
windows time out server-side.
- **Open-Meteo** is keyless. Daily temp/precip/wind come from the `daily` block;
humidity is aggregated to daily from the `hourly` block.
Study window: **2020–2024**. Unit of analysis: **one city-day**.
---
## Quickstart
**Prerequisites:** Python 3.10+ and Git.
### 1. Clone and create a v …