Skip to content

Commit

Permalink
return size_t everywhere for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
arahlin committed Sep 25, 2023
1 parent c389fa5 commit b10b2d3
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 42 deletions.
4 changes: 2 additions & 2 deletions maps/include/maps/FlatSkyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class FlatSkyMap : public G3FrameObject, public G3SkyMap {
void GetRebinAngles(size_t pixel, size_t scale,
std::vector<double> & alphas, std::vector<double> & deltas) const override;
void GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const override;
std::vector<size_t> & pixels, std::vector<double> & weights) const override;

std::vector<ssize_t> QueryDisc(double alpha, double delta,
std::vector<size_t> QueryDisc(double alpha, double delta,
double radius) const override;

G3SkyMapPtr Rebin(size_t scale, bool norm = true) const override;
Expand Down
4 changes: 2 additions & 2 deletions maps/include/maps/FlatSkyProjection.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class FlatSkyProjection : public G3FrameObject {
std::vector<double> & alphas, std::vector<double> & deltas,
bool wrap_alpha=false) const;
void GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const;
std::vector<size_t> & pixels, std::vector<double> & weights) const;

std::vector<ssize_t> QueryDisc(double alpha, double delta, double radius,
std::vector<size_t> QueryDisc(double alpha, double delta, double radius,
bool local) const;

FlatSkyProjection Rebin(size_t scale, double x_center = 0.0 / 0.0,
Expand Down
10 changes: 5 additions & 5 deletions maps/include/maps/G3SkyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ class G3SkyMap {
std::vector<double> & alphas, std::vector<double> & deltas) const = 0;
G3VectorQuat GetRebinQuats(size_t pixel, size_t scale) const;
virtual void GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const = 0;
void GetInterpPixelsWeights(quat q, std::vector<ssize_t> & pixels,
std::vector<size_t> & pixels, std::vector<double> & weights) const = 0;
void GetInterpPixelsWeights(quat q, std::vector<size_t> & pixels,
std::vector<double> & weights) const;
double GetInterpPrecalc(const std::vector<ssize_t> &pixels,
double GetInterpPrecalc(const std::vector<size_t> &pixels,
const std::vector<double> &weights) const;
double GetInterpValue(double alpha, double delta) const;
double GetInterpValue(quat q) const;
Expand All @@ -186,10 +186,10 @@ class G3SkyMap {
virtual boost::shared_ptr<G3SkyMap> Rebin(size_t scale, bool norm = true) const = 0;

/* Analogue to healpy.query_disc, returns list of pixels within a disc */
virtual std::vector<ssize_t> QueryDisc(double alpha, double delta, double radius) const {
virtual std::vector<size_t> QueryDisc(double alpha, double delta, double radius) const {
throw std::runtime_error("QueryDisc not implemented");
};
std::vector<ssize_t> QueryAlphaEllipse(double alpha, double delta, double a, double b) const;
std::vector<size_t> QueryAlphaEllipse(double alpha, double delta, double a, double b) const;

virtual bool IsDense() const {
throw std::runtime_error("Checking array density not implemented");
Expand Down
4 changes: 2 additions & 2 deletions maps/include/maps/HealpixSkyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class HealpixSkyMap : public G3FrameObject, public G3SkyMap {
void GetRebinAngles(size_t pixel, size_t scale,
std::vector<double> & alphas, std::vector<double> & deltas) const override;
void GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const override;
std::vector<size_t> & pixels, std::vector<double> & weights) const override;

std::vector<ssize_t> QueryDisc(double alpha, double delta,
std::vector<size_t> QueryDisc(double alpha, double delta,
double radius) const override;

G3SkyMapPtr Rebin(size_t scale, bool norm = true) const override;
Expand Down
4 changes: 2 additions & 2 deletions maps/include/maps/HealpixSkyMapInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class HealpixSkyMapInfo : public G3FrameObject {
std::vector<double> & alphas, std::vector<double> & deltas) const;

void GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const;
std::vector<size_t> & pixels, std::vector<double> & weights) const;

std::vector<ssize_t> QueryDisc(double alpha, double delta,
std::vector<size_t> QueryDisc(double alpha, double delta,
double radius) const;

private:
Expand Down
4 changes: 2 additions & 2 deletions maps/src/FlatSkyMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -745,12 +745,12 @@ void FlatSkyMap::GetRebinAngles(size_t pixel, size_t scale,
}

void FlatSkyMap::GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const
std::vector<size_t> & pixels, std::vector<double> & weights) const
{
proj_info.GetInterpPixelsWeights(alpha, delta, pixels, weights);
}

std::vector<ssize_t>
std::vector<size_t>
FlatSkyMap::QueryDisc(double alpha, double delta, double radius) const
{
return proj_info.QueryDisc(alpha, delta, radius, coord_ref == Local);
Expand Down
18 changes: 9 additions & 9 deletions maps/src/FlatSkyProjection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -629,19 +629,19 @@ FlatSkyProjection::PixelToAngleGrad(size_t pixel, double h) const
}

void FlatSkyProjection::GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const
std::vector<size_t> & pixels, std::vector<double> & weights) const
{
std::vector<double> xy = AngleToXY(alpha, delta);
double x = xy[0];
double y = xy[1];

pixels = std::vector<ssize_t>(4, -1);
pixels = std::vector<size_t>(4, (size_t) -1);
weights = std::vector<double>(4, 0);

int x_1 = (int)floorf(x);
int x_2 = x_1 + 1;
int y_1 = (int)floorf(y);
int y_2 = y_1 + 1;
ssize_t x_1 = (ssize_t)floorf(x);
ssize_t x_2 = x_1 + 1;
ssize_t y_1 = (ssize_t)floorf(y);
ssize_t y_2 = y_1 + 1;
if (x_1 < 0 || y_1 < 0 || x_2 >= xpix_ || y_2 >= ypix_){
log_debug("Point lies outside of pixel grid\n");
return;
Expand All @@ -653,7 +653,7 @@ void FlatSkyProjection::GetInterpPixelsWeights(double alpha, double delta,
pixels[3] = x_2 + y_2 * xpix_; weights[3] = (x - x_1) * (y - y_1);
}

std::vector<ssize_t>
std::vector<size_t>
FlatSkyProjection::QueryDisc(double alpha, double delta, double radius, bool local) const
{
static const size_t npts = 72;
Expand Down Expand Up @@ -701,10 +701,10 @@ FlatSkyProjection::QueryDisc(double alpha, double delta, double radius, bool loc
ymax = cy > ypix_ ? ypix_ : cy;
}

std::vector<ssize_t> pixels;
std::vector<size_t> pixels;
for (size_t x = xmin; x < xmax; x++) {
for (size_t y = ymin; y < ymax; y++) {
ssize_t pixel = y * xpix_ + x;
size_t pixel = y * xpix_ + x;
auto ang = PixelToAngle(pixel);
if (angular_distance(alpha, delta, ang[0], ang[1]) < radius)
pixels.push_back(pixel);
Expand Down
10 changes: 5 additions & 5 deletions maps/src/G3SkyMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ G3SkyMap &G3SkyMap::operator/=(double rhs)


void
G3SkyMap::GetInterpPixelsWeights(quat q, std::vector<ssize_t> & pixels,
G3SkyMap::GetInterpPixelsWeights(quat q, std::vector<size_t> & pixels,
std::vector<double> & weights) const
{
double alpha, delta;
Expand Down Expand Up @@ -363,7 +363,7 @@ G3SkyMap::GetRebinQuats(size_t pixel, size_t scale) const
}

double
G3SkyMap::GetInterpPrecalc(const std::vector<ssize_t> & pix,
G3SkyMap::GetInterpPrecalc(const std::vector<size_t> & pix,
const std::vector<double> & weight) const
{
double outval = 0;
Expand All @@ -376,7 +376,7 @@ G3SkyMap::GetInterpPrecalc(const std::vector<ssize_t> & pix,
double
G3SkyMap::GetInterpValue(double alpha, double delta) const
{
std::vector<ssize_t> pix;
std::vector<size_t> pix;
std::vector<double> weight;
GetInterpPixelsWeights(alpha, delta, pix, weight);
return GetInterpPrecalc(pix, weight);
Expand Down Expand Up @@ -417,7 +417,7 @@ G3SkyMap::GetInterpValues(const G3VectorQuat & quats) const
return outvals;
}

std::vector<ssize_t>
std::vector<size_t>
G3SkyMap::QueryAlphaEllipse(double alpha, double delta, double a, double b) const
{
double rmaj = a > b ? a : b;
Expand All @@ -428,7 +428,7 @@ G3SkyMap::QueryAlphaEllipse(double alpha, double delta, double a, double b) cons

auto disc = QueryDisc(alpha, delta, rmaj);

std::vector<ssize_t> pixels;
std::vector<size_t> pixels;
for (auto i: disc) {
auto ang = PixelToAngle(i);
double d = angular_distance(ang[0], ang[1], ahi, delta) +
Expand Down
4 changes: 2 additions & 2 deletions maps/src/HealpixSkyMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1015,12 +1015,12 @@ void HealpixSkyMap::GetRebinAngles(size_t pixel, size_t scale,

void
HealpixSkyMap::GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const
std::vector<size_t> & pixels, std::vector<double> & weights) const
{
info_.GetInterpPixelsWeights(alpha, delta, pixels, weights);
}

std::vector<ssize_t>
std::vector<size_t>
HealpixSkyMap::QueryDisc(double alpha, double delta, double radius) const
{
return info_.QueryDisc(alpha, delta, radius);
Expand Down
24 changes: 14 additions & 10 deletions maps/src/HealpixSkyMapInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ HealpixSkyMapInfo::RingAbove(double z) const

void
HealpixSkyMapInfo::GetInterpPixelsWeights(double alpha, double delta,
std::vector<ssize_t> & pixels, std::vector<double> & weights) const
std::vector<size_t> & pixels, std::vector<double> & weights) const
{
alpha /= G3Units::rad;
delta /= G3Units::rad;

pixels = std::vector<ssize_t>(4, -1);
pixels = std::vector<size_t>(4, (size_t) -1);
weights = std::vector<double>(4, 0);

double theta = M_PI_2 - delta;
Expand Down Expand Up @@ -414,17 +414,18 @@ HealpixSkyMapInfo::GetInterpPixelsWeights(double alpha, double delta,
}

if (nested_) {
ring2nest64(nside_, pixels[0], &pixels[0]);
ring2nest64(nside_, pixels[1], &pixels[1]);
ring2nest64(nside_, pixels[2], &pixels[2]);
ring2nest64(nside_, pixels[3], &pixels[3]);
for (size_t i = 0; i < pixels.size(); i++) {
ssize_t pix = pixels[i];
ring2nest64(nside_, pix, &pix);
pixels[i] = pix;
}
}
}

std::vector<ssize_t>
std::vector<size_t>
HealpixSkyMapInfo::QueryDisc(double alpha, double delta, double radius) const
{
auto pixels = std::vector<ssize_t>();
auto pixels = std::vector<size_t>();

radius /= G3Units::rad;
if (radius >= M_PI) {
Expand Down Expand Up @@ -499,8 +500,11 @@ HealpixSkyMapInfo::QueryDisc(double alpha, double delta, double radius) const
}

if (nested_) {
for (size_t i = 0; i < pixels.size(); i++)
ring2nest64(nside_, pixels[i], &pixels[i]);
for (size_t i = 0; i < pixels.size(); i++) {
ssize_t pix = pixels[i];
ring2nest64(nside_, pix, &pix);
pixels[i] = pix;
}
std::sort(pixels.begin(), pixels.end());
}

Expand Down
2 changes: 1 addition & 1 deletion maps/src/MapMockObserver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ MapMockObserver::Process(G3FramePtr frame, std::deque<G3FramePtr> &out)
pcoupling, U_->GetPolConv());
for (size_t i = 0; i < det.size(); i++) {
if (interp_) {
std::vector<ssize_t> pixels;
std::vector<size_t> pixels;
std::vector<double> weights;
T_->GetInterpPixelsWeights(alpha[i], delta[i], pixels, weights);
det[i] =
Expand Down

0 comments on commit b10b2d3

Please sign in to comment.