Skip to content

Plan unified visualization and reporting layer for climate-toolkit outputs #25

Description

@peetmate

Plan unified visualization and reporting layer for climate-toolkit outputs

Summary

Current toolkit mostly prints terminal tables and saves JSON/CSV, with limited plotting only in climatology. We need deliberate visualization/reporting layer spanning:

  • historical climate summaries
  • season analysis
  • period comparisons
  • NEX-GDDP ensemble comparisons
  • hazards outputs
  • weather-station candidate review and station-vs-grid diagnostics

This should be treated as major enhancement project, not ad hoc plot additions.

Why this matters

  • terminal outputs getting too dense for users to monitor or interpret
  • many modules now return rich structured outputs that are difficult to inspect quickly
  • ensemble workflows need uncertainty shown visually, not only printed means
  • station-vs-grid workflow needs diagnostic plots/maps to support source selection
  • current plotting logic is isolated in climate_tookit/climatology/long_term_climatology.py and not reusable across package

Current state in repo

  • climate_tookit/climatology/long_term_climatology.py already writes annual time-series and monthly climatology PNGs via matplotlib
  • weather-station workflow now emits HTML candidate maps/tables, but layout and reporting are still narrow-purpose
  • most other modules emit terminal tables + JSON/CSV only
  • no shared plotting API, no shared style/config, no common report bundle convention

Research notes: recommended stack and patterns

Core stack

  1. xarray + matplotlib for baseline static figures

  2. Cartopy for publication-quality climate maps

    • Strong choice for projected climate maps, anomaly maps, gridded fields, multi-panel map layouts.
    • Better than plain scatter/leaflet for static atlas-style outputs.
    • Source: Cartopy docs
      https://cartopy.readthedocs.io/stable/
  3. hvPlot / HoloViews / Panel for optional interactive HTML dashboards

  4. Folium for lightweight standalone HTML maps

  5. geemap as optional Earth Engine exploration layer, not hard dependency

    • Useful for GEE-backed exploratory maps, inspectors, split maps, timeseries interaction.
    • Should stay optional because package must not force GEE-bound visualization path for all users.
    • Source:
      https://geemap.org/

Ensemble / uncertainty best practice

Verification / station-vs-grid diagnostics

  • Daily precipitation correlation alone is weak and often misleading.
  • Need multi-timescale diagnostics:
    • daily event skill
    • monthly totals
    • seasonal totals
    • annual descriptive totals
    • bias / MAE / RMSE / correlation
    • wet-day contingency metrics
  • xskillscore is strong fit for standardized verification metrics if we move more calculations onto xarray-aligned structures.
  • Source:
    https://xskillscore.readthedocs.io/en/stable/

Design principles for toolkit visualization layer

  1. Machine-readable first, plot second

    • plotting should consume standardized output payloads, not terminal text
    • each module should expose stable report-ready structures
  2. Static first, interactive second

    • first target: robust PNG/SVG/HTML exports from CLI
    • second target: richer interactive dashboards where justified
  3. Uncertainty-aware by default

    • ensemble plots should show spread, percentiles, counts of contributing models, and missingness
  4. CF/unit aware labeling

    • variable labels and units should come from harmonized metadata layer
    • avoid hard-coded inconsistent labels across modules
  5. Separate map outputs from time-series/stat-table outputs

    • site/station geography problem differs from seasonal or climatology diagnostics
  6. Report bundle convention

    • one run should be able to emit organized bundle, e.g.:
      • report.json
      • tables/*.csv
      • figures/*.png
      • maps/*.html
      • index.html
  7. Optional dependency groups

    • keep installable base package lean
    • likely extras such as viz, maps, dashboard

Recommended scope by module

1. climate_statistics

  • annual rainfall seasonality panel
  • monthly climatology bars/lines
  • detected/fixed season window timeline
  • seasonal summary cards/tables
  • humid/perhumid guard explanation box

2. season_analysis

  • rainfall + ET0 + water balance time series with detected onset/cessation markers
  • season-within-window timeline
  • intra-season dry-spell visualization
  • multi-year onset/cessation scatter / box plots

3. compare_periods.periods

  • baseline vs focal/future seasonal bars
  • anomaly plots
  • percent-change panels
  • “review required” annotation panels when season comparability weak

4. compare_periods.ensemble_periods

  • ensemble fan charts for temperature / precipitation / water balance metrics
  • baseline vs future ridge/small-multiple model spreads
  • season-specific uncertainty bars
  • model contribution / missingness panel

5. calculate_hazards

  • hazard scorecards
  • threshold exceedance frequency plots
  • seasonal hazard comparison panels
  • later: map-ready hazard layers if/when spatial workflows mature

6. weather_station

  • nearby-station candidate map with basemap, distance lines, completeness scaling
  • station coverage calendar heatmaps
  • station-vs-grid monthly/seasonal comparison panels
  • variable-by-variable source ranking summary
  • pooled multi-station diagnostics plots

Proposed implementation phases

Phase 0: output contracts and metadata

  • define shared report/figure schema
  • normalize variable labels/units for plot use
  • identify canonical “tidy” table per module
  • decide where xarray structures are worth preserving

Phase 1: shared plotting foundation

  • create climate_tookit.visualization package
  • add plot config, palettes, label helpers, file naming helpers
  • add shared table-to-figure utilities
  • add optional dependency extras in packaging

Phase 2: static CLI exports

  • add reusable PNG/SVG exports for:
    • climatology
    • season analysis
    • compare_periods
    • ensemble_periods
    • weather_station compare

Phase 3: map/report outputs

  • formalize HTML map generation for station candidate review
  • add report bundle writer and simple index.html
  • add multi-site map and summary outputs where relevant

Phase 4: interactive dashboards

  • prototype Panel/hvPlot report for:
    • ensemble compare
    • weather station compare
    • multi-site exploration
  • keep optional; do not block CLI use

Phase 5: docs and examples

  • user guide for figure/report outputs
  • example commands and screenshots
  • notes on when to prefer static vs interactive outputs

Suggested package structure

climate_tookit/visualization/
  __init__.py
  config.py
  labels.py
  io.py
  styles.py
  timeseries.py
  climatology.py
  seasons.py
  compare_periods.py
  ensembles.py
  hazards.py
  weather_station.py
  maps.py
  report_bundle.py

Initial heavy-lift decisions to make before coding too much

  1. Should canonical plot inputs be pandas tables, xarray objects, or dual-format adapters?
  2. Which outputs must be supported in pure CLI batch mode?
  3. Which dependencies stay optional?
  4. Should index.html be plain Jinja/Folium output first, with Panel later?
  5. How much of weather-station compare should move onto xarray/xskillscore structures first?

Concrete first tranche after this issue

  1. Inventory each module’s structured outputs and define canonical plot-ready tables.
  2. Design minimal shared visualization API and output bundle layout.
  3. Implement two exemplars first:
    • ensemble_periods uncertainty plot set
    • weather_station.compare diagnostics + map bundle
  4. Only then propagate to other modules.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    codexIssue raised or formalized by CodexenhancementNew feature or requestneeds-docsImplementation or UX change needs documentation updatespriority:mediumMedium priorityresearchNeeds literature, benchmarking, or external-method reviewuxUser experience, messaging, or workflow friction

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions