Commit 9b97c4ad authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Merstat: added support for generic grids

parent b0c5b850
2010-01-20 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
* Zonstat: added support for generic grids
* Merstat: added support for generic grids
2010-01-14 Frank Kaspar <Frank.Kaspar@dwd.de> 2010-01-14 Frank Kaspar <Frank.Kaspar@dwd.de>
* import_cmsaf: added more corrections for wrong projection parameter * import_cmsaf: added more corrections for wrong projection parameter
......
...@@ -44,7 +44,7 @@ void *Merstat(void *argument) ...@@ -44,7 +44,7 @@ void *Merstat(void *argument)
int operfunc; int operfunc;
int streamID1, streamID2; int streamID1, streamID2;
int vlistID1, vlistID2; int vlistID1, vlistID2;
int gridID1, gridID2, lastgrid = -1; int gridID1, gridID2 = -1, lastgrid = -1;
int wstatus = FALSE; int wstatus = FALSE;
int code = 0, oldcode = 0; int code = 0, oldcode = 0;
int nlonmax; int nlonmax;
...@@ -111,11 +111,18 @@ void *Merstat(void *argument) ...@@ -111,11 +111,18 @@ void *Merstat(void *argument)
index = 0; index = 0;
gridID1 = vlistGrid(vlistID1, index); gridID1 = vlistGrid(vlistID1, index);
if ( gridInqType(gridID1) != GRID_LONLAT &&
gridInqType(gridID1) != GRID_GAUSSIAN )
cdoAbort("Unsupported gridtype: %s", gridNamePtr(gridInqType(gridID1)));
gridID2 = gridToMeridional(gridID1); if ( gridInqType(gridID1) == GRID_LONLAT ||
gridInqType(gridID1) == GRID_GAUSSIAN ||
gridInqType(gridID1) == GRID_GENERIC )
{
gridID2 = gridToMeridional(gridID1);
}
else
{
cdoAbort("Unsupported gridtype: %s", gridNamePtr(gridInqType(gridID1)));
}
vlistChangeGridIndex(vlistID2, index, gridID2); vlistChangeGridIndex(vlistID2, index, gridID2);
streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype()); streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
......
...@@ -44,7 +44,7 @@ void *Zonstat(void *argument) ...@@ -44,7 +44,7 @@ void *Zonstat(void *argument)
int operfunc; int operfunc;
int streamID1, streamID2; int streamID1, streamID2;
int vlistID1, vlistID2; int vlistID1, vlistID2;
int gridID1, gridID2; int gridID1, gridID2 = -1;
int nlatmax; int nlatmax;
int index, ngrids; int index, ngrids;
int recID, nrecs; int recID, nrecs;
...@@ -105,12 +105,17 @@ void *Zonstat(void *argument) ...@@ -105,12 +105,17 @@ void *Zonstat(void *argument)
index = 0; index = 0;
gridID1 = vlistGrid(vlistID1, index); gridID1 = vlistGrid(vlistID1, index);
if ( gridInqType(gridID1) != GRID_LONLAT && if ( gridInqType(gridID1) == GRID_LONLAT ||
gridInqType(gridID1) != GRID_GAUSSIAN && gridInqType(gridID1) == GRID_GAUSSIAN ||
!(gridInqType(gridID1) == GRID_GENERIC && gridInqYsize(gridID1) > 1) ) gridInqType(gridID1) == GRID_GENERIC )
cdoAbort("Unsupported gridtype: %s", gridNamePtr(gridInqType(gridID1))); {
gridID2 = gridToZonal(gridID1);
}
else
{
cdoAbort("Unsupported gridtype: %s", gridNamePtr(gridInqType(gridID1)));
}
gridID2 = gridToZonal(gridID1);
for ( index = 0; index < ngrids; index++ ) for ( index = 0; index < ngrids; index++ )
vlistChangeGridIndex(vlistID2, index, gridID2); vlistChangeGridIndex(vlistID2, index, gridID2);
......
...@@ -68,13 +68,9 @@ int gridToZonal(int gridID1) ...@@ -68,13 +68,9 @@ int gridToZonal(int gridID1)
gridsize = gridInqYsize(gridID1); gridsize = gridInqYsize(gridID1);
gridID2 = gridCreate(gridtype, gridsize); gridID2 = gridCreate(gridtype, gridsize);
if ( gridtype != GRID_LONLAT && if ( gridtype == GRID_LONLAT ||
gridtype != GRID_GAUSSIAN && gridtype == GRID_GAUSSIAN ||
(gridtype == GRID_GENERIC && gridsize <= 1) ) gridtype == GRID_GENERIC )
{
Error(func, "Gridtype %s unsupported!", gridNamePtr(gridtype));
}
else
{ {
gridDefXsize(gridID2, 1); gridDefXsize(gridID2, 1);
gridDefYsize(gridID2, gridsize); gridDefYsize(gridID2, gridsize);
...@@ -91,6 +87,10 @@ int gridToZonal(int gridID1) ...@@ -91,6 +87,10 @@ int gridToZonal(int gridID1)
free(yvals); free(yvals);
} }
} }
else
{
Error(func, "Gridtype %s unsupported!", gridNamePtr(gridtype));
}
return (gridID2); return (gridID2);
} }
...@@ -108,29 +108,28 @@ int gridToMeridional(int gridID1) ...@@ -108,29 +108,28 @@ int gridToMeridional(int gridID1)
gridsize = gridInqXsize(gridID1); gridsize = gridInqXsize(gridID1);
gridID2 = gridCreate(gridtype, gridsize); gridID2 = gridCreate(gridtype, gridsize);
switch (gridtype) if ( gridtype == GRID_LONLAT ||
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_GENERIC )
{ {
case GRID_LONLAT: gridDefXsize(gridID2, gridsize);
case GRID_GAUSSIAN: gridDefYsize(gridID2, 1);
{
gridDefXsize(gridID2, gridsize);
gridDefYsize(gridID2, 1);
xvals = (double *) malloc(gridsize*sizeof(double)); if ( gridInqXvals(gridID1, NULL) )
{
xvals = (double *) malloc(gridsize*sizeof(double));
gridInqXvals(gridID1, xvals); gridInqXvals(gridID1, xvals);
gridDefXvals(gridID2, xvals); gridDefXvals(gridID2, xvals);
gridDefYvals(gridID2, &yval);
free(xvals); free(xvals);
}
break; gridDefYvals(gridID2, &yval);
} }
default: else
{ {
Error(func, "Gridtype %s unsupported!", gridNamePtr(gridtype)); Error(func, "Gridtype %s unsupported!", gridNamePtr(gridtype));
break;
}
} }
return (gridID2); return (gridID2);
...@@ -1319,18 +1318,18 @@ int gridWeights(int gridID, double *grid_wgts) ...@@ -1319,18 +1318,18 @@ int gridWeights(int gridID, double *grid_wgts)
} }
else else
{ {
if ( gridtype != GRID_LONLAT && if ( gridtype == GRID_LONLAT ||
gridtype != GRID_GAUSSIAN && gridtype == GRID_GAUSSIAN ||
gridtype != GRID_LCC && gridtype == GRID_LCC ||
gridtype != GRID_GME && gridtype == GRID_GME ||
gridtype != GRID_CURVILINEAR && gridtype == GRID_CURVILINEAR ||
gridtype != GRID_CELL ) gridtype == GRID_CELL )
{ {
a_status = 1; a_status = gridGenArea(gridID, grid_area);
} }
else else
{ {
a_status = gridGenArea(gridID, grid_area); a_status = 1;
} }
} }
......
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