-
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
I using GFS's idx file for download some messages from GFS products
e.g.
curl --range 421881679-422391234 https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20250716/00/atmos/gfs.t00z.pgrb2.0p25.f120 > T2M.grib2
curl --range 468835884-469759757 https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.20250716/00/atmos/gfs.t00z.pgrb2.0p25.f120 > DLWRF.grib2
Several messages cannot parsed by gribberish, e.g. DLWRF.grib2
But gribberish.parse_grib_array return the correct values (I compare it with pygrib). But I cannot get the shape of array - metadata parser raise the error
thread '<unnamed>' panicked at python/src/message.rs:192:54:
called `Result::unwrap()` on an `Err` value: MessageError("This Product and Parameter is currently not supported: (5, 192)")
Ok, gribberish cannot undertand the Discipline - Product - Parameter triplet.
Can gribberish return the correct shape?
from traceback import format_exc
for file in ['T2M.grib2', 'DLWRF.grib2', ]:
print(file)
with open(file, "rb") as f:
raw = f.read()
mapping = gribberish.parse_grib_mapping(raw)
print(mapping)
if len(mapping):
for key, mapped in mapping.items():
values = gribberish.parse_grib_array(raw, mapped[1]).reshape(mapped[2].grid_shape)
else:
values = gribberish.parse_grib_array(raw, 0)
# shape = ???
try:
msg = gribberish.parse_grib_message(raw,0)
values = msg.data().reshape(msg.metadata.grid_shape)
except:
print(format_exc())
Metadata
Metadata
Assignees
Labels
No labels