Skip Menu |

This queue is for tickets about the Geo-ReadGRIB CPAN distribution.

Report information
The Basics
Id: 50457
Status: resolved
Priority: 0/
Queue: Geo-ReadGRIB

People
Owner: frank.l.cox [...] gmail.com
Requestors: frank.l.cox [...] gmail.com
Cc: ptomblin [...] gmail.com
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



RT-Send-CC: ptomblin [...] gmail.com
Paul Tomblin reports: I'm trying to read some files that come from http://www.weatheroffice.gc.ca/grib/High-resolution_GRIB_e.html, and ReadGRIB keeps telling me that the Lo1 and Lo2 are both +180. The provider insists that they've actually put them in as 0 and +360. Can you advise if there is a work-around or something I could do to read these files?
I opened one of the grib files with wgrib and dumped the GDS header. Byte 6 is 0 meaning it's a lat/long grid representation. Bytes 14-16 and 21-23 which are Lo1 and Lo2 are both 180000 millidegees or 180 degrees. The grib supplier says these values are 0 and 360. According to my understanding of the spec Geo::ReadGRIB is doing the right thing here. I'm open to enlightenment on this issue. I have recommended using the *ugly hack* or resetting these values and also LoInc (which is calculated from Lo1 and Lo2). I will close this but I hope this issue can be resolved with the grib supplier.
I'll be darned, this looks like a bug after all... In spite of what we've been told it seems these grib files are not long 0-360. This page: http://www.weatheroffice.gc.ca/grib/CMC_GRIB_Technical_Grid_Specifications_e.html#high_res_glb_30km Shows info about these files including the fact that that first grid point long is 180E, not 0. So they are saying that the first and last long in the file is 180 degrees. ASIDE: If there are 601 grid points (Ni) and a resolution of .6 degrees how can the first and last point be 180E? The math doesn't work for me... ============================================= Global GEM on full-resolution Lat-Lon grid High resolution global grid Grid specifications ni 601 nj 301 resolution 0.6° coordinate of first grid point 90° S 180° E =============================================
On Tue Oct 13 19:39:24 2009, FRANKCOX wrote: Show quoted text
> I'll be darned, this looks like a bug after all... > > In spite of what we've been told it seems these grib files are not > long > 0-360. > > This page: >
http://www.weatheroffice.gc.ca/grib/CMC_GRIB_Technical_Grid_Specifications_e.html#high_res_glb_30km Show quoted text
> > Shows info about these files including the fact that that first grid > point long is 180E, not 0. So they are saying that the first and last > long in the file is 180 degrees. > > ASIDE: If there are 601 grid points (Ni) and a resolution of .6 > degrees > how can the first and last point be 180E? The math doesn't work for > me...
Re: my aside, if there are Ni = 601 grid points on the rectangular grid there are Ni -1 or 600 spaces between them so Lo1 + ((Ni -1) * LoINC) = 180 + (600 * .6) = 540 = 180 + 360 or the same place on the globe, 180E. My problem was that I was visualizing this on a globe where there is only one 180 degree point. On this flat map (so to speak) there are two 180s (601 total grid points) but no space between them. Weirdly, these two 180 points each seem to have data for each of the 301 lat points. Presumably these are the same value but I haven't checked yet. Also, the poles lat -90 and 90 have 601 data items each even though they are points! Those must be the same too. Strange stuff! Show quoted text
> ============================================= > Global GEM on full-resolution Lat-Lon grid > > High resolution global grid > Grid specifications > ni 601 > nj 301 > resolution 0.6° > coordinate of first grid point 90° S 180° E > =============================================
This issue has been addressed in test version Geo-ReadGRIB-0.98_2.tar.gz which has been uploaded to CPAN. It should show up in http://cpan.perl.org/authors/id/F/FR/FRANKCOX/ soon. This ticket will remain open pending testing.
This issue has been dealt with, although not completely tested. This is a edge case where both values are the same. It was tricky to come up with a general solution that will work with this and any other pair I can think of. (And, I never before thought of a case where two of the same value means you went around the world once.) My solution is to shift Lo1 until it's zero and then use that and Ni, the total number of points and LaInc, the distance in degrees between points, to calculate the shifted Lo2. Then just do any calculations on the shifted grid with shifted values and then convert the answer back. I toyed with starting with Lo2 without shifting and then calculating back to Lo1 which in this case would then become -180 which helps a lot. However, the beauty of my solution is that there are no possibility of a zero complicating things somewhere in the middle.
closed for now...