Skip to content

feat(esm_catalog): PR-A1b-2 — GRIB + ECHAM scanners#1486

Open
siligam wants to merge 21 commits into
esm-catalog/pr-a1b1-scan-netcdffrom
esm-catalog/pr-a1b2-grib-echam
Open

feat(esm_catalog): PR-A1b-2 — GRIB + ECHAM scanners#1486
siligam wants to merge 21 commits into
esm-catalog/pr-a1b1-scan-netcdffrom
esm-catalog/pr-a1b2-grib-echam

Conversation

@siligam

@siligam siligam commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

PR-A1b-2 — GRIB + ECHAM scanners

Provenance: this implementation is substantially Paul Gierz's work, carried over from his esm-tools-plus/simcat/pgierz-workbench prototype branch (commits Mar–Apr 2026). This PR ports it, largely as-is, into the reviewable stack.

Completes the scan layer's format support (after #1485 added NetCDF). Adds the two GRIB scanners so esm-catalog scan handles ECHAM/GRIB output, including extension-less files.

Stacked on #1485 (esm-catalog/pr-a1b1-scan-netcdf). Retargets to release as the stack merges.

What's here (+1,201 lines)

  • scan/grib.py — generic GRIB scanner (cfgrib/eccodes) → STAC metadata
  • scan/echam.py — ECHAM-specific scanner: companion .codes table parsing, indicatorOfParameter handling, stream detection
  • scan/detect.py's lazy _dispatch_grib now resolves (no code change needed) — magic-byte sniffing routes extension-less ECHAM output
  • a 179-byte synthetic GRIB2 test fixture (+ README on how it's regenerated) — deliberately tiny, not the 17 MB sample
  • tests: generic GRIB scan via the fixture, magic-byte dispatch for extension-less files, and ECHAM pure-helper unit tests (codes parsing, stream/CF mapping, detection)

Notes

  • Deps: cfgrib + eccodes added to the catalog extra and CI. The eccodes wheel bundles the ECCODES C library (eccodeslib), so no apt step is needed in CI.
  • Cycle stays broken: scan → stac only; the A1a guard test still passes. 42 tests green on 3.9 + 3.12.
  • Known minor follow-up: grib.py/echam.py each carry an identical private copy of two codes-file helpers (from verbatim extraction) — a dedup is a candidate later cleanup.

This is the last piece of Miguel's "scan run dirs" unit. Next: PR-A2 (DuckDB shard) = "construct shards". Plan: PR-A1b plan

@siligam
siligam force-pushed the esm-catalog/pr-a1b1-scan-netcdf branch from 3cb83f3 to e853cac Compare June 17, 2026 12:12
@siligam
siligam force-pushed the esm-catalog/pr-a1b2-grib-echam branch from 5c8147d to 01a4bd9 Compare June 17, 2026 12:12
@siligam
siligam force-pushed the esm-catalog/pr-a1b1-scan-netcdf branch from e853cac to bdc93bd Compare June 17, 2026 15:54
@siligam
siligam force-pushed the esm-catalog/pr-a1b2-grib-echam branch from 01a4bd9 to 9498a0f Compare June 17, 2026 15:55
siligam and others added 21 commits June 17, 2026 18:33
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ependency)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… unused field, tighten guard test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dd scan_all_namelists

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…he/import cleanups, use collection_title

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Generated with eccodes (regular_ll_pl_grib2 sample): single temperature
message (paramId=130), 4x2 grid, 179 bytes. Used by GRIB scan unit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rib deps

Extracts scan/grib.py and scan/echam.py from source branch and rewires
the `from esm_catalog.scan.upath import parse_uri` calls in both files
to `from esm_catalog.uri import parse_uri` (the correct location in the
scan-layer stack). Adds cfgrib + eccodes to setup.py extras_require and
the CI install line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- test_grib_scan.py: asserts format, all output keys, variable name,
  CF parameter mapping, datetime extraction, and detect dispatch for
  the committed tiny.grib2 fixture.
- test_echam_scan.py: pure helper tests (no real ECHAM GRIB needed):
  _parse_codes_file, _extract_stream_type, _indicator_to_cf,
  is_echam_file (both codes-companion and filename-pattern detection).
All 41 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_to_cf + fixture README

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…_catalog/

Same convention fix as PR-0 — git's rename-detection didn't auto-relocate
these (likely due to the binary fixture file), so doing it manually.
@siligam
siligam force-pushed the esm-catalog/pr-a1b1-scan-netcdf branch from bdc93bd to 0b538f0 Compare June 17, 2026 16:34
@siligam
siligam force-pushed the esm-catalog/pr-a1b2-grib-echam branch from 9498a0f to 12ad6e2 Compare June 17, 2026 16:34
@siligam

siligam commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the corrected PR-0 base (#1483) — test relocation to tests/test_esm_catalog/, restored dedicated CI workflow at the new path, and a couple of CI fixes (doctest-collection exclusion, eval_type_backport for pydantic on Python 3.9). No change to this PR's own diff/scope. CI is green.

@siligam
siligam force-pushed the esm-catalog/pr-a1b1-scan-netcdf branch from 0b538f0 to 9be7194 Compare June 24, 2026 13:10
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.

1 participant