How stephanie-iris/mmc-watershed-data works
Purpose and Entry Points
MMC Watershed Data is a Python 3.11+ rainfall-collection and analysis package for Moores Mill Creek stations in Auburn and Opelika, Alabama. Its primary entry point is the mmc CLI, implemented through src/mmc_watershed_data/__main__.py and src/mmc_watershed_data/cli.py. A separate local Streamlit entry point is src/mmc_watershed_data/dashboard.py. The reproducible publication entry point is reports/mmc-rainfall-report.qmd.
Orchestrated Collection Workflow
src/mmc_watershed_data/workflow.py coordinates a date-bounded run across configured stations: fetch each source, preserve evidence, validate/transform records, and persist outputs. src/mmc_watershed_data/config.py supplies operational settings and station/source configuration; src/mmc_watershed_data/stations.py represents and selects the station set. Failures are station-scoped, allowing other stations to complete.
Source-Specific API Adapters
A source boundary isolates incompatible public APIs:
• src/mmc_watershed_data/auburn.py calls LI-COR’s timeseries endpoint and converts epoch-millisecond readings into the project’s UTC-6 display representation while retaining rainfall as RainIn.
• src/mmc_watershed_data/opelika.py calls ThorArchive’s interval endpoint and converts cumulative RainToday values to interval RainIn; negative deltas are treated as gauge resets.
• src/mmc_watershed_data/api.py provides the shared HTTP/API interaction layer.
Neither public source requires credentials.
Evidence, Validation, and Persistence Boundary
The canonical processing boundary is API response → raw JSON evidence → Pydantic validation → processed CSV. src/mmc_watershed_data/models.py defines structured data contracts, and src/mmc_watershed_data/validation.py enforces source payload and record validity before data become analytical outputs. src/mmc_watershed_data/storage.py owns run-specific raw JSON/raw CSV and processed CSV layout under generated data/raw/... and data/processed/....
Analysis and Event Semantics
src/mmc_watershed_data/analysis.py operates on processed interval observations. It derives rainfall events from positive RainIn observations, grouping nearby observations using the documented one-hour tolerance, and produces event duration, total precipitation, and participating-station summaries. This layer should consume processed CSV/schema-compatible records rather than live API payloads.
Interactive Dashboard and Geospatial Context
src/mmc_watershed_data/dashboard.py is a Streamlit UI that can trigger collection or load saved processed datasets, display station rainfall charts, and present event analysis. src/mmc_watershed_data/geospatial.py loads station and watershed geometries for OpenStreetMap-based views. Its immutable local spatial inputs are assets/geospatial/stations/auburn_stations.kmz, assets/geospatial/stations/opelika_stations.kmz, and assets/geospatial/watershed/mmc_boundary.kmz.
Reporting and Runtime Boundaries
src/mmc_watershed_data/reporting.py loads the newest matching processed-data collection (or bundled fallback data) and supplies report-ready summaries, maps, and charts to reports/mmc-rainfall-report.qmd. The committed fallback is reports/data/mmc_report_2026-07-01_to_2026-08-01_processed.csv; the rendered artifact is reports/mmc-rainfall-report.pdf. Runtime infrastructure is Python managed by uv; reporting additionally requires Quarto, a configured project Python/Jupyter kernel, and a PDF engine such as TinyTeX. Operational diagnostics are centralized in src/mmc_watershed_data/logging_config.py.
Components 19
Collection
Date-bounded station collection workflow.
- mmc CLI
src/mmc_watershed_data/cli.py - Collection workflow · Continues processing when an individual station fails.
src/mmc_watershed_data/workflow.py - Settings & sources
src/mmc_watershed_data/config.py - Station selection
src/mmc_watershed_data/stations.py - HTTP API layer
src/mmc_watershed_data/api.py - LI-COR adapter · Converts epoch-millisecond readings to UTC-6 display records.
src/mmc_watershed_data/auburn.py - ThorArchive adapter · Converts cumulative RainToday values and handles gauge resets.
src/mmc_watershed_data/opelika.py - LI-COR timeseries API · Credential-free Auburn source.
- ThorArchive interval API · Credential-free Opelika source.
Data boundary
Evidence, validation, and persisted analytical data.
- Run data storage · Owns generated raw JSON, raw CSV, and processed CSV layout.
src/mmc_watershed_data/storage.py - Data contracts
src/mmc_watershed_data/models.py - Payload validation · Validates source payloads and records before analytical output.
src/mmc_watershed_data/validation.py - Processed CSV · Schema-compatible interval observations under data/processed.
Analysis and publishing
Interactive and reproducible data consumers.
- Rainfall event analysis · Groups positive RainIn observations with a one-hour tolerance.
src/mmc_watershed_data/analysis.py - Streamlit dashboard · Collects or loads saved data for charts and event views.
src/mmc_watershed_data/dashboard.py - Geospatial context · Loads immutable station and watershed KMZ geometry.
src/mmc_watershed_data/geospatial.py - Report data provider · Loads newest processed data or bundled fallback.
src/mmc_watershed_data/reporting.py - Rainfall report · Reproducible report rendered with Python/Jupyter and PDF tooling.
reports/mmc-rainfall-report.qmd - Bundled fallback CSV
reports/data/mmc_report_2026-07-01_to_2026-08-01_processed.csv
Connections 23
- mmc CLI → Collection workflow: runs collection
- Collection workflow → Settings & sources: loads settings
- Collection workflow → Station selection: selects stations
- Collection workflow → LI-COR adapter: fetches Auburn
- Collection workflow → ThorArchive adapter: fetches Opelika
- LI-COR adapter → HTTP API layer: uses
- ThorArchive adapter → HTTP API layer: uses
- HTTP API layer → LI-COR timeseries API: requests
- HTTP API layer → ThorArchive interval API: requests
- Collection workflow → Run data storage: preserves raw evidence
- Collection workflow → Payload validation: validates records
- Payload validation → Data contracts: enforces contracts
- Payload validation → Run data storage: permits persistence
- Run data storage → Processed CSV: writes
- Processed CSV → Rainfall event analysis: interval observations
- Streamlit dashboard → Collection workflow: can trigger
- Streamlit dashboard → Processed CSV: loads saved data
- Streamlit dashboard → Rainfall event analysis: displays events
- Streamlit dashboard → Geospatial context: renders map context
- Report data provider → Processed CSV: loads newest
- Report data provider → Bundled fallback CSV: falls back to
- Rainfall report → Report data provider: uses summaries and charts
- Report data provider → Geospatial context: builds maps