GammaLib
2.0.0
|
Sky map pixel class. More...
#include <GSkyPixel.hpp>
Public Member Functions | |
GSkyPixel (void) | |
Void constructor. More... | |
GSkyPixel (const int &index) | |
1D pixel constructor (integer version) More... | |
GSkyPixel (const double &index) | |
1D pixel constructor (double precision version) More... | |
GSkyPixel (const int &x, const int &y) | |
2D pixel constructor (integer version) More... | |
GSkyPixel (const double &x, const double &y) | |
2D pixel constructor (double precision version) More... | |
GSkyPixel (const GSkyPixel &pixel) | |
Copy constructor. More... | |
virtual | ~GSkyPixel (void) |
Destructor. More... | |
GSkyPixel & | operator= (const GSkyPixel &pixel) |
Assignment operator. More... | |
operator int () const | |
To integer type conversion. More... | |
operator double () const | |
To double type conversion. More... | |
void | clear (void) |
Clear instance. More... | |
GSkyPixel * | clone (void) const |
Clone sky map pixel. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Return pixel dimension. More... | |
bool | is_1D (void) const |
Check if pixel is 1D. More... | |
bool | is_2D (void) const |
Check if pixel is 2D. More... | |
void | index (const double &index) |
Set sky map pixel index. More... | |
void | x (const double &x) |
Set x value of sky map pixel. More... | |
void | y (const double &y) |
Set y value of sky map pixel. More... | |
void | xy (const double &x, const double &y) |
Set x and y value of sky map pixel. More... | |
const double & | index (void) const |
Return sky map pixel index. More... | |
const double & | x (void) const |
Return x value of sky map pixel. More... | |
const double & | y (void) const |
Return y value of sky pixel. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print pixel. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Private Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GSkyPixel &pixel) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Private Attributes | |
int | m_size |
Pixel dimension (0=undefined, 1=1D, 2=2D) More... | |
double | m_x |
X index. More... | |
double | m_y |
Y index. More... | |
Friends | |
bool | operator== (const GSkyPixel &a, const GSkyPixel &b) |
Equality operator. More... | |
bool | operator!= (const GSkyPixel &a, const GSkyPixel &b) |
Inqquality operator. More... | |
Sky map pixel class.
This class implements a sky map pixel. A sky map pixel may be either 1-dimensional (1D) or 2-dimensional (2D). 1D pixels are set and retrieved using the index() method. The X and Y components of 2D pixels are set and retrieved using the x() and y() methods. The xy() method allows setting of both the X and Y components simultaneously.
There are integer and double precision variants for 1D and 2D pixel constructors:
GSkyPixel int_1D_pixel(1); // Set index to 1 GSkyPixel double_1D_pixel(1.0); // Set index to 1.0 GSkyPixel int_2D_pixel(1,2); // Set (x,y)=(1,2) GSkyPixel double_2D_pixel(1.0,2.0); // Set (x,y)=(1.0,2.0)
The 1D constructors allow for automatic type conversion:
GSkyPixel int_1D_pixel = 1; // Set index to 1 GSkyPixel double_1D_pixel = 1.0; // Set index to 1.0
Note that the class also provides conversion operators to int and double allowing to write:
int index = GSkyPixel(1); // Retrieve integer index double dindex = GSkyPixel(1.0); // Retrieve double precision index
The dimensionality of a pixel is checked using the is_1D() and is_2D() methods. The size() method returns 1 for 1D pixels and 2 for 2D pixels. If a pixel is not initialised, e.g.
GSkyPixel pixel; // Not initialised
the is_1D() and is_2D() methods return false and the size() method returns 0.
Definition at line 74 of file GSkyPixel.hpp.
GSkyPixel::GSkyPixel | ( | void | ) |
Void constructor.
Definition at line 57 of file GSkyPixel.cpp.
References init_members().
Referenced by clone().
GSkyPixel::GSkyPixel | ( | const int & | index | ) |
1D pixel constructor (integer version)
[in] | index | Pixel index. |
Definition at line 72 of file GSkyPixel.cpp.
GSkyPixel::GSkyPixel | ( | const double & | index | ) |
GSkyPixel::GSkyPixel | ( | const int & | x, |
const int & | y | ||
) |
2D pixel constructor (integer version)
[in] | x | Pixel X index. |
[in] | y | Pixel Y index. |
Definition at line 107 of file GSkyPixel.cpp.
GSkyPixel::GSkyPixel | ( | const double & | x, |
const double & | y | ||
) |
GSkyPixel::GSkyPixel | ( | const GSkyPixel & | pixel | ) |
Copy constructor.
[in] | pixel | Sky pixel. |
Definition at line 142 of file GSkyPixel.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 130 of file GSkyPixel.hpp.
|
virtual |
Clear instance.
Set sky map pixel to a clean initial state.
Implements GBase.
Definition at line 259 of file GSkyPixel.cpp.
References free_members(), and init_members().
Referenced by GWcs::init_members().
|
virtual |
Clone sky map pixel.
Returns a pointer to a deep copy of a sky map pixel.
Implements GBase.
Definition at line 279 of file GSkyPixel.cpp.
References GSkyPixel().
|
private |
Copy class members.
[in] | pixel | Sky pixel. |
Definition at line 345 of file GSkyPixel.cpp.
References m_size, m_x, and m_y.
Referenced by GSkyPixel(), and operator=().
|
private |
Delete class members.
Definition at line 360 of file GSkyPixel.cpp.
Referenced by clear(), operator=(), and ~GSkyPixel().
|
inline |
Set sky map pixel index.
[in] | index | Pixel index. |
Sets the 1D pixel index.
Definition at line 183 of file GSkyPixel.hpp.
References index(), m_size, m_x, and m_y.
Referenced by GSkyMap::contains(), and GSkyMap::inx2pix().
|
inline |
Return sky map pixel index.
Returns the 1D index of a sky map pixel. The method does not check whether the pixel is indeed a 1D pixel.
Definition at line 256 of file GSkyPixel.hpp.
References m_x.
Referenced by GSkyPixel(), and index().
|
private |
Initialise class members.
Definition at line 328 of file GSkyPixel.cpp.
References m_size, m_x, and m_y.
Referenced by clear(), GSkyPixel(), and operator=().
|
inline |
Check if pixel is 1D.
Definition at line 157 of file GSkyPixel.hpp.
References m_size.
Referenced by GHealpix::boundaries(), GSkyMap::contains(), GHealpix::neighbours(), GHealpix::pix2dir(), GSkyMap::pix2inx(), and print().
|
inline |
Check if pixel is 2D.
Definition at line 169 of file GSkyPixel.hpp.
References m_size.
Referenced by GSkyMap::contains(), GSkyMap::pix2inx(), and print().
GSkyPixel::operator double | ( | ) | const |
To double type conversion.
Converts the sky map pixel into a double precision value.
Definition at line 233 of file GSkyPixel.cpp.
References G_DOUBLE.
GSkyPixel::operator int | ( | ) | const |
To integer type conversion.
Converts the sky map pixel into an integer value.
Definition at line 208 of file GSkyPixel.cpp.
References G_INT.
Assignment operator.
[in] | pixel | Sky map pixel. |
Definition at line 180 of file GSkyPixel.cpp.
References copy_members(), free_members(), and init_members().
Print pixel.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GBase.
Definition at line 292 of file GSkyPixel.cpp.
References is_1D(), is_2D(), SILENT, gammalib::str(), x(), and y().
Referenced by GHealpix::boundaries(), GHealpix::neighbours(), GHealpix::pix2dir(), GSkyMap::pix2dir(), and GSkyMap::solidangle().
|
inline |
Return pixel dimension.
Returns the pixel dimension. If the pixel is not defined the method returns 0.
Definition at line 145 of file GSkyPixel.hpp.
References m_size.
Referenced by GSkyMap::pix2dir(), and GSkyMap::solidangle().
|
inline |
Set x value of sky map pixel.
[in] | x | X pixel index. |
Sets the X value of a 2D pixel index. The method does not alter the Y pixel index.
Definition at line 204 of file GSkyPixel.hpp.
References m_size, m_x, and x().
Referenced by GSkyRegionRectangle::contains(), GSkyMap::contains(), GSkyMap::extract(), GSkyMap::flux(), GSkyMap::inx2pix(), GSkyRegionRectangle::local_to_dir(), GSkyMap::operator()(), GSkyRegionRectangle::overlaps(), GSkyMap::overlaps_circle(), GWcs::pix2dir(), GSkyMap::pix2inx(), GSkyMap::region_circle(), and GWcs::solidangle().
|
inline |
Return x value of sky map pixel.
Returns the X value of a 2D sky map pixel. The method does not check whether the pixel is indeed a 2D pixel.
Definition at line 271 of file GSkyPixel.hpp.
References m_x.
Referenced by GSkyPixel(), print(), x(), and xy().
|
inline |
Set x and y value of sky map pixel.
[in] | x | X pixel index. |
[in] | y | Y pixel index. |
Sets the X and Y value of a 2D pixel index.
Definition at line 238 of file GSkyPixel.hpp.
References m_size, m_x, m_y, x(), and y().
Referenced by GWcs::dir2pix().
|
inline |
Set y value of sky map pixel.
[in] | y | Y pixel index. |
Sets the Y value of a 2D pixel index. The method does not alter the X pixel index.
Definition at line 221 of file GSkyPixel.hpp.
References m_size, m_y, and y().
Referenced by GSkyRegionRectangle::contains(), GSkyMap::contains(), GSkyMap::extract(), GSkyMap::flux(), GSkyMap::inx2pix(), GSkyRegionRectangle::local_to_dir(), GSkyMap::operator()(), GSkyRegionRectangle::overlaps(), GSkyMap::overlaps_circle(), GWcs::pix2dir(), GSkyMap::pix2inx(), GSkyMap::region_circle(), and GWcs::solidangle().
|
inline |
Return y value of sky pixel.
Returns the Y value of a 2D sky map pixel. The method does not check whether the pixel is indeed a 2D pixel.
Definition at line 286 of file GSkyPixel.hpp.
References m_y.
Referenced by GSkyPixel(), print(), xy(), and y().
Inqquality operator.
[in] | a | First sky pixel. |
[in] | b | Second sky pixel. |
Definition at line 314 of file GSkyPixel.hpp.
Equality operator.
[in] | a | First sky pixel. |
[in] | b | Second sky pixel. |
Definition at line 300 of file GSkyPixel.hpp.
|
private |
Pixel dimension (0=undefined, 1=1D, 2=2D)
Definition at line 118 of file GSkyPixel.hpp.
Referenced by copy_members(), GSkyPixel(), index(), init_members(), is_1D(), is_2D(), operator!=(), operator==(), size(), x(), xy(), and y().
|
private |
X index.
Definition at line 119 of file GSkyPixel.hpp.
Referenced by copy_members(), GSkyPixel(), index(), init_members(), operator!=(), operator==(), x(), and xy().
|
private |
Y index.
Definition at line 120 of file GSkyPixel.hpp.
Referenced by copy_members(), GSkyPixel(), index(), init_members(), operator!=(), operator==(), xy(), and y().