Skip to content
Snippets Groups Projects
Commit 3d22878f authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Rename hp_interpolate_weights() to hp_bilinear_interpolate_weights().

parent 15d421d1
No related branches found
No related tags found
No related merge requests found
......@@ -24,32 +24,29 @@ hp_get_order(const char *orderName)
}
static int64_t
hp_xy_to_xy(int64_t ipix, int nside)
hp_xy_to_xy(int64_t index, int nside)
{
(void) nside;
return ipix;
return index;
}
int64_t
hp_lonlat_to_healpixl(HpOrder order, int nside, double xval, double yval)
{
int64_t (*convert_order)(int64_t ipix, int nside);
int64_t (*convert_order)(int64_t index, int nside);
// clang-format off
convert_order = (order == HpOrder::Ring) ? &healpixl_xy_to_ring :
(order == HpOrder::Nest) ? &healpixl_xy_to_nested : &hp_xy_to_xy;
// clang-format on
auto ipix = radec_to_healpixl(xval, yval, nside);
auto cpix = convert_order(ipix, nside);
return cpix;
return convert_order(radec_to_healpixl(xval, yval, nside), nside);
}
void
hp_generate_coords(HpOrder order, int nside, int64_t nvals, double *xvals, double *yvals, bool withBounds, double *xbounds,
double *ybounds)
{
int64_t (*convert_order)(int64_t ipix, int nside);
int64_t (*convert_order)(int64_t index, int nside);
// clang-format off
convert_order = (order == HpOrder::Ring) ? &healpixl_ring_to_xy :
(order == HpOrder::Nest) ? &healpixl_nested_to_xy : &hp_xy_to_xy;
......@@ -58,38 +55,37 @@ hp_generate_coords(HpOrder order, int nside, int64_t nvals, double *xvals, doubl
#ifdef _OPENMP
#pragma omp parallel for if (nvals > 99999) default(shared) schedule(static)
#endif
for (int64_t ipix = 0; ipix < nvals; ipix++)
for (int64_t index = 0; index < nvals; index++)
{
auto cpix = convert_order(ipix, nside);
healpixl_to_radec(cpix, nside, 0.5, 0.5, &xvals[ipix], &yvals[ipix]);
auto cpix = convert_order(index, nside);
healpixl_to_radec(cpix, nside, 0.5, 0.5, &xvals[index], &yvals[index]);
if (withBounds)
{
healpixl_to_radec(cpix, nside, 0.0, 0.0, &xbounds[ipix * 4 + 0], &ybounds[ipix * 4 + 0]);
healpixl_to_radec(cpix, nside, 1.0, 0.0, &xbounds[ipix * 4 + 1], &ybounds[ipix * 4 + 1]);
healpixl_to_radec(cpix, nside, 1.0, 1.0, &xbounds[ipix * 4 + 2], &ybounds[ipix * 4 + 2]);
healpixl_to_radec(cpix, nside, 0.0, 1.0, &xbounds[ipix * 4 + 3], &ybounds[ipix * 4 + 3]);
healpixl_to_radec(cpix, nside, 0.0, 0.0, &xbounds[index * 4 + 0], &ybounds[index * 4 + 0]);
healpixl_to_radec(cpix, nside, 1.0, 0.0, &xbounds[index * 4 + 1], &ybounds[index * 4 + 1]);
healpixl_to_radec(cpix, nside, 1.0, 1.0, &xbounds[index * 4 + 2], &ybounds[index * 4 + 2]);
healpixl_to_radec(cpix, nside, 0.0, 1.0, &xbounds[index * 4 + 3], &ybounds[index * 4 + 3]);
}
}
}
void
hp_index_to_lonlat(HpOrder order, int nside, int64_t ipix, double *xval, double *yval)
hp_index_to_lonlat(HpOrder order, int nside, int64_t index, double *xval, double *yval)
{
int64_t (*convert_order)(int64_t ipix, int nside);
int64_t (*convert_order)(int64_t index, int nside);
// clang-format off
convert_order = (order == HpOrder::Ring) ? &healpixl_ring_to_xy :
(order == HpOrder::Nest) ? &healpixl_nested_to_xy : &hp_xy_to_xy;
// clang-format on
auto cpix = convert_order(ipix, nside);
healpixl_to_radec(cpix, nside, 0.5, 0.5, xval, yval);
healpixl_to_radec(convert_order(index, nside), nside, 0.5, 0.5, xval, yval);
}
void
hp_interpolate_weights(double lon, double lat, size_t *indices, double *weights, int nside, HpOrder order)
hp_bilinear_interpolate_weights(double lon, double lat, size_t *indices, double *weights, int nside, HpOrder order)
{
int64_t (*convert_order)(int64_t ipix, int nside);
int64_t (*convert_order)(int64_t index, int nside);
// clang-format off
convert_order = (order == HpOrder::Ring) ? &healpixl_xy_to_ring :
(order == HpOrder::Nest) ? &healpixl_xy_to_nested : &hp_xy_to_xy;
......
......@@ -15,7 +15,7 @@ HpOrder hp_get_order(const char *orderName);
int64_t hp_lonlat_to_healpixl(HpOrder order, int nside, double xval, double yval);
void hp_generate_coords(HpOrder order, int nside, int64_t nvals, double *xvals, double *yvals, bool withBounds, double *xbounds,
double *ybounds);
void hp_index_to_lonlat(HpOrder order, int nside, int64_t ipix, double *xval, double *yval);
void hp_interpolate_weights(double lon, double lat, size_t *indices, double *weights, int nside, HpOrder order);
void hp_index_to_lonlat(HpOrder order, int nside, int64_t index, double *xval, double *yval);
void hp_bilinear_interpolate_weights(double lon, double lat, size_t *indices, double *weights, int nside, HpOrder order);
#endif
......@@ -422,7 +422,7 @@ remap_bilinear_healpix_kernel(const Varray<T> &srcArray, const Varray<short> &sr
double weights[4]; // bilinear weights for four corners
size_t searchIndices[4]; // address for the four source points
hp_interpolate_weights(llpoint.lon, llpoint.lat, searchIndices, weights, nside, order);
hp_bilinear_interpolate_weights(llpoint.lon, llpoint.lat, searchIndices, weights, nside, order);
int searchResult = 1;
// Check to see if points are mask points
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment