Commit b0b65daf authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

fix problem with grib grid increment

parent 16295b34
2012-10-?? Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
2012-10-30 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Version 1.5.8 released
* using CGRIBEX library version 1.5.5
2012-10-29 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* stream_cgribex.c: do not check fraction of xinc/yinc" stream_cgribex.c
* gridGenXvals/gridGenYvals: recheck xinc/yinc if (xfirst+(size-1)*inc) > last
2012-10-26 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* stream_gribapi.c::gribapiScanTimestep: changed GRIBAPI_MISSVAL to cdiDefaultMissval
......
......@@ -213,9 +213,14 @@ void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *x
{
if ( xsize > 1 )
{
if ( (fabs(xinc) > 0) && (xlast > xfirst) && (fabs(xinc*1000 - NINT(xinc*1000)) <= FLT_EPSILON) )
if ( (fabs(xinc) > 0) )
{
if ( (xfirst + (xsize-1)*xinc) > xlast ) xinc = (xlast-xfirst)/(xsize-1);
if ( (xlast > xfirst) && (fabs(xinc*1000 - NINT(xinc*1000)) <= FLT_EPSILON) )
{
if ( IS_EQUAL(xfirst, 0) && (fabs(xlast*1000 - NINT(xlast*1000)) <= FLT_EPSILON) )
if ( xlast > 354. && xlast < 360. ) xlast = 360. - 360./(2*xsize);
if ( (xfirst + (xsize-1)*xinc) > xlast ) xinc = (xlast-xfirst)/(xsize-1);
}
}
else
{
......@@ -319,9 +324,12 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
/* else if ( gridtype == GRID_LONLAT || gridtype == GRID_GENERIC ) */
else if ( ysize > 1 )
{
if ( (fabs(yinc) > 0) && (fabs(yinc*1000 - NINT(yinc*1000)) <= FLT_EPSILON) )
if ( (fabs(yinc) > 0) )
{
if ( (yfirst + (ysize-1)*yinc) > ylast ) yinc = (ylast-yfirst)/(ysize-1);
if ( fabs(yinc*1000 - NINT(yinc*1000)) <= FLT_EPSILON )
{
if ( (yfirst + (ysize-1)*yinc) > ylast ) yinc = (ylast-yfirst)/(ysize-1);
}
}
else
{
......
......@@ -193,7 +193,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
grid->xinc = (ISEC2_LastLon - ISEC2_FirstLon) * 0.001 / (grid->xsize - 1);
/* correct xinc if necessary */
if ( ISEC2_FirstLon == 0 && ISEC2_LastLon > 354000 )
if ( ISEC2_FirstLon == 0 && ISEC2_LastLon > 354000 && ISEC2_LastLon < 360000 )
{
double xinc = 360. / grid->xsize;
......@@ -220,6 +220,18 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, int *isec4, grid_t *grid, i
grid->yinc = ISEC2_LatIncr * 0.001;
else
grid->yinc = (ISEC2_LastLat - ISEC2_FirstLat) * 0.001 / (grid->ysize - 1);
/* correct yinc if necessary */
if ( gridtype == GRID_LONLAT && abs(ISEC2_FirstLat) == abs(ISEC2_LastLat) && abs(ISEC2_LastLat) > 85000 )
{
double yinc = 180. / grid->ysize;
if ( fabs(grid->yinc-yinc) > 0.0 )
{
grid->yinc = yinc;
if ( CDI_Debug ) Message("set yinc to %g", grid->yinc);
}
}
}
grid->yfirst = ISEC2_FirstLat * 0.001;
grid->ylast = ISEC2_LastLat * 0.001;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment