From b10b2d370f25b7cd31901efbecf20f9124f391da Mon Sep 17 00:00:00 2001 From: Sasha Rahlin Date: Mon, 25 Sep 2023 09:48:06 -0500 Subject: [PATCH] return size_t everywhere for consistency --- maps/include/maps/FlatSkyMap.h | 4 ++-- maps/include/maps/FlatSkyProjection.h | 4 ++-- maps/include/maps/G3SkyMap.h | 10 +++++----- maps/include/maps/HealpixSkyMap.h | 4 ++-- maps/include/maps/HealpixSkyMapInfo.h | 4 ++-- maps/src/FlatSkyMap.cxx | 4 ++-- maps/src/FlatSkyProjection.cxx | 18 +++++++++--------- maps/src/G3SkyMap.cxx | 10 +++++----- maps/src/HealpixSkyMap.cxx | 4 ++-- maps/src/HealpixSkyMapInfo.cxx | 24 ++++++++++++++---------- maps/src/MapMockObserver.cxx | 2 +- 11 files changed, 46 insertions(+), 42 deletions(-) diff --git a/maps/include/maps/FlatSkyMap.h b/maps/include/maps/FlatSkyMap.h index f041bc00..a2279d59 100644 --- a/maps/include/maps/FlatSkyMap.h +++ b/maps/include/maps/FlatSkyMap.h @@ -128,9 +128,9 @@ class FlatSkyMap : public G3FrameObject, public G3SkyMap { void GetRebinAngles(size_t pixel, size_t scale, std::vector & alphas, std::vector & deltas) const override; void GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const override; + std::vector & pixels, std::vector & weights) const override; - std::vector QueryDisc(double alpha, double delta, + std::vector QueryDisc(double alpha, double delta, double radius) const override; G3SkyMapPtr Rebin(size_t scale, bool norm = true) const override; diff --git a/maps/include/maps/FlatSkyProjection.h b/maps/include/maps/FlatSkyProjection.h index 39c380be..e9e046aa 100644 --- a/maps/include/maps/FlatSkyProjection.h +++ b/maps/include/maps/FlatSkyProjection.h @@ -103,9 +103,9 @@ class FlatSkyProjection : public G3FrameObject { std::vector & alphas, std::vector & deltas, bool wrap_alpha=false) const; void GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const; + std::vector & pixels, std::vector & weights) const; - std::vector QueryDisc(double alpha, double delta, double radius, + std::vector QueryDisc(double alpha, double delta, double radius, bool local) const; FlatSkyProjection Rebin(size_t scale, double x_center = 0.0 / 0.0, diff --git a/maps/include/maps/G3SkyMap.h b/maps/include/maps/G3SkyMap.h index 112ca2c3..8e63347b 100644 --- a/maps/include/maps/G3SkyMap.h +++ b/maps/include/maps/G3SkyMap.h @@ -172,10 +172,10 @@ class G3SkyMap { std::vector & alphas, std::vector & deltas) const = 0; G3VectorQuat GetRebinQuats(size_t pixel, size_t scale) const; virtual void GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const = 0; - void GetInterpPixelsWeights(quat q, std::vector & pixels, + std::vector & pixels, std::vector & weights) const = 0; + void GetInterpPixelsWeights(quat q, std::vector & pixels, std::vector & weights) const; - double GetInterpPrecalc(const std::vector &pixels, + double GetInterpPrecalc(const std::vector &pixels, const std::vector &weights) const; double GetInterpValue(double alpha, double delta) const; double GetInterpValue(quat q) const; @@ -186,10 +186,10 @@ class G3SkyMap { virtual boost::shared_ptr Rebin(size_t scale, bool norm = true) const = 0; /* Analogue to healpy.query_disc, returns list of pixels within a disc */ - virtual std::vector QueryDisc(double alpha, double delta, double radius) const { + virtual std::vector QueryDisc(double alpha, double delta, double radius) const { throw std::runtime_error("QueryDisc not implemented"); }; - std::vector QueryAlphaEllipse(double alpha, double delta, double a, double b) const; + std::vector QueryAlphaEllipse(double alpha, double delta, double a, double b) const; virtual bool IsDense() const { throw std::runtime_error("Checking array density not implemented"); diff --git a/maps/include/maps/HealpixSkyMap.h b/maps/include/maps/HealpixSkyMap.h index 2ed50ab3..a28194d9 100644 --- a/maps/include/maps/HealpixSkyMap.h +++ b/maps/include/maps/HealpixSkyMap.h @@ -84,9 +84,9 @@ class HealpixSkyMap : public G3FrameObject, public G3SkyMap { void GetRebinAngles(size_t pixel, size_t scale, std::vector & alphas, std::vector & deltas) const override; void GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const override; + std::vector & pixels, std::vector & weights) const override; - std::vector QueryDisc(double alpha, double delta, + std::vector QueryDisc(double alpha, double delta, double radius) const override; G3SkyMapPtr Rebin(size_t scale, bool norm = true) const override; diff --git a/maps/include/maps/HealpixSkyMapInfo.h b/maps/include/maps/HealpixSkyMapInfo.h index a96359f6..b2461385 100644 --- a/maps/include/maps/HealpixSkyMapInfo.h +++ b/maps/include/maps/HealpixSkyMapInfo.h @@ -46,9 +46,9 @@ class HealpixSkyMapInfo : public G3FrameObject { std::vector & alphas, std::vector & deltas) const; void GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const; + std::vector & pixels, std::vector & weights) const; - std::vector QueryDisc(double alpha, double delta, + std::vector QueryDisc(double alpha, double delta, double radius) const; private: diff --git a/maps/src/FlatSkyMap.cxx b/maps/src/FlatSkyMap.cxx index 5f195108..3ba0f5a8 100644 --- a/maps/src/FlatSkyMap.cxx +++ b/maps/src/FlatSkyMap.cxx @@ -745,12 +745,12 @@ void FlatSkyMap::GetRebinAngles(size_t pixel, size_t scale, } void FlatSkyMap::GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const + std::vector & pixels, std::vector & weights) const { proj_info.GetInterpPixelsWeights(alpha, delta, pixels, weights); } -std::vector +std::vector FlatSkyMap::QueryDisc(double alpha, double delta, double radius) const { return proj_info.QueryDisc(alpha, delta, radius, coord_ref == Local); diff --git a/maps/src/FlatSkyProjection.cxx b/maps/src/FlatSkyProjection.cxx index 0c28b6fd..744d505a 100644 --- a/maps/src/FlatSkyProjection.cxx +++ b/maps/src/FlatSkyProjection.cxx @@ -629,19 +629,19 @@ FlatSkyProjection::PixelToAngleGrad(size_t pixel, double h) const } void FlatSkyProjection::GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const + std::vector & pixels, std::vector & weights) const { std::vector xy = AngleToXY(alpha, delta); double x = xy[0]; double y = xy[1]; - pixels = std::vector(4, -1); + pixels = std::vector(4, (size_t) -1); weights = std::vector(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; @@ -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 +std::vector FlatSkyProjection::QueryDisc(double alpha, double delta, double radius, bool local) const { static const size_t npts = 72; @@ -701,10 +701,10 @@ FlatSkyProjection::QueryDisc(double alpha, double delta, double radius, bool loc ymax = cy > ypix_ ? ypix_ : cy; } - std::vector pixels; + std::vector 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); diff --git a/maps/src/G3SkyMap.cxx b/maps/src/G3SkyMap.cxx index 1c6be17a..4c105eaa 100644 --- a/maps/src/G3SkyMap.cxx +++ b/maps/src/G3SkyMap.cxx @@ -334,7 +334,7 @@ G3SkyMap &G3SkyMap::operator/=(double rhs) void -G3SkyMap::GetInterpPixelsWeights(quat q, std::vector & pixels, +G3SkyMap::GetInterpPixelsWeights(quat q, std::vector & pixels, std::vector & weights) const { double alpha, delta; @@ -363,7 +363,7 @@ G3SkyMap::GetRebinQuats(size_t pixel, size_t scale) const } double -G3SkyMap::GetInterpPrecalc(const std::vector & pix, +G3SkyMap::GetInterpPrecalc(const std::vector & pix, const std::vector & weight) const { double outval = 0; @@ -376,7 +376,7 @@ G3SkyMap::GetInterpPrecalc(const std::vector & pix, double G3SkyMap::GetInterpValue(double alpha, double delta) const { - std::vector pix; + std::vector pix; std::vector weight; GetInterpPixelsWeights(alpha, delta, pix, weight); return GetInterpPrecalc(pix, weight); @@ -417,7 +417,7 @@ G3SkyMap::GetInterpValues(const G3VectorQuat & quats) const return outvals; } -std::vector +std::vector G3SkyMap::QueryAlphaEllipse(double alpha, double delta, double a, double b) const { double rmaj = a > b ? a : b; @@ -428,7 +428,7 @@ G3SkyMap::QueryAlphaEllipse(double alpha, double delta, double a, double b) cons auto disc = QueryDisc(alpha, delta, rmaj); - std::vector pixels; + std::vector pixels; for (auto i: disc) { auto ang = PixelToAngle(i); double d = angular_distance(ang[0], ang[1], ahi, delta) + diff --git a/maps/src/HealpixSkyMap.cxx b/maps/src/HealpixSkyMap.cxx index 44c8ac7e..515ec867 100644 --- a/maps/src/HealpixSkyMap.cxx +++ b/maps/src/HealpixSkyMap.cxx @@ -1015,12 +1015,12 @@ void HealpixSkyMap::GetRebinAngles(size_t pixel, size_t scale, void HealpixSkyMap::GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const + std::vector & pixels, std::vector & weights) const { info_.GetInterpPixelsWeights(alpha, delta, pixels, weights); } -std::vector +std::vector HealpixSkyMap::QueryDisc(double alpha, double delta, double radius) const { return info_.QueryDisc(alpha, delta, radius); diff --git a/maps/src/HealpixSkyMapInfo.cxx b/maps/src/HealpixSkyMapInfo.cxx index 5cd9791b..471bbdfb 100644 --- a/maps/src/HealpixSkyMapInfo.cxx +++ b/maps/src/HealpixSkyMapInfo.cxx @@ -330,12 +330,12 @@ HealpixSkyMapInfo::RingAbove(double z) const void HealpixSkyMapInfo::GetInterpPixelsWeights(double alpha, double delta, - std::vector & pixels, std::vector & weights) const + std::vector & pixels, std::vector & weights) const { alpha /= G3Units::rad; delta /= G3Units::rad; - pixels = std::vector(4, -1); + pixels = std::vector(4, (size_t) -1); weights = std::vector(4, 0); double theta = M_PI_2 - delta; @@ -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 +std::vector HealpixSkyMapInfo::QueryDisc(double alpha, double delta, double radius) const { - auto pixels = std::vector(); + auto pixels = std::vector(); radius /= G3Units::rad; if (radius >= M_PI) { @@ -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()); } diff --git a/maps/src/MapMockObserver.cxx b/maps/src/MapMockObserver.cxx index 7303e4ea..ba81012d 100644 --- a/maps/src/MapMockObserver.cxx +++ b/maps/src/MapMockObserver.cxx @@ -215,7 +215,7 @@ MapMockObserver::Process(G3FramePtr frame, std::deque &out) pcoupling, U_->GetPolConv()); for (size_t i = 0; i < det.size(); i++) { if (interp_) { - std::vector pixels; + std::vector pixels; std::vector weights; T_->GetInterpPixelsWeights(alpha[i], delta[i], pixels, weights); det[i] =