Skip to content

dgitis/black-ice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black Ice Predictor

A "should I ride today?" black ice prediction tool for Vancouver cyclists. Takes weather forecast data, runs it through a rule-based risk model, and emails a morning risk assessment (Safe / Caution / Dangerous).

Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Usage

1. Collect training data

Scrape Reddit for historical ice reports (do once — hits the API):

python3 -m src.scraper.reddit scrape

To re-run just the relevance filter on already-scraped data (fast, no network):

python3 -m src.scraper.reddit filter

Collect historical weather data from Environment Canada (takes a while):

python3 -m src.weather.env_canada

Build labeled dataset by propagating ice labels across cold spells:

python3 -m src.labeler.propagate

2. Validate model

Run the rule-based model against the labeled dataset:

python3 -m src.validate

3. Run prediction

Get today's prediction (requires SMTP env vars for email):

python3 -m src.main

4. Run tests

pytest

Environment Variables (for email notifications)

Variable Description
SMTP_HOST SMTP server hostname
SMTP_PORT SMTP port (default: 587)
SMTP_USER SMTP username/email
SMTP_PASS SMTP password or app password
NOTIFY_EMAIL Email address to send predictions to

GCP Cloud Function Deployment

  1. Install the gcloud CLI and authenticate
  2. Deploy:
gcloud functions deploy predict-ice \
  --runtime python311 \
  --trigger-http \
  --entry-point predict_ice \
  --source . \
  --set-secrets 'SMTP_HOST=smtp-host:latest,SMTP_PORT=smtp-port:latest,SMTP_USER=smtp-user:latest,SMTP_PASS=smtp-pass:latest,NOTIFY_EMAIL=notify-email:latest'
  1. Set up Cloud Scheduler to trigger at 5:00 AM PST daily:
gcloud scheduler jobs create http black-ice-daily \
  --schedule "0 5 * * *" \
  --time-zone "America/Vancouver" \
  --uri "FUNCTION_URL" \
  --http-method POST

Findings

See findings.md for detailed methodology, results, and limitations.

Architecture

src/
├── scraper/reddit.py      # Arctic Shift API — historical Reddit ice reports
├── weather/
│   ├── env_canada.py      # Environment Canada historical hourly data
│   └── forecast.py        # Current conditions fetcher
├── labeler/propagate.py   # Label propagation across cold spells
├── model/rules.py         # Rule-based prediction (temp, humidity, dew point, wind, precip)
├── notify/email.py        # SMTP email notifications
├── validate.py            # Model validation against labeled data
└── main.py                # Entry point + Cloud Function handler

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages