[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20021108: GRIB decoding



Scott and Steve,

There is a Southern Hemeisphere polar stereographic
grid in the NOAAPORT data stream, header:
OESA88 KWBM

(I've placed a sample in the ~upc directory on hp1
as OESA88_KWBM.grib). Parameter #91, AWIPS grid 220.
This is ICE concentration from the SSMI sensor.

When using the GDS block, the upper right corner point calculated in
gbpolr.c does not match the bounds provided in WMO388 and grdnav.tbl.
The grid is supposed to cover Antarctica. Nagrib (using cpyfil=gds)
as well as McIDAS both have trouble displaying the grid.

After digging around in the gbpolr.c code, and looking at the
bit fields for both the Hemisphere and the i and j
scanning direction, I was able to get the alternate corner
point by switching the i and j scanning direction sense
if the grid is in the southern hemispehere. EG, adding the
hemflag multiplier as shown in the gbpolr.c snippet below.

However, this seems to me to not match the GRIB specification of
the table 8 scanning direction flags. The gbpolr.c code I believe
was as it should have been.

I was wondering if you have any contacts regarding the
grib data for AWIPS that we could check this with (its possible that
they are just using the wrong bit values for the byte 28 scanning
mode value...should be 128 instead of 64), or if you had a different
interpretation of the I & J scanning direction flags for gbpolr.c.

Thanks for any input or information you can provide.

Steve
        /*
         * Compute the linear coordinates of the first point.
         */
        if ( flag2 == 0 ) {
                /*
                 * Northern Hemisphere
                 */
                X1 =  RADIUS * tan ( PI4TH - lat1/2 ) * sin ( lon1-loncnt );
                Y1 = -RADIUS * tan ( PI4TH - lat1/2 ) * cos ( lon1-loncnt );
                hemflag = 1;
        }
        else {
                /*
                 * Southern Hemisphere
                 */
                X1 = RADIUS * tan ( PI4TH + lat1/2 ) * sin ( lon1-loncnt );
                Y1 = RADIUS * tan ( PI4TH + lat1/2 ) * cos ( lon1-loncnt );
                hemflag = -1;
        }

        /*
         * Compute the grid spacing
         */
        TDx = Dx / ( 1 + sin ( PI3RD ) );
        TDy = Dy / ( 1 + sin ( PI3RD ) );

        /*
         * Compute the linear coordinates of the second point.
         * Check the scanning mode to determine +/- grid spacing.
         */
        if ( ( mode >> 7 ) == 1 )
            X2 = X1 + ( Nx - 1 ) * ( -TDx ) * hemflag;
        else
            X2 = X1 + ( Nx - 1 ) * TDx * hemflag;

        if ( ( ( mode >> 6 ) & 1 ) == 1 )
            Y2 = Y1 + ( Ny - 1 ) * TDy * hemflag;
        else
            Y2 = Y1 + ( Ny - 1 ) * ( -TDy ) * hemflag;