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

Selbox: added support for CDI_PROJ_RLL.

parent 3ee56a85
......@@ -33,14 +33,7 @@
static
void rot_uv_back(int gridID, double *us, double *vs)
{
long i, ilat, ilon;
double u, v;
double xval, yval;
double xpole, ypole, angle;
long nlon = gridInqXsize(gridID);
long nlat = gridInqYsize(gridID);
if ( gridInqType(gridID) == GRID_PROJECTION && gridInqProjType(gridID) == CDI_PROJ_RLL )
gridInqProjParamRLL(gridID, &xpole, &ypole, &angle);
else
......@@ -50,29 +43,31 @@ void rot_uv_back(int gridID, double *us, double *vs)
angle = gridInqAngle(gridID);
}
long nlon = gridInqXsize(gridID);
long nlat = gridInqYsize(gridID);
double *xvals = (double*) Malloc(nlon*sizeof(double));
double *yvals = (double*) Malloc(nlat*sizeof(double));
gridInqXvals(gridID, xvals);
gridInqYvals(gridID, yvals);
/* Convert lat/lon units if required */
{
char units[CDI_MAX_NAME];
gridInqXunits(gridID, units);
grid_to_degree(units, 1, &xpole, "xpole");
grid_to_degree(units, nlon, xvals, "grid center lon");
gridInqYunits(gridID, units);
grid_to_degree(units, 1, &ypole, "ypole");
grid_to_degree(units, nlat, yvals, "grid center lat");
}
for ( ilat = 0; ilat < nlat; ilat++ )
for ( ilon = 0; ilon < nlon; ilon++ )
char units[CDI_MAX_NAME];
gridInqXunits(gridID, units);
grid_to_degree(units, 1, &xpole, "xpole");
grid_to_degree(units, nlon, xvals, "grid center lon");
gridInqYunits(gridID, units);
grid_to_degree(units, 1, &ypole, "ypole");
grid_to_degree(units, nlat, yvals, "grid center lat");
double u, v;
for ( long ilat = 0; ilat < nlat; ilat++ )
for ( long ilon = 0; ilon < nlon; ilon++ )
{
i = ilat*nlon + ilon;
long i = ilat*nlon + ilon;
xval = lamrot_to_lam(yvals[ilat], xvals[ilon], ypole, xpole, angle);
yval = phirot_to_phi(yvals[ilat], xvals[ilon], ypole, angle);
double xval = lamrot_to_lam(yvals[ilat], xvals[ilon], ypole, xpole, angle);
double yval = phirot_to_phi(yvals[ilat], xvals[ilon], ypole, angle);
usvs_to_uv(us[i], vs[i], yval, xval, ypole, xpole, &u, &v);
/*
......
......@@ -92,7 +92,13 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
gridDefYlongname(gridID2, ylongname);
gridDefYunits(gridID2, yunits);
if ( gridIsRotated(gridID1) )
if ( gridtype == GRID_PROJECTION && gridInqProjType(gridID1) == CDI_PROJ_RLL )
{
double xpole, ypole, angle;
gridInqProjParamRLL(gridID1, &xpole, &ypole, &angle);
gridDefProjParamRLL(gridID2, xpole, ypole, angle);
}
else if ( gridtype == GRID_LONLAT && gridIsRotated(gridID1) )
{
gridDefXpole(gridID2, gridInqXpole(gridID1));
gridDefYpole(gridID2, gridInqYpole(gridID1));
......@@ -869,6 +875,7 @@ void *Selbox(void *argument)
gridtype = gridInqType(gridID1);
if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_CURVILINEAR ||
(gridtype == GRID_PROJECTION && gridInqProjType(gridID1) == CDI_PROJ_RLL) ||
(operatorID == SELINDEXBOX && (gridtype == GRID_GENERIC || gridtype == GRID_SINUSOIDAL) &&
gridInqXsize(gridID1) > 0 && gridInqYsize(gridID1) > 0) ||
(operatorID == SELLONLATBOX && gridtype == GRID_UNSTRUCTURED) )
......
Supports Markdown
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