noritada / grib-rs

GRIB format parser for Rust
Apache License 2.0
57 stars 9 forks source link

Assertion fails when attempting to read GRIB with data format 5.3/7.3 #29

Closed LafeWessel closed 1 year ago

LafeWessel commented 1 year ago

Simple Description on the Bug

An assertion fails when calling the .dispatch() function on a Grib2SubmessageDecoder that is attempting to read a GRIB2 message of the 5.3/7.3 format. It fails with the error

... 
panicked at 'assertion failed: `(left == right)`
    left: `[-45, 45]`,
    right: [6942, 6942]`', .../src/decoders/complex.rs:94:5
...

Steps to Reproduce

  1. Download data from the GFS forecast site (e.g. https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gdas.20230111/12/atmos/gdas.t12z.pgrb2.0p25.f000, Note that this exact URL will become unavailable as the forecast data becomes historical data and will have to be modified accordingly.). I am using the global 0.25 degree forecast data.
  2. Attempt to read and decode the values in the submessages.
    // open file
    let f = std::fs::File::open("test_grib_file").unwrap();
    let rd = std::io::BufReader::new(f);
    let gr = grib::from_reader(rd).unwrap();
    // set up decoder
    let (_, first_submessage) = gr.iter().next().unwrap();
    let dc = Grib2SubmessageDecoder::from(first_submessage).unwrap();
    let dv = dc.dispatch().unwrap(); // SHOULD PANIC HERE

Expected Behavior

Read the grid values from the file.

Actual Behavior

Assertion panic.

Additional Context

No response

noritada commented 1 year ago

@LafeWessel Thank you very much for reporting with detail descriptions and data!

I have briefly looked into the issue and have identified the problem in question. I believe it is due to the fact that this library does not yet support enough parameter value patterns. I will provide support based on the data you have provided and will update the crate in the near future.

LafeWessel commented 1 year ago

Thanks! I'd love to help and learn more about the GRIB format, so if there's any resources you could point me to, I'd really appreciate it!