Commit 55a27d6e authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

grb write: added support for projection CDI_PROJ_RLL.

parent ac4f804a
2016-08-01 Uwe Schulzweida
* grb write: added support for projection CDI_PROJ_RLL
* ieg read: added support for projection CDI_PROJ_RLL
2016-07-30 Uwe Schulzweida
......
......@@ -37,7 +37,11 @@ int cgribexGetGridType(int *isec2)
switch (ISEC2_GridType)
{
case GRIB1_GTYPE_LATLON: { if ( ISEC2_Reduced ) break; }
#ifdef TEST_PROJECTION
case GRIB1_GTYPE_LATLON_ROT: { gridtype = GRID_PROJECTION; break; }
#else
case GRIB1_GTYPE_LATLON_ROT: { gridtype = GRID_LONLAT; break; }
#endif
case GRIB1_GTYPE_LCC: { gridtype = GRID_LCC; break; }
case GRIB1_GTYPE_GAUSSIAN: { if ( ISEC2_Reduced )
gridtype = GRID_GAUSSIAN_REDUCED;
......@@ -145,6 +149,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
{
bool compyinc = true;
int gridtype = cgribexGetGridType(isec2);
int projtype = (gridtype == GRID_PROJECTION && cgribexGetIsRotated(isec2)) ? CDI_PROJ_RLL : CDI_UNDEFID;
if ( streamptr->unreduced && gridtype == GRID_GAUSSIAN_REDUCED && iret != -801 )
{
......@@ -159,10 +164,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid_init(grid);
cdiGridTypeInit(grid, gridtype, 0);
switch (gridtype)
{
case GRID_LONLAT:
case GRID_GAUSSIAN:
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || projtype == CDI_PROJ_RLL )
{
if ( ISEC4_NumValues != ISEC2_NumLon*ISEC2_NumLat )
Error("numberOfPoints (%d) and gridSize (%d) differ!", ISEC4_NumValues, ISEC2_NumLon*ISEC2_NumLat);
......@@ -197,7 +199,6 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
if ( ISEC2_FirstLon == 0 && ISEC2_LastLon > 354000 && ISEC2_LastLon < 360000 )
{
double xinc = 360. / grid->x.size;
if ( fabs(grid->x.inc-xinc) > 0.0 )
{
grid->x.inc = xinc;
......@@ -231,9 +232,8 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->y.last = ISEC2_LastLat * 0.001;
grid->y.flag = 2;
}
break;
}
case GRID_GAUSSIAN_REDUCED:
else if ( gridtype == GRID_GAUSSIAN_REDUCED )
{
grid->np = ISEC2_NumPar;
grid->size = ISEC4_NumValues;
......@@ -272,9 +272,8 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->y.last = ISEC2_LastLat * 0.001;
grid->y.flag = 2;
}
break;
}
case GRID_LCC:
else if ( gridtype == GRID_LCC )
{
if ( ISEC4_NumValues != ISEC2_NumLon*ISEC2_NumLat )
Error("numberOfPoints (%d) and gridSize (%d) differ!",
......@@ -296,10 +295,8 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->x.flag = 0;
grid->y.flag = 0;
break;
}
case GRID_SPECTRAL:
else if ( gridtype == GRID_SPECTRAL )
{
grid->size = ISEC4_NumValues;
grid->trunc = ISEC2_PentaJ;
......@@ -307,42 +304,37 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
grid->lcomplex = 1;
else
grid->lcomplex = 0;
break;
}
case GRID_GME:
else if ( gridtype == GRID_GME )
{
grid->size = ISEC4_NumValues;
grid->gme.nd = ISEC2_GME_ND;
grid->gme.ni = ISEC2_GME_NI;
grid->gme.ni2 = ISEC2_GME_NI2;
grid->gme.ni3 = ISEC2_GME_NI3;
break;
}
case GRID_GENERIC:
else if ( gridtype == GRID_GENERIC )
{
grid->size = ISEC4_NumValues;
grid->x.size = 0;
grid->y.size = 0;
break;
}
default:
else
{
Error("Unsupported grid type: %s", gridNamePtr(gridtype));
break;
}
}
grid->isRotated = FALSE;
if ( cgribexGetIsRotated(isec2) )
{
grid->isRotated = TRUE;
grid->rll.ypole = - ISEC2_LatSP*0.001;
grid->rll.xpole = ISEC2_LonSP*0.001 - 180;
grid->rll.ypole = - ISEC2_LatSP*0.001;
grid->rll.angle = - FSEC2_RotAngle;
}
grid->type = gridtype;
grid->projtype = projtype;
}
static
......@@ -387,6 +379,13 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
gridptr->rowlon = (int*) Malloc(nrowlon * sizeof(int));
memcpy(gridptr->rowlon, rowlon, nrowlon * sizeof(int));
}
else if ( gridptr->projtype == CDI_PROJ_RLL )
{
double xpole = ISEC2_LonSP*0.001 - 180;
double ypole = - ISEC2_LatSP*0.001;
double angle = - FSEC2_RotAngle;
gridDefProjParamRLL(gridID, xpole, ypole, angle);
}
}
else
Free(gridptr);
......
......@@ -681,7 +681,7 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
size_t vctsize = (size_t)IEG_G_NumVCP(gdb);
for ( size_t i = 0; i < vctsize/2; i++ ) tmpvct[i] = vct[i];
for (size_t i = 0; i < vctsize/2; i++ ) tmpvct[i+vctsize/2] = vct[i+50];
for ( size_t i = 0; i < vctsize/2; i++ ) tmpvct[i+vctsize/2] = vct[i+50];
varDefVCT(vctsize, tmpvct);
}
......
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