# @gaia/grib-codec

Sovereign **GRIB2 → Zarr** codec — the Rust component of the Phase 175 tech
split ("Rust for Zarr/GRIB conversion and operational ensemble workers"). No
third-party GRIB or Zarr library is used.

- **`grib2`** — WMO FM-92 GRIB2 message parser for regular lat/lon fields
  (Section 3 template 3.0), grid-point **simple packing** decode (Section 5
  template 5.0) using the `Y = (R + X·2^E)/10^D` reduction formula with
  sign-magnitude scale factors, bitmap masking (Section 6), plus a matching
  encoder for round-trip testing. Octet offsets match the real WMO templates, so
  genuine ECMWF/NOAA GRIB2 fields decode.
- **`zarr`** — spec-compliant **Zarr v2** array writer: `.zarray` metadata and
  C-order chunk files with the `compressor: null` (raw little-endian) codec,
  readable by `zarr-python`/`xarray`.
- **`convert`** — GRIB2 → Zarr driver with grid-aligned chunking (whole periodic
  longitude rows, latitude split on a divisor of the row count).

```bash
cargo test  --manifest-path libs/gaia/grib-codec/Cargo.toml
cargo clippy --manifest-path libs/gaia/grib-codec/Cargo.toml --all-targets -- -D warnings
```
