Commit 62568c0d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Refactor GRID_LCC to GRID_PROJECTION.

parent 670c2d4a
......@@ -3,6 +3,10 @@
* Using CDI library version 1.8.1
* Version 1.8.1 release
2017-04-09 Uwe Schulzweida
* Refactor GRID_LCC to GRID_PROJECTION
2017-04-07 Uwe Schulzweida
* setpartab: added support for values in single quotes [Bug #7662]
......
......@@ -407,38 +407,38 @@ void dumpmap()
static
void ctl_xydef(FILE *gdp, int gridID, bool *yrev)
{
int gridtype;
int i, j;
int xsize, ysize;
double xfirst, yfirst, xinc, yinc;
double *xvals, *yvals;
*yrev = false;
xsize = gridInqXsize(gridID);
ysize = gridInqYsize(gridID);
int xsize = gridInqXsize(gridID);
int ysize = gridInqYsize(gridID);
gridtype = gridInqType(gridID);
int gridtype = gridInqType(gridID);
int projtype = gridInqProjType(gridID);
/* XDEF */
if ( gridtype == GRID_LCC )
if ( gridtype == GRID_PROJECTION && projtype == CDI_PROJ_LCC )
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
double xmin = 1.e10, xmax = -1.e10, ymin = 1.e10, ymax = -1.e10;
double xrange, yrange;
int projflag, scanflag;
int nx, ny, ni;
double inc[] = { 1, 0.5, 0.2, 0.1, 0.05, 0.02, 0.01, 0.005, 0.002, 0.001 };
gridInqParamLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
double xinc = gridInqXinc(gridID);
double yinc = gridInqYinc(gridID);
double a, rf, xval_0, yval_0, lon_0, lat_1, lat_2;
gridInqParamLCC(gridID, &a, &rf, &xval_0, &yval_0, &lon_0, &lat_1, &lat_2);
fprintf(gdp, "PDEF %d %d LCCR %g %g 1 1 %g %g %g %g %g\n",
xsize, ysize, originLat, originLon, lat1, lat2, lonParY, xincm, yincm);
xsize, ysize, xval_0, yval_0, lat_1, lat_2, lon_0, xinc, yinc);
gridID = gridToCurvilinear(gridID, 0);
xvals = (double*) Malloc(xsize*ysize*sizeof(double));
yvals = (double*) Malloc(xsize*ysize*sizeof(double));
double *xvals = (double*) Malloc(xsize*ysize*sizeof(double));
double *yvals = (double*) Malloc(xsize*ysize*sizeof(double));
gridInqXvals(gridID, xvals);
gridInqYvals(gridID, yvals);
for ( i = 0; i < xsize*ysize; ++i )
......@@ -479,7 +479,7 @@ void ctl_xydef(FILE *gdp, int gridID, bool *yrev)
xinc = gridInqXinc(gridID);
if ( IS_EQUAL(xinc, 0) && gridInqXvals(gridID, NULL) )
{
xvals = (double*) Malloc(xsize*sizeof(double));
double *xvals = (double*) Malloc(xsize*sizeof(double));
gridInqXvals(gridID, xvals);
fprintf(gdp ,"XDEF %d LEVELS ", xsize);
j = 0;
......@@ -507,7 +507,7 @@ void ctl_xydef(FILE *gdp, int gridID, bool *yrev)
/* YDEF */
if ( gridtype != GRID_LCC )
if ( ! (gridtype == GRID_PROJECTION && projtype == CDI_PROJ_LCC) )
{
yfirst = gridInqYval(gridID, 0);
yinc = gridInqYinc(gridID);
......@@ -515,7 +515,7 @@ void ctl_xydef(FILE *gdp, int gridID, bool *yrev)
if ( IS_EQUAL(yinc, 0) && gridInqYvals(gridID, NULL) )
{
yvals = (double*) Malloc(ysize*sizeof(double));
double *yvals = (double*) Malloc(ysize*sizeof(double));
gridInqYvals(gridID, yvals);
fprintf(gdp ,"YDEF %d LEVELS ", ysize);
j = 0;
......@@ -1052,9 +1052,10 @@ void *Gradsdes(void *argument)
{
gridID = vlistGrid(vlistID, index);
gridtype = gridInqType(gridID);
int projtype = gridInqProjType(gridID);
if ( gridtype == GRID_LONLAT ||
gridtype == GRID_GAUSSIAN ||
gridtype == GRID_LCC ) break;
(gridtype == GRID_PROJECTION && projtype == CDI_PROJ_LCC) ) break;
}
if ( index == ngrids )
......
......@@ -763,7 +763,7 @@ int genindexgrid(int gridID1, int *lat1, int *lat2, int *lon11, int *lon12, int
genindexbox(0, gridID1, lat1, lat2, lon11, lon12, lon21, lon22);
int gridID2 = -1;
if ( gridInqType(gridID1) == GRID_LCC )
if ( gridInqType(gridID1) == GRID_PROJECTION && gridInqProjType(gridID1) == CDI_PROJ_LCC )
gridID2 = cdo_define_subgrid_grid(gridID1, *lon11, *lon12, *lat1, *lat2);
else
gridID2 = gengrid(gridID1, *lat1, *lat2, *lon11, *lon12, *lon21, *lon22);
......@@ -869,8 +869,9 @@ void *Selbox(void *argument)
gridID1 = vlistGrid(vlistID1, index);
gridtype = gridInqType(gridID1);
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_CURVILINEAR || gridtype == GRID_LCC ||
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_CURVILINEAR ||
(gridtype == GRID_PROJECTION && gridInqProjType(gridID1) == CDI_PROJ_RLL) ||
(gridtype == GRID_PROJECTION && gridInqProjType(gridID1) == CDI_PROJ_LCC) ||
(operatorID == SELINDEXBOX && gridtype == GRID_GENERIC &&
gridInqXsize(gridID1) > 0 && gridInqYsize(gridID1) > 0) ||
(operatorID == SELLONLATBOX && gridtype == GRID_UNSTRUCTURED) )
......
......@@ -554,22 +554,23 @@ int lcc_to_lonlat(int gridID, int nvals, double *xvals, double *yvals);
static
void lcc_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int projflag, scanflag;
proj_info_t proj;
gridInqParamLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm, &projflag, &scanflag);
double xinc = gridInqXinc(gridID);
double yinc = gridInqYinc(gridID);
double a, rf, xval_0, yval_0, lon_0, lat_1, lat_2;
gridInqParamLCC(gridID, &a, &rf, &xval_0, &yval_0, &lon_0, &lat_1, &lat_2);
/*
while ( originLon < 0 ) originLon += 360;
while ( lonParY < 0 ) lonParY += 360;
*/
if ( IS_NOT_EQUAL(xincm, yincm) )
cdoWarning("X and Y increment must be equal on Lambert Conformal grid (Xinc = %g, Yinc = %g)\n",
xincm, yincm);
if ( IS_NOT_EQUAL(xinc, yinc) )
cdoWarning("X and Y increment must be equal on Lambert Conformal grid (Xinc = %g, Yinc = %g)\n", xinc, yinc);
/*
if ( IS_NOT_EQUAL(lat1, lat2) )
cdoWarning("Lat1 and Lat2 must be equal on Lambert Conformal grid (Lat1 = %g, Lat2 = %g)\n",
lat1, lat2);
cdoWarning("Lat1 and Lat2 must be equal on Lambert Conformal grid (Lat1 = %g, Lat2 = %g)\n", lat1, lat2);
*/
/*
double x_0 = originLon, y_0 = originLat;
......@@ -579,7 +580,7 @@ void lcc_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
printf("out x_0 = %g y_0 = %g\n", x_0, y_0);
printf("out x_0 = %20.10f y_0 = %20.10f\n", x_0, y_0);
*/
map_set(PROJ_LC, originLat, originLon, xincm, lonParY, lat1, lat2, &proj);
map_set(PROJ_LC, yval_0, xval_0, xinc, lon_0, lat_1, lat_2, &proj);
double zlat, zlon;
for ( int i = 0; i < gridsize; i++ )
......@@ -786,18 +787,16 @@ bool grid_inq_param_lcc(int gridID, double *a, double *rf, double *lon_0, double
int lonlat_to_lcc(int gridID, int nvals, double *xvals, double *yvals)
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int projflag, scanflag;
double a, rf, xval_0, yval_0, lon_0, lat_1, lat_2;
gridInqParamLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm, &projflag, &scanflag);
gridInqParamLCC(gridID, &a, &rf, &xval_0, &yval_0, &lon_0, &lat_1, &lat_2);
#if defined(HAVE_LIBPROJ)
char *params[20];
double a = PARAM_MISSVAL, lon_0 = lonParY, lat_0 = lat1, lat_1 = lat1, lat_2 = lat2;
a = 6367470;
// bool status = grid_inq_param_lcc(gridID, &a, &lon_0, &lat_0, &lat_1, &lat_2, &x_0, &y_0);
// if ( status == false ) cdoAbort("mapping parameter missing!");
double lat_0 = lat_2;
int nbpar = 0;
params[nbpar++] = gen_param("proj=lcc");
if ( IS_NOT_EQUAL(a,PARAM_MISSVAL) && a > 0 ) params[nbpar++] = gen_param("a=%g", a);
......
......@@ -129,34 +129,44 @@ int cdo_define_sample_grid(int gridSrcID, int sampleFactor)
#
# gridID 2
#
gridtype = lcc
gridtype = projection
gridsize = 622521
xsize = 789
ysize = 789
originLon = -7.89
originLat = 42.935
lonParY = 0
lat1 = 52.5
lat2 = 52.5
xunits = "m"
yunits = "m"
xfirst = 0
xinc = 2500
yfirst = 0
yinc = 2500
projection = northpole
grid_mapping = Lambert_Conformal
grid_mapping_name = lambert_conformal_conic
standard_parallel = 52.5
longitude_of_central_meridian = 0.
latitude_of_projection_origin = 52.5
longitudeOfFirstGridPointInDegrees = -7.89
latitudeOfFirstGridPointInDegrees = 42.935
=> RESULT:
#
# gridID 2
#
gridtype = lcc
gridtype = projection
gridsize = 156025
xsize = 395
ysize = 395
originLon = -7.89
originLat = 42.935
lonParY = 0
lat1 = 52.5
lat2 = 52.5
xunits = "m"
yunits = "m"
xfirst = 0
xinc = 5000
yfirst = 0
yinc = 5000
projection = northpole
grid_mapping = Lambert_Conformal
grid_mapping_name = lambert_conformal_conic
standard_parallel = 52.5
longitude_of_central_meridian = 0.
latitude_of_projection_origin = 52.5
longitudeOfFirstGridPointInDegrees = -7.89
latitudeOfFirstGridPointInDegrees = 42.935
*/
if ( cdoDebugExt )
cdoPrint("%s(gridSrcID=%d, sampleFactor=%d) ...", __func__, gridSrcID, sampleFactor);
......@@ -191,19 +201,7 @@ int cdo_define_sample_grid(int gridSrcID, int sampleFactor)
if ( gridtype == GRID_PROJECTION ) grid_copy_mapping(gridSrcID, gridID_sampled);
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 ( gridInqXvals(gridSrcID, NULL) && gridInqYvals(gridSrcID, NULL) )
{
if ( gridtype == GRID_CURVILINEAR )
{
......@@ -269,34 +267,44 @@ int cdo_define_subgrid_grid(int gridSrcID, int subI0, int subI1, int subJ0, int
#
# gridID 2
#
gridtype = lcc
gridtype = projection
gridsize = 622521
xsize = 789
ysize = 789
originLon = -7.89
originLat = 42.935
lonParY = 0
lat1 = 52.5
lat2 = 52.5
xunits = "m"
yunits = "m"
xfirst = 0
xinc = 2500
yfirst = 0
yinc = 2500
projection = northpole
grid_mapping = Lambert_Conformal
grid_mapping_name = lambert_conformal_conic
standard_parallel = 52.5
longitude_of_central_meridian = 0.
latitude_of_projection_origin = 52.5
longitudeOfFirstGridPointInDegrees = -7.89
latitudeOfFirstGridPointInDegrees = 42.935
=> RESULT:
#
# gridID 2
#
gridtype = lcc
gridtype = projection
gridsize = 156025
xsize = 350
ysize = 350
originLon = ...
originLat = ...
lonParY = 0
lat1 = 52.5
lat2 = 52.5do SampleGrid: define_subgrid_grid
xunits = "m"
yunits = "m"
xfirst = 0
xinc = 2500
yfirst = 0
yinc = 2500
projection = northpole
grid_mapping = Lambert_Conformal
grid_mapping_name = lambert_conformal_conic
standard_parallel = 52.5
longitude_of_central_meridian = 0.
latitude_of_projection_origin = 52.5
longitudeOfFirstGridPointInDegrees = ...
latitudeOfFirstGridPointInDegrees = ...
*/
if ( cdoDebugExt )
cdoPrint("%s(gridSrcID=%d, (subI0,subI1,subJ0,subJ1) = (%d,%d,%d,%d) ...",
......@@ -307,20 +315,19 @@ int cdo_define_subgrid_grid(int gridSrcID, int subI0, int subI1, int subJ0, int
int maxIndexI = gridXsize-1;
int maxIndexJ = gridYsize-1;
if ( (subI0<0) || (subI0>maxIndexI) ||
if ( (subI0<0) || (subI0>maxIndexI) ||
(subI1<=subI0) || (subI1>maxIndexI) ||
(subJ0<0) || (subJ0>maxIndexJ) ||
(subJ0<0) || (subJ0>maxIndexJ) ||
(subJ1<=subJ0) || (subJ1>maxIndexJ) )
cdoAbort("%s() Incorrect subgrid specified! (subI0,subI1,subJ0,subJ1) =(%d,%d,%d,%d) Note that: gridXsize = %d, gridYsize = %d", __func__, subI0,subI1, subJ0, subJ1, gridXsize, gridYsize);
int gridtype = gridInqType(gridSrcID);
if ( gridtype != GRID_LCC )
if ( !(gridtype == GRID_PROJECTION && gridInqProjType(gridSrcID) == CDI_PROJ_LCC) )
cdoAbort("%s() Error; Only LCC grid is supported; use selindexbox!", __func__);
double originLon, originLat, lonParY, lat1, lat2, xinc, yinc;
int projflag, scanflag;
double a, rf, xval_0, yval_0, lon_0, lat_1, lat_2;
gridInqParamLCC(gridSrcID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xinc, &yinc, &projflag, &scanflag);
gridInqParamLCC(gridSrcID, &a, &rf, &xval_0, &yval_0, &lon_0, &lat_1, &lat_2);
if ( cdoDebugExt>20 ) cdo_print_grid(gridSrcID, 1);
......@@ -328,14 +335,13 @@ int cdo_define_subgrid_grid(int gridSrcID, int subI0, int subI1, int subJ0, int
{
cdoPrint("%s() Original LCC grid:", __func__);
cdoPrint("grid Xsize %d, grid Ysize %d", gridXsize, gridYsize);
cdoPrint("originLon %4.3f, originLat %4.3f", originLon, originLat);
cdoPrint("grid Xinc %4.3f, grid Yinc %4.3f", xinc, yinc);
cdoPrint("xval_0 %4.3f, yval_0 %4.3f", xval_0, yval_0);
}
int gridIDcurvl = gridToCurvilinear(gridSrcID, 1);
originLon = gridInqXval(gridIDcurvl, 0);
originLat = gridInqYval(gridIDcurvl, 0);
xval_0 = gridInqXval(gridIDcurvl, 0);
yval_0 = gridInqYval(gridIDcurvl, 0);
if ( cdoDebugExt )
{
......@@ -343,10 +349,9 @@ int cdo_define_subgrid_grid(int gridSrcID, int subI0, int subI1, int subJ0, int
cdoPrint("grid Xsize %d, grid Ysize %d", gridInqXsize(gridIDcurvl), gridInqYsize(gridIDcurvl));
cdoPrint("grid Xfirst %4.3f, grid Yfirst %4.3f", gridInqXval(gridIDcurvl, 0), gridInqYval(gridIDcurvl, 0));
cdoPrint("grid Xlast %4.3f, grid Ylast %4.3f", gridInqXval(gridIDcurvl, gridInqSize(gridIDcurvl) -1), gridInqYval(gridIDcurvl, gridInqSize(gridIDcurvl) -1));
cdoPrint("originLon %4.3f, originLat %4.3f", originLon, originLat);
cdoPrint("xval_0 %4.3f, yval_0 %4.3f", xval_0, yval_0);
}
int xsize = subI1 - subI0 + 1;
int ysize = subJ1 - subJ0 + 1;
......@@ -354,26 +359,36 @@ int cdo_define_subgrid_grid(int gridSrcID, int subI0, int subI1, int subJ0, int
gridDefXsize(gridID_sampled, xsize);
gridDefYsize(gridID_sampled, ysize);
if ( gridInqXvals(gridSrcID, NULL) && gridInqYvals(gridSrcID, NULL) )
{
double *xvals = (double*) Malloc(xsize*sizeof(double));
double *yvals = (double*) Malloc(ysize*sizeof(double));
gridInqXvals(gridSrcID, xvals);
gridInqYvals(gridSrcID, yvals);
gridDefXvals(gridID_sampled, xvals);
gridDefYvals(gridID_sampled, yvals);
Free(xvals);
Free(yvals);
}
gridDefNP(gridID_sampled, gridInqNP(gridSrcID));
gridDefPrec(gridID_sampled, gridInqPrec(gridSrcID));
if ( gridInqUvRelativeToGrid(gridSrcID) ) gridDefUvRelativeToGrid(gridID_sampled, 1);
grid_copy_attributes(gridSrcID, gridID_sampled);
if ( gridtype == GRID_PROJECTION ) grid_copy_mapping(gridSrcID, gridID_sampled);
originLon = gridInqXval(gridIDcurvl, subJ0*gridXsize + subI0 );
originLat = gridInqYval(gridIDcurvl, subJ0*gridXsize + subI0 );
xval_0 = gridInqXval(gridIDcurvl, subJ0*gridXsize + subI0);
yval_0 = gridInqYval(gridIDcurvl, subJ0*gridXsize + subI0);
if ( cdoDebugExt )
{
cdoPrint("%s() Sub-grid:", __func__);
cdoPrint("grid Xsize %d, grid Ysize %d", gridInqXsize(gridID_sampled), gridInqYsize(gridID_sampled));
cdoPrint("originLon %4.3f, originLat %4.3f", originLon, originLat);
cdoPrint("xval_0 %4.3f, yval_0 %4.3f", xval_0, yval_0);
}
gridDefParamLCC(gridID_sampled, originLon, originLat, lonParY, lat1, lat2, xinc, yinc, projflag, scanflag);
gridDefParamLCC(gridID_sampled, a, rf, xval_0, yval_0, lon_0, lat_1, lat_2);
gridDestroy(gridIDcurvl);
......
......@@ -360,9 +360,7 @@ void grid_print_kernel(int gridID, int opt, FILE *fp)
case GRID_LCC:
{
double originLon = 0, originLat = 0, lonParY = 0, lat1 = 0, lat2 = 0, xincm = 0, yincm = 0;
int projflag = 0, scanflag = 0;
gridInqParamLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
&projflag, &scanflag);
gridInqParamLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm);
fprintf(fp,
"originLon = %.*g\n"
......@@ -371,12 +369,9 @@ void grid_print_kernel(int gridID, int opt, FILE *fp)
"lat1 = %.*g\n"
"lat2 = %.*g\n"
"xinc = %.*g\n"
"yinc = %.*g\n"
"projection = %s\n",
"yinc = %.*g\n",
dig, originLon, dig, originLat, dig, lonParY,
dig, lat1, dig, lat2, dig, xincm, dig, yincm,
(projflag & 128) == 0 ? "northpole" : "southpole");
dig, lat1, dig, lat2, dig, xincm, dig, yincm);
int uvRelativeToGrid = gridInqUvRelativeToGrid(gridID);
if ( uvRelativeToGrid > 0 )
......
......@@ -138,22 +138,8 @@ void grid_read_data(size_t ikv, size_t nkv, kvmap_t *kvmap, griddes_t *grid, siz
else if ( STR_IS_EQ(key, "ylast") ) { grid->ylast = parameter2double(value); grid->def_ylast = true; }
else if ( STR_IS_EQ(key, "xinc") ) { grid->xinc = parameter2double(value); grid->def_xinc = true; }
else if ( STR_IS_EQ(key, "yinc") ) { grid->yinc = parameter2double(value); grid->def_yinc = true; }
else if ( STR_IS_EQ(key, "originLon") ) { grid->originLon = parameter2double(value); grid->def_originLon = true; }
else if ( STR_IS_EQ(key, "originLat") ) { grid->originLat = parameter2double(value); grid->def_originLat = true; }
else if ( STR_IS_EQ(key, "lonParY") ) { grid->lonParY = parameter2double(value); grid->def_lonParY = true; }
else if ( STR_IS_EQ(key, "lat1") ) { grid->lat1 = parameter2double(value); grid->def_lat1 = true; }
else if ( STR_IS_EQ(key, "lat2") ) { grid->lat2 = parameter2double(value); grid->def_lat2 = true; }
else if ( STR_IS_EQ(key, "lat_0") ) { grid->lat_0 = parameter2double(value); grid->def_lat_0 = true; }
else if ( STR_IS_EQ(key, "lat_1") ) { grid->lat_1 = parameter2double(value); grid->def_lat_1 = true; }
else if ( STR_IS_EQ(key, "lat_2") ) { grid->lat_2 = parameter2double(value); grid->def_lat_2 = true; }
else if ( STR_IS_EQ(key, "a") ) grid->a = parameter2double(value);
else if ( STR_IS_EQ(key, "uvRelativeToGrid") ) grid->uvRelativeToGrid = parameter2bool(value);
else if ( STR_IS_EQ(key, "projection") )
{
if ( STR_IS_EQ(value, "northpole") ) { grid->projflag = 0; grid->scanflag = 64; }
else if ( STR_IS_EQ(value, "southpole") ) { grid->projflag = 128; grid->scanflag = 64; }
else cdoAbort("Invalid projection : %s (grid description file: %s)", value, dname);
}
else if ( STR_IS_EQ(key, "xvals") )
{
size_t size = (grid->type == GRID_CURVILINEAR || grid->type == GRID_UNSTRUCTURED) ? grid->size : grid->xsize;
......
......@@ -49,32 +49,6 @@ void gridInit(griddes_t *grid)
grid->ntr = 0;
grid->nvertex = 0;
grid->genBounds = false;
grid->originLon = 0;
grid->originLat = 0;
grid->lonParY = 0;
grid->lat1 = 0;
grid->lat2 = 0;
grid->projflag = 0;
grid->scanflag = 64;
grid->def_originLon = false;
grid->def_originLat = false;
grid->def_lonParY = false;
grid->def_lat1 = false;
grid->def_lat2 = false;
grid->uvRelativeToGrid = 0;
grid->a = 0;
grid->lon_0 = 0;
grid->lat_0 = 0;
grid->lat_1 = 0;
grid->lat_2 = 0;
grid->def_lon_0 = false;
grid->def_lat_0 = false;
grid->def_lat_1 = false;
grid->def_lat_2 = false;
grid->def_xfirst = false;
grid->def_yfirst = false;
grid->def_xlast = false;
......@@ -275,36 +249,6 @@ int gridDefine(griddes_t grid)
if ( grid.ybounds ) { gridDefYbounds(gridID, grid.ybounds); Free(grid.ybounds); }
if ( grid.mask ) { gridDefMask(gridID, grid.mask); Free(grid.mask); }
break;
}
case GRID_LCC:
{
if ( grid.xsize == 0 ) Error("xsize undefined!");
if ( grid.ysize == 0 ) Error("ysize undefined!");
if ( grid.size == 0 ) grid.size = grid.xsize*grid.ysize;
gridID = gridCreate(grid.type, grid.size);
gridDefPrec(gridID, grid.prec);
gridDefXsize(gridID, grid.xsize);
gridDefYsize(gridID, grid.ysize);
if ( grid.def_originLon == false ) Error("originLon undefined!");
if ( grid.def_originLat == false ) Error("originLat undefined!");
if ( grid.def_lonParY == false ) Error("lonParY undefined!");
if ( grid.def_lat1 == false ) Error("lat1 undefined!");
if ( grid.def_lat2 == false ) Error("lat2 undefined!");
if ( grid.def_xinc == false ) Error("xinc undefined!");
if ( grid.def_yinc == false ) Error("yinc undefined!");
gridDefParamLCC(gridID, grid.originLon, grid.originLat, grid.lonParY,
grid.lat1, grid.lat2, grid.xinc, grid.yinc, grid.projflag, grid.scanflag);
if ( grid.uvRelativeToGrid ) gridDefUvRelativeToGrid(gridID, 1);
if ( grid.mask ) { gridDefMask(gridID, grid.mask); Free(grid.mask); }
break;
}
case GRID_SPECTRAL:
......
......@@ -14,11 +14,6 @@ typedef struct {
double xlast, ylast;
double xinc, yinc;
double xpole, ypole, angle; /* rotated north pole */
double originLon; /* lambert */
double originLat;
double lonParY;
double lat1;
double lat2;
int scanningMode;
/* scanningMode = 128 * iScansNegatively + 64 * jScansPositively + 32 * jPointsAreConsecutive;
64 = 128 * 0 + 64 * 1 + 32 * 0
......@@ -26,23 +21,8 @@ typedef struct {
96 = 128 * 0 + 64 * 1 + 32 * 1
Default / implicit scanning mode is 64:
i and j scan positively, i points are consecutive (row-major) */
int projflag;
int scanflag;
bool def_originLon;
bool def_originLat;
bool def_lonParY;
bool def_lat1;
bool def_lat2;
bool uvRelativeToGrid;
double a;
double lon_0;
double lat_0;
double lat_1;
double lat_2;
bool def_lon_0;
bool def_lat_0;
bool def_lat_1;
bool def_lat_2;
int prec;
int isRotated; /* TRUE for rotated grids */
int type;
......
......@@ -226,7 +226,7 @@ void print_xyvals2D(int gridID, int dig)
int xsize = gridInqXsize(gridID);
if ( xsize > 1 )
{
double *xvals = (double*) malloc(xsize*sizeof(double));
double *xvals = (double*) malloc((size_t)xsize*sizeof(double));
for ( int i = 0; i < xsize; ++i ) xvals[i] = xvals2D[i];
xinc = fabs(xvals[xsize-1] - xvals[0])/(xsize-1);
for ( int i = 2; i < xsize; i++ )
......@@ -236,7 +236,7 @@ void print_xyvals2D(int gridID, int dig)
int ysize = gridInqYsize(gridID);
if ( ysize > 1 )
{
double *yvals = (double*) malloc(ysize*sizeof(double));
double *yvals = (double*) malloc((size_t)ysize*sizeof(double));
for ( int i = 0; i < ysize; ++i ) yvals[i] = yvals2D[i*xsize];
yinc = fabs(yvals[ysize-1] - yvals[0])/(ysize-1);
for ( int i = 2; i < ysize; i++ )
......@@ -410,27 +410,6 @@ void printGridInfoKernel(int gridID, int index, bool lproj)
print_xyvals2D(gridID, dig);
}
else if ( gridtype == GRID_LCC )
{
double originLon, originLat, lonParY, lat1, lat2, xincm, yincm;
int projflag, scanflag;
gridInqParamLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm