Re: [decoders] Java GRIB 1 Decoder Problems with Flag Variables

NOTE: The decoders mailing list is no longer active. The list archives are made available for historical reasons.

On Thu, 7 May 2009, Macaulay, Michael G wrote:


Hello,

 

Iʼm using the latest java Decoders package and am running into an error trying
to decode some GRIB (v1) files.  The error occurs when I try to grab data that
has a format of simple flags like (0 or 1) or (0,1,2,or 3).   What seems to be
happening is that the code mistakenly thinks the offset passed in is the Grid
Description Section (GDS) even though the data offset is what is being passed
in. 

 

Normally this is handled ok by the code but when the length of the Binary Data
Section(BDS) is small, it mistakenly thinks its in a GDS and subsequently the
file pointer gets messed up.  In our case, we have a flag parameter that
happens to have a very small BDS (its an icing flag and I there was no icing in
our area) and hence the length octet is small (12) and therefore less than 50
which fools the code into thinking its in a GDS.   This less than 50 check
happens around line 129 of the Grib1Data class. 

 

My question to the mailing list is whether this is a bug or is there a way Iʼm
misunderstanding the API?  

Mike,

The API at some point should probably be change to be similar to the Grib 2 API where the GDS and PDS offsets are given as the starting points to reading the data. The problem is that there are many folks with the current Grib 1 indexes and they would all have to be rebuilt if the API was changed.

 I can currently work around this by deliberately
bypassing the Grib1Data class.  To do so, you just need to do the following:


Your following description describs how the Grib 1 API would work if the GDS and PDS offsets were given. Hindsight is always easier to see and it was implemented in the Grib2 API.


1)       Set the raf (file pointer) to the data offset of your GDS

2)      If the Product Data Section (PDS) says that the bms exists, then build
a Grib1BitMapSection from the raf.

3)      Build a new Grib1BinaryDataSection object from the raf, the decimal
scale of the PDS and the above mentioned bms

4)      Then call getValues on that object. 

 

Does anyone see a problem with my workaround? 

No, I think it's the correct solution.



If it is a bug, it might be easily taken care of by having another Boolean
variable passed in that tells the code whether itʼs a data offset or a gds
offset.

I'll take another look at the code and try to improve it without breaking the API

RObb...




 

Any help or comments would be greatly appreciated.  Thanks,


Sincerely,

 

Mike Macaulay

Sr. Software Engineer

Lockheed Martin




===============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
rkambic@xxxxxxxxxxxxxxxx                   WWW: http://www.unidata.ucar.edu/
===============================================================================
  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the decoders archives: