GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSkyRegionMap Class Reference

Interface for a sky region map. More...

#include <GSkyRegionMap.hpp>

Inheritance diagram for GSkyRegionMap:
GSkyRegion GBase

Public Member Functions

 GSkyRegionMap (void)
 Void constructor. More...
 
 GSkyRegionMap (const GFilename &filename)
 FITS filename constructor. More...
 
 GSkyRegionMap (const GSkyMap &map)
 Sky map constructor. More...
 
 GSkyRegionMap (const GSkyRegion *region)
 Region conversion constructor. More...
 
 GSkyRegionMap (const GSkyRegionMap &region)
 Copy constructor. More...
 
virtual ~GSkyRegionMap (void)
 Destructor. More...
 
GSkyRegionMapoperator= (const GSkyRegionMap &region)
 Assignment operator. More...
 
void clear (void)
 Clear instance. More...
 
GSkyRegionMapclone (void) const
 Clone sky region map. More...
 
std::string classname (void) const
 Return class name. More...
 
void read (const std::string &line)
 Create region from a string in DS9 format. More...
 
std::string write (void) const
 Write string describing region in DS9 region format. More...
 
bool contains (const GSkyDir &dir) const
 Check if a given direction is contained in this region. More...
 
bool contains (const GSkyRegion &reg) const
 Checks if a given region is fully contained within this region. More...
 
bool overlaps (const GSkyRegion &reg) const
 Checks if a given region is overlapping with this region. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print region description. More...
 
void load (const GFilename &filename)
 Load region map from FITS file. More...
 
void map (const GSkyMap &map)
 Set sky map. More...
 
const GSkyMapmap (void) const
 Return sky map. More...
 
const std::vector< int > & nonzero_indices (void) const
 Get non-zero index vector. More...
 
- Public Member Functions inherited from GSkyRegion
 GSkyRegion (void)
 Void constructor. More...
 
 GSkyRegion (const GSkyRegion &region)
 Copy constructor. More...
 
virtual ~GSkyRegion (void)
 Destructor. More...
 
virtual GSkyRegionoperator= (const GSkyRegion &region)
 Assignment operator. More...
 
const std::string & type (void) const
 Return region type. More...
 
const std::string & name (void) const
 Return region name. More...
 
const double & solidangle (void) const
 Return solid angle of region. More...
 
void type (const std::string &type)
 Set region type. More...
 
void name (const std::string &name)
 Set region name. More...
 
void solidangle (const double &solidangle)
 Set solid angle of region. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GSkyRegionMap &region)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void compute_solid_angle (void)
 Compute solid angle. More...
 
void set_nonzero_indices (void)
 Create an array of non-zero pixel indices. More...
 
void set_region_circle (const GSkyRegionCircle *circle)
 Set region map from region circle. More...
 
- Protected Member Functions inherited from GSkyRegion
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GSkyRegion &region)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

GSkyMap m_map
 The region map. More...
 
std::vector< int > m_nonzero_indices
 Vector of non-zero pixel indices. More...
 
- Protected Attributes inherited from GSkyRegion
std::string m_type
 Type of the region (circle, rectangle,...) More...
 
std::string m_name
 Name of the region. More...
 
double m_solid
 Solid angle subtended by the region (sr) More...
 

Detailed Description

Interface for a sky region map.

This class provides an implementation for a sky region defined by a sky map. The map is provided as a FITS file. Pixels with non-zero values are within the region, pixels with zero values outside the region.

Definition at line 51 of file GSkyRegionMap.hpp.

Constructor & Destructor Documentation

GSkyRegionMap::GSkyRegionMap ( void  )

Void constructor.

Definition at line 60 of file GSkyRegionMap.cpp.

References init_members().

Referenced by clone().

GSkyRegionMap::GSkyRegionMap ( const GFilename filename)
explicit

FITS filename constructor.

Parameters
[in]filenameFITS file.

Constructs region from a FITS file.

Definition at line 77 of file GSkyRegionMap.cpp.

References init_members(), and load().

GSkyRegionMap::GSkyRegionMap ( const GSkyMap map)
explicit

Sky map constructor.

Parameters
[in]mapSky map.

Definition at line 95 of file GSkyRegionMap.cpp.

References init_members(), and map().

GSkyRegionMap::GSkyRegionMap ( const GSkyRegion region)
explicit

Region conversion constructor.

Parameters
[in]regionPointer to sky region.

Constructs a sky region map from any region type.

Definition at line 115 of file GSkyRegionMap.cpp.

References copy_members(), init_members(), map(), and set_region_circle().

GSkyRegionMap::GSkyRegionMap ( const GSkyRegionMap region)

Copy constructor.

Parameters
[in]regionSky region map.

Definition at line 145 of file GSkyRegionMap.cpp.

References copy_members(), and init_members().

GSkyRegionMap::~GSkyRegionMap ( void  )
virtual

Destructor.

Definition at line 161 of file GSkyRegionMap.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GSkyRegion.

Definition at line 103 of file GSkyRegionMap.hpp.

void GSkyRegionMap::clear ( void  )
virtual

Clear instance.

Implements GSkyRegion.

Definition at line 213 of file GSkyRegionMap.cpp.

References free_members(), GSkyRegion::free_members(), init_members(), and GSkyRegion::init_members().

GSkyRegionMap * GSkyRegionMap::clone ( void  ) const
virtual

Clone sky region map.

Returns
Deep copy to sky region map.

Implements GSkyRegion.

Definition at line 233 of file GSkyRegionMap.cpp.

References GSkyRegionMap().

void GSkyRegionMap::compute_solid_angle ( void  )
protected

Compute solid angle.

Definition at line 533 of file GSkyRegionMap.cpp.

References m_map, m_nonzero_indices, GSkyRegion::m_solid, and GSkyMap::solidangle().

Referenced by copy_members(), load(), and map().

bool GSkyRegionMap::contains ( const GSkyDir dir) const
virtual

Check if a given direction is contained in this region.

Parameters
[in]dirSky direction.
Returns
True if sky direction is in region, false otherwise.

Checks if sky direction is contained in the region map.

Implements GSkyRegion.

Definition at line 361 of file GSkyRegionMap.cpp.

References GSkyMap::contains(), GSkyMap::dir2inx(), and m_map.

Referenced by contains().

bool GSkyRegionMap::contains ( const GSkyRegion reg) const
virtual

Checks if a given region is fully contained within this region.

Parameters
[in]regSky region.
Returns
True if the region is contained within this region, false otherwise.
Exceptions
GException::feature_not_implementedSpecified sky region type not supported by method.

Implements GSkyRegion.

Definition at line 392 of file GSkyRegionMap.cpp.

References GSkyRegionCircle::centre(), gammalib::centre(), contains(), G_CONTAINS, GSkyMap::inx2dir(), map(), nonzero_indices(), GSkyRegionCircle::radius(), GSkyDir::rotate_deg(), and GSkyRegion::type().

void GSkyRegionMap::copy_members ( const GSkyRegionMap map)
protected

Copy class members.

Parameters
[in]mapSky region map.

Definition at line 506 of file GSkyRegionMap.cpp.

References compute_solid_angle(), m_map, and m_nonzero_indices.

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

void GSkyRegionMap::free_members ( void  )
protected

Delete class members.

Definition at line 523 of file GSkyRegionMap.cpp.

Referenced by clear(), load(), operator=(), and ~GSkyRegionMap().

void GSkyRegionMap::init_members ( void  )
protected

Initialise class members.

Definition at line 487 of file GSkyRegionMap.cpp.

References GSkyMap::clear(), m_map, m_nonzero_indices, and GSkyRegion::m_type.

Referenced by clear(), GSkyRegionMap(), load(), and operator=().

void GSkyRegionMap::load ( const GFilename filename)

Load region map from FITS file.

Parameters
[in]filenameFITS file name.

Definition at line 268 of file GSkyRegionMap.cpp.

References compute_solid_angle(), free_members(), init_members(), GSkyMap::load(), m_map, and set_nonzero_indices().

Referenced by GSkyRegionMap().

void GSkyRegionMap::map ( const GSkyMap map)
const GSkyMap & GSkyRegionMap::map ( void  ) const
inline

Return sky map.

Returns
region sky map.

Definition at line 115 of file GSkyRegionMap.hpp.

References m_map.

Referenced by GSkyRegionMap(), map(), and set_region_circle().

const std::vector< int > & GSkyRegionMap::nonzero_indices ( void  ) const
inline

Get non-zero index vector.

Returns
Reference to non-zero pixel indices vector.

Definition at line 127 of file GSkyRegionMap.hpp.

References m_nonzero_indices.

Referenced by GCTAOnOffObservation::compute_alpha(), GCTAOnOffObservation::compute_arf(), GCTAOnOffObservation::compute_arf_cut(), GCTAOnOffObservation::compute_bgd(), GCTAOnOffObservation::compute_rmf(), and contains().

GSkyRegionMap & GSkyRegionMap::operator= ( const GSkyRegionMap region)

Assignment operator.

Parameters
[in]regionSky region map.
Returns
Sky region map.

Definition at line 183 of file GSkyRegionMap.cpp.

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

bool GSkyRegionMap::overlaps ( const GSkyRegion reg) const
virtual

Checks if a given region is overlapping with this region.

Parameters
[in]regSky region.
Returns
True if the region is overlapping, false otherwise.

Implements GSkyRegion.

Definition at line 459 of file GSkyRegionMap.cpp.

References GSkyRegion::contains(), GSkyMap::inx2dir(), m_map, and m_nonzero_indices.

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

Print region description.

Parameters
[in]chatterChattiness.
Returns
String containing region information.

Implements GSkyRegion.

Definition at line 332 of file GSkyRegionMap.cpp.

References m_map, GSkyMap::print(), and SILENT.

void GSkyRegionMap::read ( const std::string &  line)
virtual

Create region from a string in DS9 format.

Parameters
[in]lineString describing region in DS9 region format.

Empty implementation of a virtual function because map is not supported as DS9 region.

Todo:
Translate any DS9 region into a map.

Implements GSkyRegion.

Definition at line 300 of file GSkyRegionMap.cpp.

void GSkyRegionMap::set_nonzero_indices ( void  )
protected

Create an array of non-zero pixel indices.

Definition at line 551 of file GSkyRegionMap.cpp.

References m_map, m_nonzero_indices, and GSkyMap::npix().

Referenced by load(), and map().

void GSkyRegionMap::set_region_circle ( const GSkyRegionCircle circle)
protected

Set region map from region circle.

Parameters
[in]circleRegion circle

Sets a region map from a region circle. The method allocates a sky map with a default resolution of 1/20 of the circle radius. In any case, the sky map resolution is comprised within [0.0002, 0.1] degrees. The default size of the sky map is 2.5 times the circle radius, and in any case, at least 10 sky map pixels will be allocated. The sky map will be in celestial coordinates and TAN projection.

Definition at line 580 of file GSkyRegionMap.cpp.

References GSkyRegionCircle::centre(), GSkyRegionCircle::dec(), GSkyDir::dist_deg(), GSkyMap::inx2dir(), map(), GSkyMap::npix(), GSkyRegionCircle::ra(), GSkyRegionCircle::radius(), and gammalib::resolution().

Referenced by GSkyRegionMap().

std::string GSkyRegionMap::write ( void  ) const
virtual

Write string describing region in DS9 region format.

Returns
DS9 region string

Returns an empty string.

Todo:
Translate region map into a DS9 polygon.

Implements GSkyRegion.

Definition at line 316 of file GSkyRegionMap.cpp.

Member Data Documentation

GSkyMap GSkyRegionMap::m_map
protected
std::vector<int> GSkyRegionMap::m_nonzero_indices
protected

Vector of non-zero pixel indices.

Definition at line 93 of file GSkyRegionMap.hpp.

Referenced by compute_solid_angle(), copy_members(), init_members(), nonzero_indices(), overlaps(), and set_nonzero_indices().


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