8000 GitHub - ayushinn/devx · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

ayushinnPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Heatwave Early Warning API

A FastAPI service and live map dashboard for estimating human heat stress from submitted observations and Open-Meteo weather forecasts.

Run locally

py -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txt
python -m uvicorn app.main:app --reload

The live satellite map dashboard is available at http://127.0.0.1:8000; interactive API documentation is at /docs. The dashboard supports city search, browser location, and selecting a point on the map. Use the map layer control to switch between satellite imagery and the street map. Forecast data refreshes every 15 minutes while the page is open.

Endpoints

  • GET /health reports service health.
  • POST /api/v1/heat-risk/assess estimates heat index, categorizes risk, and returns precautions for one observation.
  • POST /api/v1/heat-risk/model-assess returns an experimental ML estimate and class probabilities. The deterministic endpoint above remains the canonical assessment.
  • POST /api/v1/heat-risk/forecast assesses a supplied series of up to 168 forecast observations.
  • GET /api/v1/heat-risk/live?latitude=19.076&longitude=72.8777 fetches current conditions and a seven-day forecast, then returns current risk, daily risk outlook, and potential heatwave periods.

The live endpoint uses Open-Meteo's Forecast API and does not require a key for basic use. Coordinates use decimal latitude/longitude.

Example request:

{
  "temperature_c": 38,
  "humidity_percent": 65,
  "observed_at": "2026-10-14T12:00:00Z",
  "vulnerable_groups": ["older adults", "outdoor workers"]
}

Heatwave screening and limitations

Heat index is the NOAA temperature-and-humidity estimate for shaded conditions with light wind. The live endpoint detects a potential heatwave when daily maximum heat index reaches 39.4 C for at least two consecutive forecast days. This is a transparent screening heuristic, not an official regional heatwave definition or a trained ML prediction. Thresholds should be calibrated to local climatology and official guidance before operational use. The service does not issue alerts or compute a full WBGT index.

Experimental classifier

The repository includes hourly historical weather for six cities from 2020 through 2025 in data/heat_risk_training.csv. The observations come from the Open-Meteo Archive API (CC BY 4.0). The risk categories are labels generated by this project's NOAA heat-index formula and thresholds, not independently observed health outcomes. The classifier therefore learns to approximate existing rules; it is an experiment, not evidence of improved or clinically validated prediction. The regular assessment and live endpoints continue to use the deterministic rules.

The saved artifact is models/heat_risk_classifier.joblib. Retrain from the included data with:

python -m scripts.train_heat_risk_model --reuse-data

To refresh the historical data from Open-Meteo and retrain:

python -m scripts.train_heat_risk_model

The script trains on 2020-2024 and reports results on the 2025 holdout. The extreme-danger category is rare in that holdout, so its score is especially uncertain.

Tests

python -m pip install -r requirements-dev.txt
python -m pytest

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0