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

samplegrid: added support for GRID_LCC.

parent 1ace4005
......@@ -30,7 +30,6 @@
#include "util.h"
void cdo_print_grid(int gridID, int opt);
void cdo_print_zaxis(int zaxisID);
void cdo_print_attributes(FILE *fp, int cdiID, int varID, int nblanks)
......
......@@ -118,10 +118,10 @@ void *SampleGrid(void *argument)
{
int gridSrcID = vlistGrid(vlistID1, index);
int gridIDsampled = -1;
int gridtype = gridInqType(gridSrcID);
int gridtype = gridInqType(gridSrcID);
if ( ! (gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT || gridtype == GRID_PROJECTION ||
gridtype == GRID_CURVILINEAR || gridtype == GRID_GENERIC) )
gridtype == GRID_CURVILINEAR || gridtype == GRID_GENERIC || gridtype == GRID_LCC) )
cdoAbort("Unsupported gridtype: %s", gridNamePtr(gridtype));
if ( operatorID == SAMPLEGRID )
......@@ -143,8 +143,8 @@ void *SampleGrid(void *argument)
sbox[index].gridSrcID = gridSrcID;
sbox[index].gridIDsampled = gridIDsampled;
// TODO if ( cdoDebugExt>=10 ) gridPrint(gridSrcID, 1,0);
// if ( cdoDebugExt>=10 ) gridPrint(gridIDsampled, 1,0);
// if ( cdoDebugExt>=10 ) cdo_print_grid(gridSrcID, 1);
// if ( cdoDebugExt>=10 ) cdo_print_grid(gridIDsampled, 1);
vlistChangeGridIndex(vlistID2, index, gridIDsampled);
for ( varID = 0; varID < nvars; varID++ )
......@@ -202,7 +202,6 @@ void *SampleGrid(void *argument)
if (operatorID == SAMPLEGRID)
{
//if ( cdoDebugExt ) cdoPrint("Calling sampleData gridSrcID: %d; gridIDsampled: %d",gridSrcID, gridIDsampled);
sampleData(array1, gridSrcID, array2, gridIDsampled, resampleFactor);
}
else if (operatorID == SUBGRID)
......
......@@ -129,6 +129,8 @@ int W3FB12(double xi, double xj, double alat1, double elon1, double dx,
double elonv, double alatan, double *alat, double *elon);
*/
void cdo_print_grid(int gridID, int opt);
// Define a sampled grid of another grid
int cdo_define_sample_grid(int gridID, int sampleFactor);
......
......@@ -52,12 +52,12 @@ int cdo_define_sample_grid(int gridSrcID, int sampleFactor)
projection = northpole
*/
if ( cdoDebugExt )
cdoPrint("cdo_define_sample_grid(gridSrcID=%d, sampleFactor=%d) ...\n",gridSrcID, sampleFactor);
cdoPrint("cdo_define_sample_grid(gridSrcID=%d, sampleFactor=%d) ...", gridSrcID, sampleFactor);
int gridtype = gridInqType(gridSrcID);
if ( ! (gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT || gridtype == GRID_PROJECTION ||
gridtype == GRID_CURVILINEAR || gridtype == GRID_GENERIC) )
gridtype == GRID_CURVILINEAR || gridtype == GRID_GENERIC || gridtype == GRID_LCC) )
cdoAbort("Unsupported gridtype: %s", gridNamePtr(gridtype));
int gridXsize = gridInqXsize(gridSrcID);
......@@ -67,7 +67,7 @@ int cdo_define_sample_grid(int gridSrcID, int sampleFactor)
cdoAbort("cdo_define_sample_grid() Unsupported sampleFactor (%d)! Note that: gridXsize = %d, gridYsize = %d",
sampleFactor, gridXsize, gridYsize);
// TODO if ( cdoDebugExt>20 ) gridPrint(gridSrcID,1,0);
if ( cdoDebugExt>20 ) cdo_print_grid(gridSrcID, 1);
int xsize = (gridXsize + (sampleFactor-1)) / sampleFactor; // HARM36_L25: (789 + 2-1) / 2 = 395
int ysize = (gridYsize + (sampleFactor-1)) / sampleFactor;
......@@ -85,17 +85,26 @@ int cdo_define_sample_grid(int gridSrcID, int sampleFactor)
gridDefXsize(gridID_sampled, xsize);
gridDefYsize(gridID_sampled, ysize);
// for the case of Lambert projection ...
// TODO
/*
grid_sampled->lcc_xinc = grid_src->lcc_xinc * sampleFactor;
grid_sampled->lcc_yinc = grid_src->lcc_yinc * sampleFactor;
gridDefNP(gridID_sampled, gridInqNP(gridSrcID));
gridDefPrec(gridID_sampled, gridInqPrec(gridSrcID));
grid_sampled->xinc = grid_src->xinc * sampleFactor;
grid_sampled->yinc = grid_src->yinc * sampleFactor;
*/
grid_copy_attributes(gridSrcID, gridID_sampled);
if ( gridtype == GRID_PROJECTION ) grid_copy_mapping(gridSrcID, gridID_sampled);
if ( gridInqXvals(gridSrcID, NULL) && gridInqYvals(gridSrcID, NULL) )
if ( gridtype == GRID_LCC )
{
double originLon, originLat, lonParY, lat1, lat2, xinc, yinc;
int projflag, scanflag;
gridInqParamLCC(gridSrcID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xinc, &yinc, &projflag, &scanflag);
xinc *= sampleFactor;
yinc *= sampleFactor;
gridDefParamLCC(gridID_sampled, originLon, originLat, lonParY, lat1, lat2, xinc, yinc, projflag, scanflag);
}
else if ( gridInqXvals(gridSrcID, NULL) && gridInqYvals(gridSrcID, NULL) )
{
if ( gridtype == GRID_CURVILINEAR )
{
......@@ -131,17 +140,10 @@ int cdo_define_sample_grid(int gridSrcID, int sampleFactor)
}
}
// TODO
/*
if ( grid_sampled->type == GRID_LCC )
gridDefLCC( gridID_sampled, grid_sampled->lcc_originLon, grid_sampled->lcc_originLat, grid_sampled->lcc_lonParY,
grid_sampled->lcc_lat1, grid_sampled->lcc_lat2, grid_sampled->lcc_xinc, grid_sampled->lcc_yinc,
grid_sampled->lcc_projflag, grid_sampled->lcc_scanflag);
*/
if ( cdoDebugExt>20 )
{
printf("cdo SampleGrid: define_sample_grid(): \n");
// TODO gridPrint(gridID_sampled, 1,0);
cdoPrint("cdo SampleGrid: define_sample_grid(): ");
cdo_print_grid(gridID_sampled, 1);
}
return gridID_sampled;
......
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