From 45bcd2e89c4dc39de3e917d95abe58febe582e78 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sun, 8 Dec 2013 02:29:54 +0100 Subject: [PATCH] Rename omega() methods to solidangle(). --- NEWS | 9 ++++++--- include/GHealpix.hpp | 19 ++++++++++++++++++- include/GSkyProjection.hpp | 2 +- include/GSkymap.hpp | 4 ++-- include/GWcs.hpp | 2 +- inst/com/src/GCOMEventCube.cpp | 2 +- inst/cta/include/GCTAEventBin.hpp | 2 +- inst/cta/pyext/GCTAEventBin.i | 8 ++++---- inst/cta/src/GCTAEventBin.cpp | 8 ++++---- inst/cta/src/GCTAEventCube.cpp | 2 +- inst/lat/src/GLATEventCube.cpp | 2 +- inst/lat/src/GLATMeanPsf.cpp | 8 ++++---- pyext/GHealpix.i | 2 +- pyext/GSkyProjection.i | 2 +- pyext/GSkymap.i | 4 ++-- pyext/GWcs.i | 2 +- src/model/GModelSpatialDiffuseCube.cpp | 4 ++-- src/model/GModelSpatialDiffuseMap.cpp | 4 ++-- src/sky/GHealpix.cpp | 17 ----------------- src/sky/GSkymap.cpp | 26 +++++++++++++------------- src/sky/GWcs.cpp | 3 +-- 21 files changed, 67 insertions(+), 65 deletions(-) diff --git a/NEWS b/NEWS index 220d0bb..acb94d2 100644 --- a/NEWS +++ b/NEWS @@ -248,18 +248,21 @@ GWcs => GSkyProjection been added that returns the dimension of the projection (1D or 2D). The integer index methods have been removed as GSkyPixel now supports 1D and 2D pixels. The read() and write() methods - now take a reference instead of a pointer. + now take a reference instead of a pointer. The omega() method + has been renamed to solidangle(). GWcslib => GWcs The GWcslib class has been renamed to GWcs. The class now conforms to the GSkyProjection base class interface. The read() and write() - methods now take a reference instead of a pointer. + methods now take a reference instead of a pointer. The omega() + method has been renamed to solidangle(). GWcsHPX => GHealpix The GWcsHPX class has been renamed to GHealpix as the Healpix projection is not a World Coordinate System. GHealpix is no longer registered in GWcsRegistry. The read() and write() - methods now take a reference instead of a pointer. + methods now take a reference instead of a pointer. The + omega() method has been renamed to solidangle(). GWcsRegistry Now holds objects of renamed type GWcs (see GHealpix). diff --git a/include/GHealpix.hpp b/include/GHealpix.hpp index ba6e961..9341448 100644 --- a/include/GHealpix.hpp +++ b/include/GHealpix.hpp @@ -66,7 +66,7 @@ public: virtual std::string name(void) const; virtual void read(const GFitsHDU& hdu); virtual void write(GFitsHDU& hdu) const; - virtual double omega(const GSkyPixel& pixel) const; + virtual double solidangle(const GSkyPixel& pixel) const; virtual GSkyDir pix2dir(const GSkyPixel& pixel) const; virtual GSkyPixel dir2pix(const GSkyDir& dir) const; virtual std::string print(const GChatter& chatter = NORMAL) const; @@ -167,4 +167,21 @@ const int& GHealpix::nside(void) const return m_nside; } + +/***********************************************************************//** + * @brief Returns solid angle of pixel + * + * @param[in] pixel Sky pixel. + * @return Solid angle of pixel. + * + * Returns the solid angle of the specified @p pixel. Note that HEALPix + * pixels have all the same solid angle, hence the @p pixel argument is in + * fact not used by the method. + ***************************************************************************/ +inline +double GHealpix::solidangle(const GSkyPixel& pixel) const +{ + return m_omega; +} + #endif /* GHEALPIX_HPP */ diff --git a/include/GSkyProjection.hpp b/include/GSkyProjection.hpp index 26875d8..ba3ce8d 100644 --- a/include/GSkyProjection.hpp +++ b/include/GSkyProjection.hpp @@ -67,7 +67,7 @@ public: virtual std::string name(void) const = 0; virtual void read(const GFitsHDU& hdu) = 0; virtual void write(GFitsHDU& hdu) const = 0; - virtual double omega(const GSkyPixel& pixel) const = 0; + virtual double solidangle(const GSkyPixel& pixel) const = 0; virtual GSkyDir pix2dir(const GSkyPixel& pixel) const = 0; virtual GSkyPixel dir2pix(const GSkyDir& dir) const = 0; virtual std::string print(const GChatter& chatter = NORMAL) const = 0; diff --git a/include/GSkymap.hpp b/include/GSkymap.hpp index 5f85cd1..98a7205 100644 --- a/include/GSkymap.hpp +++ b/include/GSkymap.hpp @@ -119,8 +119,8 @@ public: int pix2inx(const GSkyPixel& pixel) const; int dir2inx(const GSkyDir& dir) const; GSkyPixel dir2pix(const GSkyDir& dir) const; - double omega(const int& index) const; - double omega(const GSkyPixel& pixel) const; + double solidangle(const int& index) const; + double solidangle(const GSkyPixel& pixel) const; bool contains(const GSkyDir& dir) const; bool contains(const GSkyPixel& pixel) const; const GSkyProjection* projection(void) const; diff --git a/include/GWcs.hpp b/include/GWcs.hpp index 4d2349d..1935a6d 100644 --- a/include/GWcs.hpp +++ b/include/GWcs.hpp @@ -70,7 +70,7 @@ public: virtual int size(void) const; virtual void read(const GFitsHDU& hdu); virtual void write(GFitsHDU& hdu) const; - virtual double omega(const GSkyPixel& pixel) const; + virtual double solidangle(const GSkyPixel& pixel) const; virtual GSkyDir pix2dir(const GSkyPixel& pixel) const; virtual GSkyPixel dir2pix(const GSkyDir& dir) const; diff --git a/inst/com/src/GCOMEventCube.cpp b/inst/com/src/GCOMEventCube.cpp index 3bdbcd4..c0a3cb2 100644 --- a/inst/com/src/GCOMEventCube.cpp +++ b/inst/com/src/GCOMEventCube.cpp @@ -709,7 +709,7 @@ void GCOMEventCube::set_scatter_directions(void) for (int ix = 0; ix < nchi(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); m_dirs.push_back(m_map.pix2dir(pixel)); - m_omega.push_back(m_map.omega(pixel)); + m_omega.push_back(m_map.solidangle(pixel)); } } diff --git a/inst/cta/include/GCTAEventBin.hpp b/inst/cta/include/GCTAEventBin.hpp index 68b7082..d4b2097 100644 --- a/inst/cta/include/GCTAEventBin.hpp +++ b/inst/cta/include/GCTAEventBin.hpp @@ -76,7 +76,7 @@ public: virtual std::string print(const GChatter& chatter = NORMAL) const; // Other methods - const double& omega(void) const; + const double& solidangle(void) const; const GEnergy& ewidth(void) const; const double& ontime(void) const; diff --git a/inst/cta/pyext/GCTAEventBin.i b/inst/cta/pyext/GCTAEventBin.i index ecc2bc5..7368ff3 100644 --- a/inst/cta/pyext/GCTAEventBin.i +++ b/inst/cta/pyext/GCTAEventBin.i @@ -1,7 +1,7 @@ /*************************************************************************** - * GCTAEventBin.i - CTA event bin class * + * GCTAEventBin.i - CTA event bin class * * ----------------------------------------------------------------------- * - * copyright (C) 2011-2012 by Juergen Knoedlseder * + * copyright (C) 2011-2013 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -20,7 +20,7 @@ ***************************************************************************/ /** * @file GCTAEventBin.i - * @brief CTA event bin class Python interface definition + * @brief CTA event bin class definition * @author Juergen Knoedlseder */ %{ @@ -57,7 +57,7 @@ public: virtual void counts(const double& counts); // Other methods - const double& omega(void) const; + const double& solidangle(void) const; const GEnergy& ewidth(void) const; const double& ontime(void) const; }; diff --git a/inst/cta/src/GCTAEventBin.cpp b/inst/cta/src/GCTAEventBin.cpp index ae46bb3..94068fa 100644 --- a/inst/cta/src/GCTAEventBin.cpp +++ b/inst/cta/src/GCTAEventBin.cpp @@ -40,7 +40,7 @@ #define G_TIME "GCTAEventBin::time()" #define G_COUNTS_GET "GCTAEventBin::counts()" #define G_COUNTS_SET "GCTAEventBin::counts(double&)" -#define G_OMEGA "GCTAEventBin::omega()" +#define G_SOLIDANGLE "GCTAEventBin::solidangle()" #define G_EWIDTH "GCTAEventBin::ewidth()" #define G_ONTIME "GCTAEventBin::ontime()" @@ -186,7 +186,7 @@ GCTAEventBin* GCTAEventBin::clone(void) const double GCTAEventBin::size(void) const { // Compute bin size - double size = omega() * ewidth().MeV() * ontime(); + double size = solidangle() * ewidth().MeV() * ontime(); // Return bin size return size; @@ -344,11 +344,11 @@ double GCTAEventBin::error(void) const * * Returns reference to the solid angle of the event bin. ***************************************************************************/ -const double& GCTAEventBin::omega(void) const +const double& GCTAEventBin::solidangle(void) const { // Throw an exception if solid angle pointer is not valid if (m_omega == NULL) { - throw GCTAException::no_member(G_OMEGA, + throw GCTAException::no_member(G_SOLIDANGLE, "Invalid solid angle pointer."); } diff --git a/inst/cta/src/GCTAEventCube.cpp b/inst/cta/src/GCTAEventCube.cpp index 0e09466..3b7ebba 100644 --- a/inst/cta/src/GCTAEventCube.cpp +++ b/inst/cta/src/GCTAEventCube.cpp @@ -680,7 +680,7 @@ void GCTAEventCube::set_directions(void) try { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); m_dirs.push_back(GCTAInstDir(m_map.pix2dir(pixel))); - m_omega.push_back(m_map.omega(pixel)); + m_omega.push_back(m_map.solidangle(pixel)); } catch (GException::wcs_invalid_x_y& e) { m_dirs.push_back(GCTAInstDir()); diff --git a/inst/lat/src/GLATEventCube.cpp b/inst/lat/src/GLATEventCube.cpp index b785c77..2bb1608 100644 --- a/inst/lat/src/GLATEventCube.cpp +++ b/inst/lat/src/GLATEventCube.cpp @@ -843,7 +843,7 @@ void GLATEventCube::set_directions(void) for (int ix = 0; ix < nx(); ++ix) { GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); m_dirs.push_back(GLATInstDir(m_map.pix2dir(pixel))); - m_omega.push_back(m_map.omega(pixel)); + m_omega.push_back(m_map.solidangle(pixel)); } } diff --git a/inst/lat/src/GLATMeanPsf.cpp b/inst/lat/src/GLATMeanPsf.cpp index fa2ca13..c1596ea 100644 --- a/inst/lat/src/GLATMeanPsf.cpp +++ b/inst/lat/src/GLATMeanPsf.cpp @@ -735,16 +735,16 @@ void GLATMeanPsf::set_map_corrections(const GLATObservation& obs) for (int ix = 0; ix < cube->nx(); ++ix) { // Compute offset angle in degrees - GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); - double offset = cube->map().pix2dir(pixel).dist_deg(m_dir); - double omega = cube->map().omega(pixel); + GSkyPixel pixel = GSkyPixel(double(ix), double(iy)); + double offset = cube->map().pix2dir(pixel).dist_deg(m_dir); + double solidangle = cube->map().solidangle(pixel); // Use only pixels within maximum PSF radius if (offset <= radius) { // Accumulate energy dependent pixel sum for (int ieng = 0; ieng < m_energy.size(); ++ieng) - sum[ieng] += psf(offset, m_energy[ieng]) * omega; + sum[ieng] += psf(offset, m_energy[ieng]) * solidangle; } // endif: pixel was within maximum PSF radius diff --git a/pyext/GHealpix.i b/pyext/GHealpix.i index e39ebe3..963bb8f 100644 --- a/pyext/GHealpix.i +++ b/pyext/GHealpix.i @@ -52,7 +52,7 @@ public: virtual std::string name(void) const; virtual void read(const GFitsHDU& hdu); virtual void write(GFitsHDU& hdu) const; - virtual double omega(const GSkyPixel& pixel) const; + virtual double solidangle(const GSkyPixel& pixel) const; virtual GSkyDir pix2dir(const GSkyPixel& pixel) const; virtual GSkyPixel dir2pix(const GSkyDir& dir) const; diff --git a/pyext/GSkyProjection.i b/pyext/GSkyProjection.i index 46c006c..b4336e1 100644 --- a/pyext/GSkyProjection.i +++ b/pyext/GSkyProjection.i @@ -53,7 +53,7 @@ public: virtual std::string name(void) const = 0; virtual void read(const GFitsHDU& hdu) = 0; virtual void write(GFitsHDU& hdu) const = 0; - virtual double omega(const GSkyPixel& pixel) const = 0; + virtual double solidangle(const GSkyPixel& pixel) const = 0; virtual GSkyDir pix2dir(const GSkyPixel& pixel) const = 0; virtual GSkyPixel dir2pix(const GSkyDir& dir) const = 0; diff --git a/pyext/GSkymap.i b/pyext/GSkymap.i index 5cc6f90..0ada82f 100644 --- a/pyext/GSkymap.i +++ b/pyext/GSkymap.i @@ -140,8 +140,8 @@ public: int pix2inx(const GSkyPixel& pixel) const; int dir2inx(const GSkyDir& dir) const; GSkyPixel dir2pix(const GSkyDir& dir) const; - double omega(const int& index) const; - double omega(const GSkyPixel& pixel) const; + double solidangle(const int& index) const; + double solidangle(const GSkyPixel& pixel) const; bool contains(const GSkyDir& dir) const; bool contains(const GSkyPixel& pixel) const; const GSkyProjection* projection(void) const; diff --git a/pyext/GWcs.i b/pyext/GWcs.i index 2f63c29..4adac67 100644 --- a/pyext/GWcs.i +++ b/pyext/GWcs.i @@ -56,7 +56,7 @@ public: virtual int size(void) const; virtual void read(const GFitsHDU& hdu); virtual void write(GFitsHDU& hdu) const; - virtual double omega(const GSkyPixel& pixel) const; + virtual double solidangle(const GSkyPixel& pixel) const; virtual GSkyDir pix2dir(const GSkyPixel& pixel) const; virtual GSkyPixel dir2pix(const GSkyDir& dir) const; diff --git a/src/model/GModelSpatialDiffuseCube.cpp b/src/model/GModelSpatialDiffuseCube.cpp index 06a056c..7672ba1 100644 --- a/src/model/GModelSpatialDiffuseCube.cpp +++ b/src/model/GModelSpatialDiffuseCube.cpp @@ -781,7 +781,7 @@ void GModelSpatialDiffuseCube::set_mc_cone(const GSkyDir& centre, // that corresponds to the pixel's solid angle. For security, // the radius is enhanced by 50%. double pixel_radius = - std::acos(1.0 - m_cube.omega(k)/gammalib::twopi) * + std::acos(1.0 - m_cube.solidangle(k)/gammalib::twopi) * gammalib::rad2deg * 1.5; // Add up flux with simulation cone radius + effective pixel @@ -793,7 +793,7 @@ void GModelSpatialDiffuseCube::set_mc_cone(const GSkyDir& centre, // simulated event is contained in the simulation cone. double distance = centre.dist_deg(m_cube.pix2dir(k)); if (distance <= radius+pixel_radius) { - double flux = m_cube(k,i) * m_cube.omega(k); + double flux = m_cube(k,i) * m_cube.solidangle(k); if (flux > 0.0) { total_flux += flux; } diff --git a/src/model/GModelSpatialDiffuseMap.cpp b/src/model/GModelSpatialDiffuseMap.cpp index 890bdc8..a33c4f8 100644 --- a/src/model/GModelSpatialDiffuseMap.cpp +++ b/src/model/GModelSpatialDiffuseMap.cpp @@ -640,7 +640,7 @@ void GModelSpatialDiffuseMap::prepare_map(void) // zero intensity in the skymap. double sum = 0.0; for (int i = 0; i < npix; ++i) { - double flux = m_map(i) * m_map.omega(i); + double flux = m_map(i) * m_map.solidangle(i); if (flux < 0.0) { m_map(i) = 0.0; flux = 0.0; @@ -665,7 +665,7 @@ void GModelSpatialDiffuseMap::prepare_map(void) #if defined(G_DEBUG_PREPARE) double sum_control = 0.0; for (int i = 0; i < npix; ++i) { - double flux = m_map(i) * m_map.omega(i); + double flux = m_map(i) * m_map.solidangle(i); if (flux >= 0.0) { sum_control += flux; } diff --git a/src/sky/GHealpix.cpp b/src/sky/GHealpix.cpp index 066c5de..a48007e 100644 --- a/src/sky/GHealpix.cpp +++ b/src/sky/GHealpix.cpp @@ -343,23 +343,6 @@ void GHealpix::write(GFitsHDU& hdu) const /***********************************************************************//** - * @brief Returns solid angle of pixel - * - * @param[in] pixel Sky pixel. - * @return Solid angle of pixel. - * - * Returns the solid angle of the specified @p pixel. Note that HEALPix - * pixels have all the same solid angle, hence the @p pixel argument is in - * fact not used by the method. - ***************************************************************************/ -double GHealpix::omega(const GSkyPixel& pixel) const -{ - // Return solid angle - return m_omega; -} - - -/***********************************************************************//** * @brief Returns sky direction of pixel * * @param[in] pixel Sky map pixel. diff --git a/src/sky/GSkymap.cpp b/src/sky/GSkymap.cpp index 071bf78..753df3c 100644 --- a/src/sky/GSkymap.cpp +++ b/src/sky/GSkymap.cpp @@ -50,8 +50,8 @@ #define G_PIX2DIR "GSkymap::pix2dir(GSkyPixel&)" #define G_DIR2INX "GSkymap::dir2inx(GSkyDir&)" #define G_DIR2PIX "GSkymap::dir2pix(GSkyDir&)" -#define G_OMEGA1 "GSkymap::omega(int&)" -#define G_OMEGA2 "GSkymap::omega(GSkyPixel&)" +#define G_SOLIDANGLE1 "GSkymap::solidangle(int&)" +#define G_SOLIDANGLE2 "GSkymap::solidangle(GSkyPixel&)" #define G_READ "GSkymap::read(const GFitsHDU&)" #define G_SET_WCS "GSkymap::set_wcs(std::string&, std::string&, double&,"\ " double&, double&, double&, double&, double&,"\ @@ -761,19 +761,19 @@ GSkyPixel GSkymap::dir2pix(const GSkyDir& dir) const * * Returns the solid angle of the pixel with the specified @p index. ***************************************************************************/ -double GSkymap::omega(const int& index) const +double GSkymap::solidangle(const int& index) const { // Throw error if WCS is not valid if (m_proj == NULL) { std::string msg = "Sky projection has not been defined."; - throw GException::invalid_value(G_OMEGA1, msg); + throw GException::invalid_value(G_SOLIDANGLE1, msg); } // Determine solid angle from pixel index. - double omega = m_proj->omega(inx2pix(index)); + double solidangle = m_proj->solidangle(inx2pix(index)); // Return solid angle - return omega; + return solidangle; } @@ -788,27 +788,27 @@ double GSkymap::omega(const int& index) const * * Returns the solid angle of the specified sky map @p pixel. ***************************************************************************/ -double GSkymap::omega(const GSkyPixel& pixel) const +double GSkymap::solidangle(const GSkyPixel& pixel) const { // Throw error if WCS is not valid if (m_proj == NULL) { std::string msg = "Sky projection has not been defined."; - throw GException::invalid_value(G_OMEGA2, msg); + throw GException::invalid_value(G_SOLIDANGLE2, msg); } // Initialise solid angle - double omega = 0.0; + double solidangle = 0.0; // If pixel size matches the projection size then perform a straight // forward solid angle determination if (m_proj->size() == pixel.size()) { - omega = m_proj->omega(pixel); + solidangle = m_proj->solidangle(pixel); } // ... otherwise, if we have a 2D projection but a 1D pixel then // interpret the pixel as the linear index in the pixel array else if (m_proj->size() == 2) { - omega = m_proj->omega(GSkyPixel(inx2pix(int(pixel)))); + solidangle = m_proj->solidangle(GSkyPixel(inx2pix(int(pixel)))); } // ... otherwise we have a 1D projection but a 2D pixel. There is @@ -819,11 +819,11 @@ double GSkymap::omega(const GSkyPixel& pixel) const " the 1-dimensional sky projection \""+ m_proj->name()+"\"\n" "Please specify a 1-dimensional sky map pixel."; - throw GException::invalid_argument(G_OMEGA2, msg); + throw GException::invalid_argument(G_SOLIDANGLE2, msg); } // Return solid angle - return omega; + return solidangle; } diff --git a/src/sky/GWcs.cpp b/src/sky/GWcs.cpp index 4e8e1d7..df89d1b 100644 --- a/src/sky/GWcs.cpp +++ b/src/sky/GWcs.cpp @@ -37,7 +37,6 @@ /* __ Method name definitions ____________________________________________ */ #define G_READ "GWcs::read(GFitsHDU&)" -#define G_OMEGA "GWcs::omega(int&)" #define G_PIX2DIR "GWcs::pix2dir(int&)" #define G_DIR2PIX "GWcs::dir2pix(GSkyDir&)" #define G_CRVAL "GWcs::crval(int&)" @@ -437,7 +436,7 @@ void GWcs::write(GFitsHDU& hdu) const * rotated sky maps. Something more intelligent should be implemented in * the future. ***************************************************************************/ -double GWcs::omega(const GSkyPixel& pixel) const +double GWcs::solidangle(const GSkyPixel& pixel) const { // Get the sky directions of the 6 points GSkyDir dir1 = pix2dir(GSkyPixel(pixel.x()-0.5, pixel.y()-0.5)); -- libgit2 0.21.4