GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSkyPixel Class Reference

Sky map pixel class. More...

#include <GSkyPixel.hpp>

Inheritance diagram for GSkyPixel:
GBase

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...
 
GSkyPixeloperator= (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...
 
GSkyPixelclone (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...
 

Detailed Description

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.

Constructor & Destructor Documentation

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)

Parameters
[in]indexPixel index.

Definition at line 72 of file GSkyPixel.cpp.

References m_size, m_x, and m_y.

GSkyPixel::GSkyPixel ( const double &  index)

1D pixel constructor (double precision version)

Parameters
[in]indexPixel index.

Definition at line 89 of file GSkyPixel.cpp.

References index(), m_size, m_x, and m_y.

GSkyPixel::GSkyPixel ( const int &  x,
const int &  y 
)

2D pixel constructor (integer version)

Parameters
[in]xPixel X index.
[in]yPixel Y index.

Definition at line 107 of file GSkyPixel.cpp.

References m_size, m_x, and m_y.

GSkyPixel::GSkyPixel ( const double &  x,
const double &  y 
)

2D pixel constructor (double precision version)

Parameters
[in]xPixel X index.
[in]yPixel Y index.

Definition at line 125 of file GSkyPixel.cpp.

References m_size, m_x, m_y, x(), and y().

GSkyPixel::GSkyPixel ( const GSkyPixel pixel)

Copy constructor.

Parameters
[in]pixelSky pixel.

Definition at line 142 of file GSkyPixel.cpp.

References copy_members(), and init_members().

GSkyPixel::~GSkyPixel ( void  )
virtual

Destructor.

Definition at line 158 of file GSkyPixel.cpp.

References free_members().

Member Function Documentation

std::string GSkyPixel::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GSkyPixel").

Implements GBase.

Definition at line 130 of file GSkyPixel.hpp.

void GSkyPixel::clear ( void  )
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().

GSkyPixel * GSkyPixel::clone ( void  ) const
virtual

Clone sky map pixel.

Returns
Pointer to deep copy of 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().

void GSkyPixel::copy_members ( const GSkyPixel pixel)
private

Copy class members.

Parameters
[in]pixelSky pixel.

Definition at line 345 of file GSkyPixel.cpp.

References m_size, m_x, and m_y.

Referenced by GSkyPixel(), and operator=().

void GSkyPixel::free_members ( void  )
private

Delete class members.

Definition at line 360 of file GSkyPixel.cpp.

Referenced by clear(), operator=(), and ~GSkyPixel().

void GSkyPixel::index ( const double &  index)
inline

Set sky map pixel index.

Parameters
[in]indexPixel 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().

const double & GSkyPixel::index ( void  ) const
inline

Return sky map pixel index.

Returns
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().

void GSkyPixel::init_members ( void  )
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=().

bool GSkyPixel::is_1D ( void  ) const
inline

Check if pixel is 1D.

Returns
True 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().

bool GSkyPixel::is_2D ( void  ) const
inline

Check if pixel is 2D.

Returns
True 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.

Returns
Pixel index.

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.

Returns
Pixel index.

Converts the sky map pixel into an integer value.

Definition at line 208 of file GSkyPixel.cpp.

References G_INT.

GSkyPixel & GSkyPixel::operator= ( const GSkyPixel pixel)

Assignment operator.

Parameters
[in]pixelSky map pixel.
Returns
Sky map pixel.

Definition at line 180 of file GSkyPixel.cpp.

References copy_members(), free_members(), and init_members().

std::string GSkyPixel::print ( const GChatter chatter = NORMAL) const
virtual

Print pixel.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing pixel information.

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().

int GSkyPixel::size ( void  ) const
inline

Return pixel dimension.

Returns
Pixel dimension [0,1,2].

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().

void GSkyPixel::x ( const double &  x)
inline

Set x value of sky map pixel.

Parameters
[in]xX 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().

const double & GSkyPixel::x ( void  ) const
inline

Return x value of sky map pixel.

Returns
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().

void GSkyPixel::xy ( const double &  x,
const double &  y 
)
inline

Set x and y value of sky map pixel.

Parameters
[in]xX pixel index.
[in]yY 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().

void GSkyPixel::y ( const double &  y)
inline

Set y value of sky map pixel.

Parameters
[in]yY 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().

const double & GSkyPixel::y ( void  ) const
inline

Return y value of sky pixel.

Returns
Y value of sky map 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().

Friends And Related Function Documentation

bool operator!= ( const GSkyPixel a,
const GSkyPixel b 
)
friend

Inqquality operator.

Parameters
[in]aFirst sky pixel.
[in]bSecond sky pixel.
Returns
True if first and second sky pixels are different.

Definition at line 314 of file GSkyPixel.hpp.

bool operator== ( const GSkyPixel a,
const GSkyPixel b 
)
friend

Equality operator.

Parameters
[in]aFirst sky pixel.
[in]bSecond sky pixel.
Returns
True if first and second sky pixels are identical.

Definition at line 300 of file GSkyPixel.hpp.

Member Data Documentation

int GSkyPixel::m_size
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().

double GSkyPixel::m_x
private

X index.

Definition at line 119 of file GSkyPixel.hpp.

Referenced by copy_members(), GSkyPixel(), index(), init_members(), operator!=(), operator==(), x(), and xy().

double GSkyPixel::m_y
private

Y index.

Definition at line 120 of file GSkyPixel.hpp.

Referenced by copy_members(), GSkyPixel(), index(), init_members(), operator!=(), operator==(), xy(), and y().


The documentation for this class was generated from the following files: