Skip to content

feat(vrt): single-band viewer VRTs for scalar datasets#68

Merged
emmanuelmathot merged 2 commits into
mainfrom
fix/single-band-viewer-vrt
Jun 30, 2026
Merged

feat(vrt): single-band viewer VRTs for scalar datasets#68
emmanuelmathot merged 2 commits into
mainfrom
fix/single-band-viewer-vrt

Conversation

@emmanuelmathot

Copy link
Copy Markdown
Contributor

Fixes #66.

Summary

  • Added SingleBandComposite dataclass to datasets/base.py (mirrors RgbComposite but for 1-band/scalar products)
  • Added viewer_bands() -> list[SingleBandComposite] hook to Dataset base (default: [])
  • SwotRaster100mDataset overrides viewer_bands() to expose one composite per configured variable (e.g. wse)
  • Added build_single_band_vrt_xml(grids) to vrt.py — same mosaic logic as RGB but emits a 1-band Gray VRT
  • Added crs_epsg(crs_wkt) helper to extract the outermost EPSG code from WKT (used for per-zone VRT naming)
  • Extended _publish_rgb_vrts in runner.py to also iterate viewer_bands() after the RGB composites loop:
    • Collects grids for each band across all products
    • Groups by CRS WKT — a France-wide SWOT run spanning UTM zones 30–32 gets run-wse-epsg32630.vrt, run-wse-epsg32631.vrt, run-wse-epsg32632.vrt instead of nothing
    • Single-zone runs get a clean run-wse.vrt

Test plan

  • test_single_band_vrt_has_one_gray_band — Gray colorinterp, correct pixel value
  • test_single_band_vrt_mosaics_two_tiles — union extent, correct DstRect placement
  • test_single_band_vrt_raises_on_empty_grids
  • test_crs_epsg_extracts_from_wkt — extracts outermost EPSG (not nested datum/spheroid codes)
  • test_crs_epsg_returns_none_for_unknown
  • test_swot_viewer_bands_default — default wseSingleBandComposite(name="wse", band="wse")
  • test_swot_viewer_bands_custom_variables
  • test_base_dataset_viewer_bands_returns_empty — SingleObjectDataset returns []

🤖 Generated with Claude Code

Adds a `viewer_bands()` hook to `Dataset` (analogous to `rgb_composites()`)
and a `build_single_band_vrt_xml()` function to `vrt.py`. `_publish_rgb_vrts`
now falls back to single-band Gray mosaic VRTs when no RGB composite exists,
grouping by CRS WKT so a multi-UTM-zone run (e.g. SWOT France) emits one VRT
per zone (`run-wse-epsg32631.vrt`). `SwotRaster100mDataset` overrides
`viewer_bands()` to expose one composite per configured variable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@emmanuelmathot
emmanuelmathot merged commit cb46390 into main Jun 30, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single-band datasets get no viewer VRT — _publish_rgb_vrts only emits RGB composites

1 participant