Commit Graph

2 Commits

Author SHA1 Message Date
Schuwi
a9eed7f378 Fix GRIB2 scale factor decoding (sign-magnitude, not two's complement)
GRIB2 encodes binary (E) and decimal (D) scale factors in sign-and-magnitude
format (MSB = sign bit, lower 15 bits = magnitude), not two's complement.
The previous read_i16 call misinterpreted 0x8009 as -32759 instead of -9,
causing 2^E to underflow to 0.0 in f32 and zeroing all decoded values.

Fix: replace read_i16 with read_grib_scale for E and D in
decode_simple_packing. Add regression tests covering sign-magnitude decoding
and a realistic DWD CLCT packing scenario.
2026-03-06 21:40:39 +01:00
Schuwi
6c9a20bf59 Initial commit 2026-03-03 23:26:05 +01:00