GammaLib 2.1.0
Loading...
Searching...
No Matches
GSkyPixel Class Reference

Sky map pixel class. More...

#include <GSkyPixel.hpp>

Inheritance diagram for GSkyPixel:
GBase

Public Member Functions

 GSkyPixel (void)
 Void constructor.
 
 GSkyPixel (const int &index)
 1D pixel constructor (integer version)
 
 GSkyPixel (const double &index)
 1D pixel constructor (double precision version)
 
 GSkyPixel (const int &x, const int &y)
 2D pixel constructor (integer version)
 
 GSkyPixel (const double &x, const double &y)
 2D pixel constructor (double precision version)
 
 GSkyPixel (const GSkyPixel &pixel)
 Copy constructor.
 
virtual ~GSkyPixel (void)
 Destructor.
 
GSkyPixel & operator= (const GSkyPixel &pixel)
 Assignment operator.
 
 operator int () const
 To integer type conversion.
 
 operator double () const
 To double type conversion.
 
void clear (void)
 Clear instance.
 
GSkyPixel * clone (void) const
 Clone sky map pixel.
 
std::string classname (void) const
 Return class name.
 
int size (void) const
 Return pixel dimension.
 
bool is_1D (void) const
 Check if pixel is 1D.
 
bool is_2D (void) const
 Check if pixel is 2D.
 
void index (const double &index)
 Set sky map pixel index.
 
void x (const double &x)
 Set x value of sky map pixel.
 
void y (const double &y)
 Set y value of sky map pixel.
 
void xy (const double &x, const double &y)
 Set x and y value of sky map pixel.
 
const double & index (void) const
 Return sky map pixel index.
 
const double & x (void) const
 Return x value of sky map pixel.
 
const double & y (void) const
 Return y value of sky pixel.
 
std::string print (const GChatter &chatter=NORMAL) const
 Print pixel.
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor.
 

Private Member Functions

void init_members (void)
 Initialise class members.
 
void copy_members (const GSkyPixel &pixel)
 Copy class members.
 
void free_members (void)
 Delete class members.
 

Private Attributes

int m_size
 Pixel dimension (0=undefined, 1=1D, 2=2D)
 
double m_x
 X index.
 
double m_y
 Y index.
 

Friends

bool operator== (const GSkyPixel &a, const GSkyPixel &b)
 Equality operator.
 
bool operator!= (const GSkyPixel &a, const GSkyPixel &b)
 Inqquality operator.
 

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() [1/6]

GSkyPixel::GSkyPixel ( void )

Void constructor.

Definition at line 57 of file GSkyPixel.cpp.

References init_members().

Referenced by clone().

◆ GSkyPixel() [2/6]

GSkyPixel::GSkyPixel ( const int & index)

1D pixel constructor (integer version)

Parameters
[in]indexPixel index.

Definition at line 72 of file GSkyPixel.cpp.

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

◆ GSkyPixel() [3/6]

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() [4/6]

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, m_y, x(), and y().

◆ GSkyPixel() [5/6]

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() [6/6]

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::~GSkyPixel ( void )
virtual

Destructor.

Definition at line 158 of file GSkyPixel.cpp.

References free_members().

Member Function Documentation

◆ classname()

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.

◆ clear()

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

◆ clone()

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

◆ copy_members()

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

◆ free_members()

void GSkyPixel::free_members ( void )
private

Delete class members.

Definition at line 360 of file GSkyPixel.cpp.

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

◆ index() [1/2]

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

◆ index() [2/2]

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(), GSkyPixel(), and index().

◆ init_members()

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(), GSkyPixel(), and operator=().

◆ is_1D()

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

◆ is_2D()

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

◆ operator double()

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.

◆ operator int()

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.

◆ operator=()

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

◆ print()

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

◆ size()

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

◆ x() [1/2]

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

◆ x() [2/2]

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(), GSkyPixel(), print(), x(), and xy().

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

◆ y() [1/2]

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

◆ y() [2/2]

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(), GSkyPixel(), print(), xy(), and y().

Friends And Related Symbol Documentation

◆ operator!=

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.

◆ operator==

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

◆ m_size

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(), GSkyPixel(), GSkyPixel(), GSkyPixel(), index(), init_members(), is_1D(), is_2D(), size(), x(), xy(), and y().

◆ m_x

double GSkyPixel::m_x
private

X index.

Definition at line 119 of file GSkyPixel.hpp.

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

◆ m_y

double GSkyPixel::m_y
private

Y index.

Definition at line 120 of file GSkyPixel.hpp.

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


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