thredds icon indicating copy to clipboard operation
thredds copied to clipboard

GRIB1 data length overflow

Open JohnLCaron opened this issue 10 years ago • 11 comments

When GRIB1 data length > 2^23-1, apparently this is the way it is encoded:

sizeSection4 = (read the 3 bytes of section 4) If (sizeSection4 < 120) {
// computed using total length – length of all other sections sizeTotal = (sizeTotal – 7FFFFF ) * 120 – sizeSection4 + 4
sizeSection4 = sizeTotal – 8 –sizeSection1 – sizeSection2 – sizeSection3 – 4;
}

May be ECMWF specific, not sure (sent note to ask).

JohnLCaron avatar Feb 24 '16 15:02 JohnLCaron

sample file:

http://jmp.sh/qGRzDNB

reported by

[email protected]

JohnLCaron avatar Feb 24 '16 15:02 JohnLCaron

ECMWF redefines the GRIB format without (AFAIK) documenting it. Now we all run around and adjust. Can we lodge a protest with the United Nations?

OTOH, maybe they did get official permission, and we dont know it. OTOH, why reward bad behavior? OTOH, this is just the way it is in GRIBlandia, so stop your whining, its not a bad solution to data size too big. OTOH, it messes with my pretty code. OTOH, grow up and get over it.

JohnLCaron avatar Mar 13 '16 23:03 JohnLCaron

OTOH, it's non-standard GRIB, so the best course of action is to burn it!

IT"S GRIB - BURN IT

But more seriously, it's non-standard GRIB. GRIB is a pain as it is, no need to further complicate it with non-standard stuff. I'd rather try to get users to put pressure on the organization to get them to do the right thing. That said, it's ECMWF, so I have zero idea how they respond to things like this.

lesserwhirls avatar Mar 13 '16 23:03 lesserwhirls

Ok, im going to transfer ownership to you. if you do decide to do it, note that Grib1RecordScanner has to get more complex because can no longer count on the message length being correct.

JohnLCaron avatar Mar 15 '16 01:03 JohnLCaron

Do you have any updates on the status of this issue? We have users that have been requesting access to this dataset through TDS/OPeNDAP. Thx.

DCSCHUS avatar Apr 05 '17 21:04 DCSCHUS

Greetings @DCSCHUS - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).

lesserwhirls avatar May 26 '17 16:05 lesserwhirls

Hi Sean,

Example files for ds113.1 can be downloaded from the following, after you agree to the terms of usage in your RDA profile: https://rda.ucar.edu/datasets/ds113.1/#!description

If you have detailed questions regarding the ECMWF GRIB1 "length of data section" hack, Dave Stepaniak, cc'd on this email might be able to help.

Finally, if it would be of help, we could add a login for you on the VM that John Caron previously used for testing. This has direct access to all DSS/RDA data on disk, and has his current version of the RDA#THREDDS version 5.0 data server installed.

Thanks in advance for your help, Doug

On Fri, May 26, 2017 at 10:00 AM, Sean Arms [email protected] wrote:

Greetings @DCSCHUS https://github.com/dcschus - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304320698, or mute the thread https://github.com/notifications/unsubscribe-auth/AGL5avVRaC_9fVnwBJrCHaJk53-uXlzBks5r9vcMgaJpZM4Hhz6A .

-- Doug Schuster [email protected] 303-497-1216 NCAR/CISL Research Data Archive http://rda.ucar.edu

DCSCHUS avatar May 26 '17 19:05 DCSCHUS

Great - thanks Doug! I just grabbed a file and will try to take a look here soon. A login to the VM might be extreamly helpful once I have netCDF-Java able to read the files locally.

Cheers!

On Fri, May 26, 2017 at 1:06 PM, Doug Schuster [email protected] wrote:

Hi Sean,

Example files for ds113.1 can be downloaded from the following, after you agree to the terms of usage in your RDA profile: https://rda.ucar.edu/datasets/ds113.1/#!description

If you have detailed questions regarding the ECMWF GRIB1 "length of data section" hack, Dave Stepaniak, cc'd on this email might be able to help.

Finally, if it would be of help, we could add a login for you on the VM that John Caron previously used for testing. This has direct access to all DSS/RDA data on disk, and has his current version of the RDA#THREDDS version 5.0 data server installed.

Thanks in advance for your help, Doug

On Fri, May 26, 2017 at 10:00 AM, Sean Arms [email protected] wrote:

Greetings @DCSCHUS https://github.com/dcschus - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304320698, or mute the thread <https://github.com/notifications/unsubscribe-auth/AGL5avVRaC_ 9fVnwBJrCHaJk53-uXlzBks5r9vcMgaJpZM4Hhz6A> .

-- Doug Schuster [email protected] 303-497-1216 <(303)%20497-1216> NCAR/CISL Research Data Archive http://rda.ucar.edu

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304364386, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEGGFyghjFkIkRXWKWCIF-gUYMbRomcks5r9yLKgaJpZM4Hhz6A .

lesserwhirls avatar Jun 07 '17 16:06 lesserwhirls

Sounds good. Thanks Sean. Let me know when you get to the point where a VM login is needed.

Doug

On Wed, Jun 7, 2017 at 10:21 AM, Sean Arms [email protected] wrote:

Great - thanks Doug! I just grabbed a file and will try to take a look here soon. A login to the VM might be extreamly helpful once I have netCDF-Java able to read the files locally.

Cheers!

On Fri, May 26, 2017 at 1:06 PM, Doug Schuster [email protected] wrote:

Hi Sean,

Example files for ds113.1 can be downloaded from the following, after you agree to the terms of usage in your RDA profile: https://rda.ucar.edu/datasets/ds113.1/#!description

If you have detailed questions regarding the ECMWF GRIB1 "length of data section" hack, Dave Stepaniak, cc'd on this email might be able to help.

Finally, if it would be of help, we could add a login for you on the VM that John Caron previously used for testing. This has direct access to all DSS/RDA data on disk, and has his current version of the RDA#THREDDS version 5.0 data server installed.

Thanks in advance for your help, Doug

On Fri, May 26, 2017 at 10:00 AM, Sean Arms [email protected] wrote:

Greetings @DCSCHUS https://github.com/dcschus - do you have an example file I could play with (I may have asked before, but I've misplaced the file if I have it).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://github.com/Unidata/thredds/issues/445#issuecomment-304320698 , or mute the thread <https://github.com/notifications/unsubscribe-auth/AGL5avVRaC_ 9fVnwBJrCHaJk53-uXlzBks5r9vcMgaJpZM4Hhz6A> .

-- Doug Schuster [email protected] 303-497-1216 <(303)%20497-1216> <(303)%20497-1216> NCAR/CISL Research Data Archive http://rda.ucar.edu

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-304364386, or mute the thread <https://github.com/notifications/unsubscribe- auth/AAEGGFyghjFkIkRXWKWCIF-gUYMbRomcks5r9yLKgaJpZM4Hhz6A>

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Unidata/thredds/issues/445#issuecomment-306847698, or mute the thread https://github.com/notifications/unsubscribe-auth/AGL5ai7rj5Ee8hLESxZ06ROZYh67yH--ks5sBs4YgaJpZM4Hhz6A .

-- Doug Schuster [email protected] 303-497-1216 NCAR/CISL Research Data Archive http://rda.ucar.edu

DCSCHUS avatar Jun 07 '17 19:06 DCSCHUS

Hi, we have emailed with Sean about netCdf java support of ECMWF grib1 files at 27/12/2017.

These files can be read with grib-api, an ECMWF grib library which can be found here

I provide here a sample file and its grib-api dump. Sample file grib-api dump

Basically, what is wrong with these files is the "totalLength" section at bytes 5-7 of each message. Netcdf Java tries to validate these files by looking at "totalLength" area and checks whether the end of section 5 message is "7777". Due to wrong length value, it gives "not a valid cdm file" exception.

In my opinion, these files have a fixed length sections for each message. So, grib-api can read them without referring to "totalLength" section. But this information needs to be approved.

I need to be able to open these files with netcdf java. Let me know if I can contribute the open source development process.

Thank you.

sefadolunay avatar Jan 11 '18 07:01 sefadolunay

@sefadolunay, you can use that files setting 2 properties at Grib1RecordScanner class:

  ucar.nc2.grib.grib1.Grib1RecordScanner.setAllowBadDsLength(true);
  ucar.nc2.grib.grib1.Grib1RecordScanner.setAllowBadIsLength(true);
  NetcdfFile nc = NetcdfFile.open(filename);
  System.out.println(nc);

Regards

cofinoa avatar Jan 11 '18 20:01 cofinoa