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

Interface for the circular sky region class. More...

#include <GSkyRegionCircle.hpp>

Inheritance diagram for GSkyRegionCircle:
GSkyRegion GBase

Public Member Functions

 GSkyRegionCircle (void)
 Void constructor. More...
 
 GSkyRegionCircle (const GSkyDir &centre, const double &radius)
 Direction constructor. More...
 
 GSkyRegionCircle (const double &ra, const double &dec, const double &radius)
 Direction constructor. More...
 
 GSkyRegionCircle (const std::string &line)
 String constructor. More...
 
 GSkyRegionCircle (const GSkyRegionCircle &region)
 Copy constructor. More...
 
virtual ~GSkyRegionCircle (void)
 Destructor. More...
 
GSkyRegionCircleoperator= (const GSkyRegionCircle &region)
 Assignment operator. More...
 
void clear (void)
 Clear instance. More...
 
GSkyRegionCircleclone (void) const
 Clone circular sky region. More...
 
std::string classname (void) const
 Return class name. More...
 
const double & radius (void) const
 Return circular region radius (in degrees) More...
 
void radius (const double &radius)
 Set radius of circular region. More...
 
const GSkyDircentre (void) const
 Return circular region centre. More...
 
void centre (const GSkyDir &centre)
 Set circular region centre. More...
 
void centre (const double &ra, const double &dec)
 Set circular region centre Right Ascension and Declincation. More...
 
double ra (void) const
 Return circular region centre Right Ascension. More...
 
double dec (void) const
 Return circular region centre Declination. More...
 
void read (const std::string &line)
 Read region from DS9 string. More...
 
std::string write (void) const
 Write region into a string. More...
 
bool contains (const GSkyDir &dir) const
 Checks if sky direction lies within region. More...
 
bool contains (const GSkyRegion &reg) const
 Checks if region is fully contained within this region. More...
 
bool overlaps (const GSkyRegion &reg) const
 Checks if region is overlapping with this region. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print circular region. 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 GSkyRegionCircle &region)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void compute_solid_angle (void)
 Compute solid angle. 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

GSkyDir m_centre
 Centre or reference point of the region. More...
 
double m_radius
 Radius of circular the region (degrees) 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...
 

Friends

bool operator== (const GSkyRegionCircle &a, const GSkyRegionCircle &b)
 Equality operator. More...
 
bool operator!= (const GSkyRegionCircle &a, const GSkyRegionCircle &b)
 Non equality operator. More...
 

Detailed Description

Interface for the circular sky region class.

This class provides an implementation for a circular sky region. The sky region is defined by an array of parameters, the meaning of which is specific to the derived class where the region type or shape is defined. The parameters are GModelPar objects for convenience.

The class holds several properties such as solid angle subtended by the region and computed through internal method compute_solid().

To be clarified:

  • Do we want a member relating the region to an observation run ?
  • Constructor and read/write using XML may not be needed if we use DS9 region file format ?
  • Replace GModelPar by double for the parameters (GModelPar is overkill) ?

Definition at line 58 of file GSkyRegionCircle.hpp.

Constructor & Destructor Documentation

GSkyRegionCircle::GSkyRegionCircle ( void  )

Void constructor.

Definition at line 60 of file GSkyRegionCircle.cpp.

References init_members().

Referenced by clone().

GSkyRegionCircle::GSkyRegionCircle ( const GSkyDir centre,
const double &  radius 
)

Direction constructor.

Parameters
[in]centreCentre sky direction.
[in]radiusRegion radius (degrees).

Definition at line 76 of file GSkyRegionCircle.cpp.

References centre(), compute_solid_angle(), init_members(), and radius().

GSkyRegionCircle::GSkyRegionCircle ( const double &  ra,
const double &  dec,
const double &  radius 
)

Direction constructor.

Parameters
[in]raRight Ascension of region centre (degrees).
[in]decDeclination of region centre (degrees).
[in]radiusRegion radius (degrees).

Definition at line 101 of file GSkyRegionCircle.cpp.

References centre(), compute_solid_angle(), init_members(), and radius().

GSkyRegionCircle::GSkyRegionCircle ( const std::string &  line)
explicit

String constructor.

Parameters
[in]lineDS9 region file line.

Constructs region from a DS9 region file line.

Definition at line 127 of file GSkyRegionCircle.cpp.

References init_members(), and read().

GSkyRegionCircle::GSkyRegionCircle ( const GSkyRegionCircle region)

Copy constructor.

Parameters
[in]regionCircular sky region.

Definition at line 146 of file GSkyRegionCircle.cpp.

References copy_members(), and init_members().

GSkyRegionCircle::~GSkyRegionCircle ( void  )
virtual

Destructor.

Definition at line 163 of file GSkyRegionCircle.cpp.

References free_members().

Member Function Documentation

void GSkyRegionCircle::centre ( const GSkyDir dir)
inline

Set circular region centre.

Parameters
[in]dirRegion centre.

Sets the centre of the circular region to the specified sky direction.

Definition at line 155 of file GSkyRegionCircle.hpp.

References m_centre.

void GSkyRegionCircle::centre ( const double &  ra,
const double &  dec 
)
inline

Set circular region centre Right Ascension and Declincation.

Parameters
[in]raRight Ascension [deg].
[in]decDeclination [deg].

Sets the centre of the circular region to the specified Right Ascension and Declination.

Definition at line 175 of file GSkyRegionCircle.hpp.

References m_centre, and GSkyDir::radec_deg().

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

Return class name.

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

Implements GSkyRegion.

Definition at line 113 of file GSkyRegionCircle.hpp.

GSkyRegionCircle * GSkyRegionCircle::clone ( void  ) const
virtual

Clone circular sky region.

Returns
Deep copy to circular sky region.

Implements GSkyRegion.

Definition at line 238 of file GSkyRegionCircle.cpp.

References GSkyRegionCircle().

void GSkyRegionCircle::compute_solid_angle ( void  )
protected

Compute solid angle.

Definition at line 724 of file GSkyRegionCircle.cpp.

References cos(), gammalib::deg2rad, m_radius, GSkyRegion::m_solid, and gammalib::twopi.

Referenced by GSkyRegionCircle(), radius(), and read().

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

Checks if sky direction lies within region.

Parameters
[in]dirSky direction.
Returns
True if sky direction is contained in region.

A sky direction lies within a region when its distance to the region centre is not larger than the region radius.

Implements GSkyRegion.

Definition at line 502 of file GSkyRegionCircle.cpp.

References GSkyDir::dist_deg(), m_centre, and radius().

Referenced by contains(), GModelSpatial::circle_int_kern_omega::eval(), and GSkyMap::overlaps_circle().

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

Checks if region is fully contained within this region.

Parameters
[in]regSky region.
Returns
True if region is contained in region.
Exceptions
GException::feature_not_implementedRegions differ in type.

Implements GSkyRegion.

Definition at line 528 of file GSkyRegionCircle.cpp.

References centre(), contains(), GSkyRegionRectangle::corner(), GSkyDir::dist_deg(), G_CONTAINS, m_centre, m_radius, GSkyRegionMap::map(), GSkyRegionMap::nonzero_indices(), radius(), and GSkyRegion::type().

void GSkyRegionCircle::copy_members ( const GSkyRegionCircle region)
protected

Copy class members.

Parameters
[in]regionCircular sky region.

Definition at line 700 of file GSkyRegionCircle.cpp.

References m_centre, and m_radius.

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

double GSkyRegionCircle::dec ( void  ) const
inline

Return circular region centre Declination.

Returns
Region centre Declination [deg].

Returns the region centre Declination in degrees.

Definition at line 207 of file GSkyRegionCircle.hpp.

References GSkyDir::dec_deg(), and m_centre.

Referenced by print(), and GSkyRegionMap::set_region_circle().

void GSkyRegionCircle::free_members ( void  )
protected

Delete class members.

Definition at line 714 of file GSkyRegionCircle.cpp.

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

void GSkyRegionCircle::init_members ( void  )
protected

Initialise class members.

Definition at line 683 of file GSkyRegionCircle.cpp.

References m_centre, m_radius, and GSkyRegion::m_type.

Referenced by clear(), GSkyRegionCircle(), and operator=().

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

Assignment operator.

Parameters
[in]regionCircular sky region.
Returns
Circular sky region.

Definition at line 185 of file GSkyRegionCircle.cpp.

References copy_members(), free_members(), init_members(), and GSkyRegion::operator=().

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

Checks if region is overlapping with this region.

Parameters
[in]regSky region.
Returns
True if region overlaps with region.
Exceptions
GException::feature_not_implementedRegions differ in type.

Implements GSkyRegion.

Definition at line 617 of file GSkyRegionCircle.cpp.

References centre(), GSkyDir::dist_deg(), G_CONTAINS, m_centre, m_radius, GSkyRegionMap::overlaps(), GSkyRegionRectangle::overlaps(), radius(), and GSkyRegion::type().

Referenced by GModelSpatial::flux().

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

Print circular region.

Parameters
[in]chatterChattiness
Returns
String containing region information.

Implements GSkyRegion.

Definition at line 468 of file GSkyRegionCircle.cpp.

References dec(), gammalib::parformat(), ra(), radius(), SILENT, and gammalib::str().

double GSkyRegionCircle::ra ( void  ) const
inline

Return circular region centre Right Ascension.

Returns
Region centre Right Ascension [deg].

Returns the region centre Right Ascension in degrees.

Definition at line 193 of file GSkyRegionCircle.hpp.

References m_centre, and GSkyDir::ra_deg().

Referenced by print(), and GSkyRegionMap::set_region_circle().

void GSkyRegionCircle::radius ( const double &  radius)

Set radius of circular region.

Parameters
[in]radiusRadius (degrees).
Exceptions
GException::invalid_argumentRadius value is less than 0.

Sets the radius of the circular sky region. Only non-negative radii are allowed.

Definition at line 256 of file GSkyRegionCircle.cpp.

References compute_solid_angle(), G_RADIUS, m_radius, radius(), and gammalib::str().

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

Read region from DS9 string.

Parameters
[in]lineString in DS9 format.
Exceptions
GException::invalid_valueInvalid value found in DS9 format string.

Implements GSkyRegion.

Definition at line 286 of file GSkyRegionCircle.cpp.

References centre(), clear(), compute_solid_angle(), gammalib::contains(), G_READ, GSkyDir::lb_deg(), GSkyRegion::m_name, GSkyDir::radec_deg(), radius(), gammalib::split(), gammalib::str(), and gammalib::todouble().

Referenced by GSkyRegionCircle(), and GSkyRegions::load().

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

Write region into a string.

Returns
String to be written in a DS9 region file

Writes a DS9 region into a string. The region name is only written if it is defined.

Implements GSkyRegion.

Definition at line 435 of file GSkyRegionCircle.cpp.

References GSkyDir::dec_deg(), m_centre, GSkyRegion::m_name, m_radius, GSkyDir::ra_deg(), and gammalib::str().

Friends And Related Function Documentation

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

Non equality operator.

Parameters
[in]aFirst sky region circle.
[in]bSecond sky region circle.
Returns
True if both sky region circles are different.

Definition at line 760 of file GSkyRegionCircle.cpp.

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

Equality operator.

Parameters
[in]aFirst sky region circle.
[in]bSecond sky region circle.
Returns
True if both sky region circles are identical.

Returns true if two sky region circles and identical.

Definition at line 746 of file GSkyRegionCircle.cpp.

Member Data Documentation

GSkyDir GSkyRegionCircle::m_centre
protected

Centre or reference point of the region.

Definition at line 102 of file GSkyRegionCircle.hpp.

Referenced by centre(), contains(), copy_members(), dec(), init_members(), operator!=(), operator==(), overlaps(), ra(), and write().

double GSkyRegionCircle::m_radius
protected

Radius of circular the region (degrees)

Definition at line 103 of file GSkyRegionCircle.hpp.

Referenced by compute_solid_angle(), contains(), copy_members(), init_members(), operator!=(), operator==(), overlaps(), radius(), and write().


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