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

remapFindWeights(): changed interface.

parent 568b50f0
......@@ -191,7 +191,7 @@ bool pointInQuad(bool isCyclic, size_t nx, size_t ny, size_t i, size_t j, size_t
int gridSearchSquareCurv2dScrip(RemapGrid *src_grid, size_t *src_add, double *src_lats, double *src_lons, double plat, double plon,
GridSearchBins &srcBins);
bool remapFindWeights(double plon, double plat, double *src_lons, double *src_lats, double *ig, double *jg);
bool remapFindWeights(const LonLatPoint &llpoint, double *src_lons, double *src_lats, double *ig, double *jg);
int rect_grid_search(size_t *ii, size_t *jj, double x, double y, size_t nxm, size_t nym, const double *xm, const double *ym);
LonLatPoint remapgrid_get_lonlat(RemapGrid *grid, size_t cell_add);
......
......@@ -136,7 +136,7 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
if (!tgt_grid->mask[tgt_cell_add]) continue;
const auto llp = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
......@@ -144,7 +144,7 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
double wgts[4][4]; // bicubic weights for four corners
// Find nearest square of grid points on source grid
int search_result = remapSearchSquare(rsearch, llp, src_add, src_lats, src_lons);
int search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
// Check to see if points are mask points
if (search_result > 0)
......@@ -159,7 +159,7 @@ remapBicubicWeights(RemapSearch &rsearch, RemapVars &rv)
tgt_grid->cell_frac[tgt_cell_add] = 1.;
double iw, jw; // current guess for bilinear coordinate
if (remapFindWeights(llp.lon, llp.lat, src_lons, src_lats, &iw, &jw))
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
{
// Successfully found iw,jw - compute weights
bicubicSetWeights(iw, jw, wgts);
......@@ -252,7 +252,7 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
if (!tgt_grid->mask[tgt_cell_add]) continue;
const auto llp = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
......@@ -260,7 +260,7 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
double wgts[4][4]; // bicubic weights for four corners
// Find nearest square of grid points on source grid
int search_result = remapSearchSquare(rsearch, llp, src_add, src_lats, src_lons);
int search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
// Check to see if points are mask points
if (search_result > 0)
......@@ -275,7 +275,7 @@ remapBicubic(RemapSearch &rsearch, const double *restrict src_array, double *res
tgt_grid->cell_frac[tgt_cell_add] = 1.;
double iw, jw; // current guess for bilinear coordinate
if (remapFindWeights(llp.lon, llp.lat, src_lons, src_lats, &iw, &jw))
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
{
// Successfully found iw,jw - compute weights
bicubicSetWeights(iw, jw, wgts);
......
......@@ -26,7 +26,7 @@
// bilinear interpolation
bool
remapFindWeights(double plon, double plat, double *restrict src_lons, double *restrict src_lats, double *ig, double *jg)
remapFindWeights(const LonLatPoint &llpoint, double *restrict src_lons, double *restrict src_lats, double *ig, double *jg)
{
long iter; // iteration counters
double deli, delj; // corrections to iw,jw
......@@ -63,8 +63,8 @@ remapFindWeights(double plon, double plat, double *restrict src_lons, double *re
for (iter = 0; iter < remap_max_iter; ++iter)
{
dthp = plat - src_lats[0] - dth1 * iguess - dth2 * jguess - dth3 * iguess * jguess;
dphp = plon - src_lons[0];
dthp = llpoint.lat - src_lats[0] - dth1 * iguess - dth2 * jguess - dth3 * iguess * jguess;
dphp = llpoint.lon - src_lons[0];
if (dphp > 3.0 * PIH) dphp -= PI2;
if (dphp < -3.0 * PIH) dphp += PI2;
......@@ -206,7 +206,7 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
if (!tgt_grid->mask[tgt_cell_add]) continue;
const auto llp = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
......@@ -214,7 +214,7 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
double wgts[4]; // bilinear weights for four corners
// Find nearest square of grid points on source grid
int search_result = remapSearchSquare(rsearch, llp, src_add, src_lats, src_lons);
int search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
// Check to see if points are mask points
if (search_result > 0)
......@@ -229,7 +229,7 @@ remapBilinearWeights(RemapSearch &rsearch, RemapVars &rv)
tgt_grid->cell_frac[tgt_cell_add] = 1.;
double iw, jw; // current guess for bilinear coordinate
if (remapFindWeights(llp.lon, llp.lat, src_lons, src_lats, &iw, &jw))
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
{
// Successfully found iw,jw - compute weights
bilinearSetWeights(iw, jw, wgts);
......@@ -312,7 +312,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
if (!tgt_grid->mask[tgt_cell_add]) continue;
const auto llp = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
const auto llpoint = remapgrid_get_lonlat(tgt_grid, tgt_cell_add);
size_t src_add[4]; // address for the four source points
double src_lats[4]; // latitudes of four bilinear corners
......@@ -320,7 +320,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
double wgts[4]; // bilinear weights for four corners
// Find nearest square of grid points on source grid
int search_result = remapSearchSquare(rsearch, llp, src_add, src_lats, src_lons);
int search_result = remapSearchSquare(rsearch, llpoint, src_add, src_lats, src_lons);
// Check to see if points are mask points
if (search_result > 0)
......@@ -335,7 +335,7 @@ remapBilinear(RemapSearch &rsearch, const double *restrict src_array, double *re
tgt_grid->cell_frac[tgt_cell_add] = 1.;
double iw, jw; // current guess for bilinear coordinate
if (remapFindWeights(llp.lon, llp.lat, src_lons, src_lats, &iw, &jw))
if (remapFindWeights(llpoint, src_lons, src_lats, &iw, &jw))
{
// Successfully found iw,jw - compute weights
bilinearSetWeights(iw, jw, wgts);
......
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