Skip to content

Cannot parse the shape of several GFS message's #76

@byphilipp

Description

@byphilipp

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions