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

Sky map class. More...

#include <GSkyMap.hpp>

Inheritance diagram for GSkyMap:
GBase

Public Member Functions

 GSkyMap (void)
 Void constructor. More...
 
 GSkyMap (const GFilename &filename)
 FITS file constructor. More...
 
 GSkyMap (const GFitsHDU &hdu)
 FITS HDU constructor. More...
 
 GSkyMap (const std::string &coords, const int &nside, const std::string &order, const int &nmaps=1)
 Healpix sky map constructor. More...
 
 GSkyMap (const std::string &wcs, const std::string &coords, const double &x, const double &y, const double &dx, const double &dy, const int &nx, const int &ny, const int &nmaps=1)
 WCS sky map constructor. More...
 
 GSkyMap (const GSkyMap &map)
 Copy constructor. More...
 
virtual ~GSkyMap (void)
 Destructor. More...
 
GSkyMapoperator= (const GSkyMap &map)
 Assignment operator. More...
 
GSkyMapoperator= (const double &value)
 Value setting operator. More...
 
GSkyMapoperator+= (const GSkyMap &map)
 Map addition operator. More...
 
GSkyMapoperator+= (const double &value)
 Value addition operator. More...
 
GSkyMapoperator-= (const GSkyMap &map)
 Map subtraction operator. More...
 
GSkyMapoperator-= (const double &value)
 Value subtraction operator. More...
 
GSkyMapoperator*= (const GSkyMap &map)
 Multiplication operator. More...
 
GSkyMapoperator*= (const double &factor)
 Sky map scaling operator. More...
 
GSkyMapoperator/= (const GSkyMap &map)
 Division operator. More...
 
GSkyMapoperator/= (const double &factor)
 Sky map division operator. More...
 
GSkyMap operator+ (const GSkyMap &map) const
 Binary sky map addition. More...
 
GSkyMap operator- (const GSkyMap &map) const
 Binary sky map subtraction. More...
 
GSkyMap operator* (const GSkyMap &map) const
 Binary sky map multiplication. More...
 
GSkyMap operator/ (const GSkyMap &map) const
 Binary sky map division. More...
 
double & operator() (const int &index, const int &map=0)
 Pixel index access operator. More...
 
const double & operator() (const int &index, const int &map=0) const
 Pixel index access operator (const variant) More...
 
double & operator() (const GSkyPixel &pixel, const int &map=0)
 Sky map pixel access operator. More...
 
const double & operator() (const GSkyPixel &pixel, const int &map=0) const
 Sky map pixel access operator. More...
 
double operator() (const GSkyDir &dir, const int &map=0) const
 Return interpolated skymap value for sky direction. More...
 
void clear (void)
 Clear instance. More...
 
GSkyMapclone (void) const
 Clone sky map. More...
 
std::string classname (void) const
 Return class name. More...
 
bool is_empty (void) const
 Signals if sky map is empty. More...
 
const int & npix (void) const
 Returns number of pixels. More...
 
const int & nx (void) const
 Returns number of pixels in x coordinate. More...
 
const int & ny (void) const
 Returns number of pixels in y coordinate. More...
 
const int & nmaps (void) const
 Returns number of maps. More...
 
void nmaps (const int &nmaps)
 Set number of maps. More...
 
const std::vector< int > & shape (void) const
 Returns shape of maps. More...
 
void shape (const int &s1)
 Set one-dimensional shape of maps. More...
 
void shape (const int &s1, const int &s2)
 Set two-dimensional shape of maps. More...
 
void shape (const int &s1, const int &s2, const int &s3)
 Set three-dimensional shape of maps. More...
 
void shape (const std::vector< int > &shape)
 Set shape of maps. More...
 
int ndim (void) const
 Returns dimension of maps. More...
 
GSkyPixel inx2pix (const int &index) const
 Converts pixel index into sky map pixel. More...
 
GSkyDir inx2dir (const int &index) const
 Returns sky direction of pixel. More...
 
GSkyDir pix2dir (const GSkyPixel &pixel) const
 Returns sky direction of pixel. More...
 
int pix2inx (const GSkyPixel &pixel) const
 Converts sky map pixel into pixel index. More...
 
int dir2inx (const GSkyDir &dir) const
 Returns pixel index for a given sky direction. More...
 
GSkyPixel dir2pix (const GSkyDir &dir) const
 Returns sky map pixel for a given sky direction. More...
 
GNdarray counts (void) const
 Returns array with total number of counts for count maps. More...
 
double flux (const int &index, const int &map=0) const
 Returns flux in pixel. More...
 
double flux (const GSkyPixel &pixel, const int &map=0) const
 Returns flux in pixel. More...
 
double flux (const GSkyRegion &region, const int &map=0) const
 Returns flux within sky region. More...
 
double flux (const GSkyRegions &regions, const int &map=0) const
 Returns flux within sky regions. More...
 
GNdarray flux (void) const
 Returns array with total flux for sky maps. More...
 
double solidangle (const int &index) const
 Returns solid angle of pixel. More...
 
double solidangle (const GSkyPixel &pixel) const
 Returns solid angle of pixel. More...
 
double solidangle (const GSkyRegion &region) const
 Returns solid angle within sky region. More...
 
double solidangle (const GSkyRegions &regions) const
 Returns solid angle within sky regions. More...
 
bool contains (const GSkyDir &dir) const
 Checks if sky direction falls in map. More...
 
bool contains (const GSkyPixel &pixel) const
 Checks if sky map pixel falls in map. More...
 
bool overlaps (const GSkyRegion &region) const
 Checks whether a region overlaps with this map. More...
 
void smooth (const std::string &kernel, const double &par)
 Smooth sky map. More...
 
void correlate (const std::string &kernel, const double &par)
 Correlates sky map. More...
 
const GSkyProjectionprojection (void) const
 Returns pointer to sky projection. More...
 
void projection (const GSkyProjection &proj)
 Set sky projection. More...
 
const double * pixels (void) const
 Returns pointer to pixel data. More...
 
GSkyMap extract (const int &map, const int &nmaps=1) const
 Extract maps into a new sky map object. More...
 
GSkyMap extract (const int &startx, const int &stopx, const int &starty, const int &stopy) const
 Extract a sub-range of pixels in the map in x,y. More...
 
GSkyMap extract (const GSkyRegions &inclusions) const
 Extract the spatial portion of the maps that overlap inclusions. More...
 
void stack_maps (void)
 Stack all maps into a single map. More...
 
GSkyRegionCircle region_circle (void) const
 Return sky region circle that encloses the sky map. More...
 
void load (const GFilename &filename)
 Load skymap from FITS file. More...
 
void save (const GFilename &filename, const bool &clobber=false) const
 Save sky map into FITS file. More...
 
void read (const GFitsHDU &hdu)
 Read skymap from FITS HDU. More...
 
GFitsHDUwrite (GFits &file, const std::string &extname="") const
 Write sky map into FITS file. More...
 
void publish (const std::string &name="") const
 Publish sky map. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print sky map. 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 GSkyMap &map)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void set_wcs (const std::string &wcs, const std::string &coords, const double &crval1, const double &crval2, const double &crpix1, const double &crpix2, const double &cdelt1, const double &cdelt2)
 Set World Coordinate System. More...
 
void read_healpix (const GFitsTable &table)
 Read Healpix data from FITS table. More...
 
void read_wcs (const GFitsImage &image)
 Read WCS image from FITS HDU. More...
 
void alloc_wcs (const GFitsImage &image)
 Allocate WCS class. More...
 
GFitsBinTablecreate_healpix_hdu (void) const
 Create FITS HDU containing Healpix data. More...
 
GFitsImageDoublecreate_wcs_hdu (void) const
 Create FITS HDU containing WCS image. More...
 
double solidangle (const GSkyDir &dir1, const GSkyDir &dir2, const GSkyDir &dir3) const
 Compute solid angle subtended by 3 sky directions. More...
 
double solidangle (const GSkyDir &dir1, const GSkyDir &dir2, const GSkyDir &dir3, const GSkyDir &dir4) const
 Compute solid angle subtended by 4 sky directions. More...
 
bool overlaps_circle (const GSkyRegionCircle &region) const
 Checks whether a circular region overlaps with this map. More...
 
bool is_healpix (const GFitsHDU &hdu) const
 Check if HDU contains HEALPix data. More...
 
bool is_wcs (const GFitsHDU &hdu) const
 Check if HDU contains WCS data. More...
 
bool is_same (const GSkyMap &map) const
 Check if map is the same. More...
 
void convolve (const std::string &kernel, const double &par, const bool &normalise)
 Convolve sky map. More...
 
GNdarray convolution_kernel (const std::string &kernel, const double &par, const bool &normalise) const
 Return convolution kernel. More...
 

Private Attributes

int m_num_pixels
 Number of pixels (used for pixel allocation) More...
 
int m_num_maps
 Number of maps (used for pixel allocation) More...
 
int m_num_x
 Number of pixels in x direction (only 2D) More...
 
int m_num_y
 Number of pixels in y direction (only 2D) More...
 
std::vector< int > m_shape
 Shape of the maps. More...
 
GSkyProjectionm_proj
 Pointer to sky projection. More...
 
GNdarray m_pixels
 Skymap pixels. More...
 
bool m_hascache
 Cache is valid. More...
 
bool m_contained
 Sky direction is contained in map. More...
 
GSkyDir m_last_dir
 Last sky direction. More...
 
GBilinear m_interpol
 Bilinear interpolator. More...
 

Friends

GSkyMap sqrt (const GSkyMap &map)
 Computes square root of sky map elements. More...
 
GSkyMap log (const GSkyMap &map)
 Computes the natural logarithm of sky map elements. More...
 
GSkyMap log10 (const GSkyMap &map)
 Computes the base 10 logarithm of sky map elements. More...
 
GSkyMap abs (const GSkyMap &map)
 Computes the absolute value of sky map elements. More...
 
GSkyMap sign (const GSkyMap &map)
 Computes the sign value of sky map elements. More...
 
GSkyMap clip (const GSkyMap &map, const double &thresh)
 Clips map at given value. More...
 
bool operator== (const GSkyMap &a, const GSkyMap &b)
 Equality operator. More...
 
bool operator!= (const GSkyMap &a, const GSkyMap &b)
 Non-equality operator. More...
 

Detailed Description

Sky map class.

This class implements a sky maps. Sky maps are collections of pixels that define a quantity as function of pixel location. Typical quantities are gamma-ray intensities, but may also be the number of measured counts.

Sky map pixels may be arranged in a 2-dimensional grid or in a linear 1-dimensional sequence. The link between pixel index and sky direction on the celestial sphere is established using a projection, implemented by the GSkyProjection class. 2-dimensional grids are represented by World Coordinate Systems. All World Coordinate Systems derive from GWcs and are registered in GWcsRegistry. The Healpix pixelisation, implemented by the GHealpix class, is the only 1-dimensional grid that is so far available.

Sky map pixels may be accessed by their linear index, by pixel or by sky direction. While the index and pixel access return the sky map value at the pixel centre, the sky direction access operator performs an interpolation to the exact sky direction.

Conversion methods exist to convert between the linear index, the pixel and the sky direction:

GSkyPixel pixel = map.inx2pix(index);   // Index to pixel
GSkyDir   dir   = map.inx2dir(index);   // Index to sky direction
GSkyDir   dir   = map.pix2dir(pixel);   // Pixel to sky direction
int       index = map.pix2inx(pixel);   // Pixel to index
int       index = map.dir2inx(dir);     // Sky direction to index
GSkyPixel pixel = map.dir2pix(dir);     // Sky direction to pixel

Definition at line 89 of file GSkyMap.hpp.

Constructor & Destructor Documentation

GSkyMap::GSkyMap ( void  )

Void constructor.

Constructs an empty sky map.

Definition at line 116 of file GSkyMap.cpp.

References init_members().

Referenced by clone().

GSkyMap::GSkyMap ( const GFilename filename)
explicit

FITS file constructor.

Parameters
[in]filenameFITS file name.

Constructs a sky map by loading data from a FITS file. See the load() method for more information about the FITS formats that are supported.

Definition at line 134 of file GSkyMap.cpp.

References init_members(), and load().

GSkyMap::GSkyMap ( const GFitsHDU hdu)
explicit

FITS HDU constructor.

Parameters
[in]hduFITS HDU.

Constructs a sky map by fetching data from a FITS HDU. See the read() method for more information.

Definition at line 155 of file GSkyMap.cpp.

References init_members(), and read().

GSkyMap::GSkyMap ( const std::string &  coords,
const int &  nside,
const std::string &  order,
const int &  nmaps = 1 
)

Healpix sky map constructor.

Parameters
[in]coordsCoordinate System (CEL or GAL).
[in]nsideNside parameter.
[in]orderPixel ordering (RING or NEST).
[in]nmapsNumber of maps in set.
Exceptions
GException::invalid_argumentInvalid nmaps parameter.

Constructs nmaps identical all sky maps in Healpix pixelisation. All pixels of the sky maps will be initialised to values of zero.

Definition at line 182 of file GSkyMap.cpp.

References G_CONSTRUCT_HPX, init_members(), m_num_maps, m_num_pixels, m_pixels, m_proj, m_shape, nmaps(), GHealpix::npix(), projection(), and gammalib::str().

GSkyMap::GSkyMap ( const std::string &  wcs,
const std::string &  coords,
const double &  x,
const double &  y,
const double &  dx,
const double &  dy,
const int &  nx,
const int &  ny,
const int &  nmaps = 1 
)

WCS sky map constructor.

Parameters
[in]wcsWorld Coordinate System.
[in]coordsCoordinate System (CEL or GAL).
[in]xX coordinate of sky map centre (deg).
[in]yY coordinate of sky map centre (deg).
[in]dxPixel size in x direction at centre (deg/pixel).
[in]dyPixel size in y direction at centre (deg/pixel).
[in]nxNumber of pixels in x direction.
[in]nyNumber of pixels in y direction.
[in]nmapsNumber of maps in set (default=1).
Exceptions
GException::invalid_argumentInvalid number of pixels or maps.

Constructs nmaps identical all sky maps in World Coordinate System projection. All pixels of the sky maps will be initialised to values of zero.

Definition at line 234 of file GSkyMap.cpp.

References G_CONSTRUCT_MAP, init_members(), m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_shape, nmaps(), nx(), ny(), set_wcs(), and gammalib::str().

GSkyMap::GSkyMap ( const GSkyMap map)

Copy constructor.

Parameters
[in]mapSky map.

Constructs sky maps by copying data from another sky map object.

Definition at line 297 of file GSkyMap.cpp.

References copy_members(), and init_members().

GSkyMap::~GSkyMap ( void  )
virtual

Destructor.

Definition at line 313 of file GSkyMap.cpp.

References free_members().

Member Function Documentation

void GSkyMap::alloc_wcs ( const GFitsImage image)
private

Allocate WCS class.

Parameters
[in]imageFITS image.
Exceptions
GException::invalid_argumentCTYPE1 and CTYPE2 keywords are incompatible or WCS projection of FITS file not supported by GammaLib.

Definition at line 3228 of file GSkyMap.cpp.

References GWcsRegistry::alloc(), GRegistry::content(), G_ALLOC_WCS, m_proj, and GFitsHDU::string().

Referenced by read_wcs().

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

Return class name.

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

Implements GBase.

Definition at line 319 of file GSkyMap.hpp.

GSkyMap * GSkyMap::clone ( void  ) const
virtual

Clone sky map.

Returns
Pointer to deep copy of sky map.

Implements GBase.

Definition at line 1118 of file GSkyMap.cpp.

References GSkyMap().

bool GSkyMap::contains ( const GSkyDir dir) const

Checks if sky direction falls in map.

Parameters
[in]dirSky direction.
Returns
True if sky direction falls into map, false otherwise.

This method checks if the specified sky direction falls within the pixels covered by the skymap. The method uses the dir2xy method to convert the sky direction into 2D pixel indices, and then checks whether the pixel indices fall in the skymap.

Definition at line 2023 of file GSkyMap.cpp.

References dir2pix().

Referenced by GCOMDri::compute_dre(), GSkyRegionMap::contains(), GCOMResponse::irf_diffuse(), GLATEventCube::maxrad(), operator()(), and overlaps_circle().

bool GSkyMap::contains ( const GSkyPixel pixel) const

Checks if sky map pixel falls in map.

Parameters
[in]pixelSky map pixel.
Returns
Trus if pixels is within map, false otherwise.

Checks whether the specified sky map pixel falls within the skymap or not. A pixel is considered to fall in the sky may if the value is contained in the interval

\[ [-0.5, n-0.5[ \]

where \(n\) is the number of sky map pixels. Note that the upper bound is excluded from the interval.

Definition at line 2064 of file GSkyMap.cpp.

References GSkyPixel::index(), GSkyPixel::is_1D(), GSkyPixel::is_2D(), m_num_pixels, m_num_x, m_num_y, GSkyPixel::x(), and GSkyPixel::y().

GNdarray GSkyMap::convolution_kernel ( const std::string &  kernel,
const double &  par,
const bool &  normalise 
) const
private

Return convolution kernel.

Parameters
[in]kernelConvolution kernel type ("DISK", "GAUSSIAN").
[in]parConvolution parameter (>0).
[in]normaliseNormalise kernel?
Returns
Array filled with convolution kernel.

If normalise is true the kernel is normalised to an integral of unity so that the operation corresponds to a smoothing. Otherwise the maximum of the kernel is 1 so that the convolution is a correlation.

Definition at line 3813 of file GSkyMap.cpp.

References GWcs::cdelt(), exp(), G_CONVOLUTION_KERNEL, m_num_x, m_num_y, m_proj, norm(), sqrt(), sum(), and gammalib::toupper().

Referenced by convolve().

void GSkyMap::convolve ( const std::string &  kernel,
const double &  par,
const bool &  normalise 
)
private

Convolve sky map.

Parameters
[in]kernelConvolution kernel type ("DISK", "GAUSSIAN").
[in]parConvolution parameter.
[in]normaliseNormalise kernel?

Convolves all sky maps using the specified kernel and a convolution parameter.

For the "DISK" kernel the convolution parameter is the disk radius in degrees. For the "GAUSSIAN" kernel the convolution parameter is the Gaussian sigma in degrees.

If normalise is true the kernel is normalised to an integral of unity so that the operation corresponds to a smoothing. Otherwise the maximum of the kernel is 1 so that the convolution is a correlation.

Definition at line 3756 of file GSkyMap.cpp.

References GFft::backward(), convolution_kernel(), GNdarray::data(), m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, and smooth().

Referenced by correlate(), and smooth().

void GSkyMap::copy_members ( const GSkyMap map)
private

Copy class members.

Parameters
[in]mapSky map.

Definition at line 2884 of file GSkyMap.cpp.

References GSkyProjection::clone(), m_contained, m_hascache, m_interpol, m_last_dir, m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_proj, and m_shape.

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

void GSkyMap::correlate ( const std::string &  kernel,
const double &  par 
)
inline

Correlates sky map.

Parameters
[in]kernelCorrelation kernel type ("DISK", "GAUSSIAN").
[in]parCorrelation parameter.

Correlates all sky maps using the specified kernel and a correlation parameter. For the "DISK" kernel the correlation parameter is the disk radius in degrees. For the "GAUSSIAN" kernel the correlation parameter is the Gaussian sigma in degrees.

Definition at line 452 of file GSkyMap.hpp.

References convolve().

GNdarray GSkyMap::counts ( void  ) const

Returns array with total number of counts for count maps.

Returns
Array of pixel counts sums.

For a set of n count maps, the method returns a 1D array with n entries that correspond to the sum of the pixel counts in each map.

Definition at line 1496 of file GSkyMap.cpp.

References m_num_maps, m_num_pixels, and sum().

GFitsBinTable * GSkyMap::create_healpix_hdu ( void  ) const
private

Create FITS HDU containing Healpix data.

This method allocates a binary table HDU that contains the Healpix data. Deallocation of the table has to be done by the client.

Definition at line 3271 of file GSkyMap.cpp.

References GFitsTable::append(), GFitsHDU::card(), GNdarray::data(), GFitsHDU::extname(), m_num_maps, m_num_pixels, m_pixels, m_proj, gammalib::number(), and GSkyProjection::write().

Referenced by save(), and write().

GFitsImageDouble * GSkyMap::create_wcs_hdu ( void  ) const
private

Create FITS HDU containing WCS image.

This method allocates an image HDU that contains the WCS image data. Deallocation of the image has to be done by the client.

Todo:
Set additional keywords.

Definition at line 3332 of file GSkyMap.cpp.

References GNdarray::data(), GFitsHDU::extname(), m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_proj, m_shape, ndim(), and GSkyProjection::write().

Referenced by save(), and write().

int GSkyMap::dir2inx ( const GSkyDir dir) const

Returns pixel index for a given sky direction.

Parameters
[in]dirSky direction.
Returns
Pixel index [0,...,npix()-1].
Exceptions
GException::invalid_valueNo valid sky projection found.

Returns sky map pixel index for a given sky direction.

Definition at line 1445 of file GSkyMap.cpp.

References GSkyProjection::dir2pix(), G_DIR2INX, m_proj, and pix2inx().

Referenced by GSkyRegionMap::contains().

GSkyPixel GSkyMap::dir2pix ( const GSkyDir dir) const

Returns sky map pixel for a given sky direction.

Parameters
[in]dirSky direction.
Returns
Sky map pixel.
Exceptions
GException::invalid_valueNo valid sky projection found.

Returns sky map pixel for a given sky direction.

Definition at line 1472 of file GSkyMap.cpp.

References GSkyProjection::dir2pix(), G_DIR2PIX, and m_proj.

Referenced by GCOMDri::compute_dre(), contains(), GLATLtCubeMap::operator()(), and operator()().

GSkyMap GSkyMap::extract ( const int &  map,
const int &  nmaps = 1 
) const

Extract maps into a new sky map object.

Parameters
[in]mapFirst map to extract
[in]nmapsNumber of maps to extract
Returns
Extracted map(s).
Exceptions
GException::out_of_rangeFirst map index outside valid range
GException::invalid_argumentRequested number of maps are not available.

Extracts nmaps sky maps starting from map from the sky map.

Definition at line 2139 of file GSkyMap.cpp.

References GNdarray::data(), G_EXTRACT, m_num_maps, m_num_pixels, m_pixels, m_shape, nmaps(), and gammalib::str().

Referenced by GCOMDri::cone_content(), and extract().

GSkyMap GSkyMap::extract ( const int &  startx,
const int &  stopx,
const int &  starty,
const int &  stopy 
) const

Extract a sub-range of pixels in the map in x,y.

Parameters
[in]startxStarting bin in X (inclusive)
[in]stopxLast bin in X (inclusive)
[in]startyStarting bin in Y (inclusive)
[in]stopyLast bin in Y (inclusive)
Returns
Skymap that overlaps with supplied exclusions
Exceptions
GException::invalid_argumentMethod not valid for HPX projection

This method creates a new skymap consisting of all pixels in the map in the range [startx,stopx] and [starty,stopy]. The boundary values provided are inclusive and the actual projection is unchanged. The number of maps in the skymap is also unchanged.

NOTE: The pixel ranges are indexed from 0, as in

Definition at line 2209 of file GSkyMap.cpp.

References GWcs::cdelt(), GBilinear::clear(), GSkyDir::clear(), GSkyProjection::code(), GSkyProjection::coordsys(), GWcs::crpix(), GWcs::crval(), G_EXTRACT_INT, m_contained, m_hascache, m_interpol, m_last_dir, m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_proj, and GWcs::set().

GSkyMap GSkyMap::extract ( const GSkyRegions inclusions) const

Extract the spatial portion of the maps that overlap inclusions.

Parameters
[in]inclusionsList of GSkyRegion objects
Returns
Skymap that overlaps with supplied exclusions
Exceptions
GException::invalid_argumentMethod not valid for HPX projection

This method computes the x,y range that covers the regions in inclusions, then returns that range as a new GSkyMap.

NOTE: A 1-pixel border is added to the returned map to provide better coverage in the returned map.

Definition at line 2289 of file GSkyMap.cpp.

References GSkyProjection::code(), GSkyRegions::contains(), extract(), G_EXTRACT_REG, inx2pix(), m_proj, npix(), nx(), ny(), pix2dir(), GSkyPixel::x(), and GSkyPixel::y().

double GSkyMap::flux ( const int &  index,
const int &  map = 0 
) const

Returns flux in pixel.

Parameters
[in]indexPixel index [0,...,npix()-1].
[in]mapMap index [0,...,nmaps()-1].
Returns
Flux in pixel.
Exceptions
GException::invalid_valueNo valid sky projection found.

Returns the flux in the pixel with the specified index. The flux is computed by integrating the intensity over the solid angle subtended by the pixel. Integration is done by dividing the pixel into wedges, computing the intensitites at the cornes of each wedge, averaging these intensities, and multiplying it with the solid angle of each wedge. This provides an approximation of the true pixel flux which is accurate to better than about 5%.

For a HealPix pixelisation, the pixel is divided into 12 wedges. For a WCS pixelisation, the pixel is divided into 8 wedges.

Warning
This method only returns correct values once the skymap is completely setup with values. Do not use this method during a setup operation as the method uses neighboring pixels for interpolation. If the map is not completely setup the neighboring pixels may still be empty, hence the flux interpolation will be wrong.

Definition at line 1551 of file GSkyMap.cpp.

References flux(), G_FLUX1, inx2pix(), and m_proj.

Referenced by GModelSpatialDiffuseMap::flux(), GModelSpatialDiffuseCube::flux(), GModelSpatialDiffuseMap::mc_cone(), GModelSpatialDiffuseCube::mc_cone(), and GModelSpatialDiffuseMap::prepare_map().

double GSkyMap::flux ( const GSkyPixel pixel,
const int &  map = 0 
) const

Returns flux in pixel.

Parameters
[in]pixelSky map pixel.
[in]mapMap index [0,...,nmaps()-1].
Returns
Flux in pixel (ph/cm2/s).
Exceptions
GException::invalid_valueNo valid sky projection found.

Returns the flux in the specified sky map pixel. The flux is computed by integrating the intensity over the solid angle subtended by the pixel. Integration is done by dividing the pixel into wedges, computing the intensitites at the cornes of each wedge, averaging these intensities, and multiplying it with the solid angle of each wedge. This provides an approximation of the true pixel flux which is accurate to better than about 5%.

For a HealPix pixelisation, the pixel is divided into 12 wedges. For a WCS pixelisation, the pixel is divided into 8 wedges.

Warning
This method only returns correct values once the skymap is completely setup with values. Do not use this method during a setup operation as the method uses neighboring pixels for interpolation. If the map is not completely setup the neighboring pixels may still be empty, hence the flux interpolation will be wrong.

Definition at line 1595 of file GSkyMap.cpp.

References GHealpix::boundaries(), gammalib::centre(), flux(), G_FLUX2, m_proj, gammalib::onethird, operator()(), GHealpix::pix2dir(), pix2dir(), projection(), GSkyProjection::size(), solidangle(), GSkyPixel::x(), and GSkyPixel::y().

double GSkyMap::flux ( const GSkyRegion region,
const int &  map = 0 
) const

Returns flux within sky region.

Parameters
[in]regionSky region.
[in]mapMap index [0,...,nmaps()-1].
Returns
Flux in sky region.
Exceptions
GException::out_of_rangeMap index out of valid range

The method returns the total flux in all sky map pixels that fall within the specified region. Containment is tested using the GSkyRegion::contains() method. Sky map values are multiplied by the solid angle of the pixel.

Definition at line 1749 of file GSkyMap.cpp.

References GSkyRegion::contains(), flux(), G_FLUX3, inx2dir(), m_num_maps, m_num_pixels, m_pixels, and solidangle().

double GSkyMap::flux ( const GSkyRegions regions,
const int &  map = 0 
) const

Returns flux within sky regions.

Parameters
[in]regionsSky regions.
[in]mapMap index [0,...,nmaps()-1].
Returns
Flux in sky region.
Exceptions
GException::out_of_rangeMap index out of valid range

The method returns the total flux in all sky map pixels that fall within the specified regions. Containment is tested using the GSkyRegions::contains() method. Sky map values are multiplied by the solid angle of the pixel.

Definition at line 1788 of file GSkyMap.cpp.

References GSkyRegions::contains(), flux(), G_FLUX4, inx2dir(), m_num_maps, m_num_pixels, m_pixels, and solidangle().

GNdarray GSkyMap::flux ( void  ) const

Returns array with total flux for sky maps.

Returns
Array of pixel flux sums.

For a set of n sky maps, the method returns a 1D array with n entries that correspond to the sum of the pixel flux in each map.

Definition at line 1820 of file GSkyMap.cpp.

References m_num_maps, m_num_pixels, m_pixels, and solidangle().

Referenced by flux().

void GSkyMap::free_members ( void  )
private

Delete class members.

Definition at line 2911 of file GSkyMap.cpp.

References m_proj.

Referenced by clear(), operator=(), read(), and ~GSkyMap().

void GSkyMap::init_members ( void  )
private
GSkyPixel GSkyMap::inx2pix ( const int &  index) const

Converts pixel index into sky map pixel.

Parameters
[in]indexPixel index [0,...,npix()-1].
Returns
Sky map pixel.

Converts the pixel index into a sky map pixel (GSkyPixel).The dimension of GSkyPixel will be identical to the dimension of the sky map (i.e. a 1D sky map leads to a 1D GSkyPixel object, a 2D sky map leads to a 2D GSkyPixel object.

< 2D sky map

< 1D sky map

Definition at line 1301 of file GSkyMap.cpp.

References GSkyPixel::index(), m_num_x, GSkyPixel::x(), and GSkyPixel::y().

Referenced by extract(), flux(), inx2dir(), pix2dir(), region_circle(), and solidangle().

bool GSkyMap::is_empty ( void  ) const
inline

Signals if sky map is empty.

Returns
True if sky map is empty, false otherwise.

Signals if a sky map has no pixels or maps.

Definition at line 333 of file GSkyMap.hpp.

References m_num_maps, and m_num_pixels.

bool GSkyMap::is_healpix ( const GFitsHDU hdu) const
private

Check if HDU contains HEALPix data.

Parameters
[in]hduFITS Header Data Unit.
Returns
True is HDU contains HEALPix data.

Returns true if the HDU is not an image and the HDU has the "PIXTYPE" keyword set to "HEALPIX".

Definition at line 3624 of file GSkyMap.cpp.

References GFitsHDU::exttype(), GFitsHDU::has_card(), GFitsHDU::HT_IMAGE, and GFitsHDU::string().

Referenced by load(), and read().

bool GSkyMap::is_same ( const GSkyMap map) const
private

Check if map is the same.

Parameters
[in]mapSky map.
Returns
True is sky map definition is identical.

Returns true if the sky map definition is identical to the one of the current map.

Definition at line 3675 of file GSkyMap.cpp.

References GWcs::cdelt(), GSkyProjection::code(), GSkyProjection::coordsys(), GWcs::crpix(), GWcs::crval(), m_num_x, m_num_y, m_proj, GHealpix::npix(), GHealpix::nside(), and GHealpix::ordering().

Referenced by operator*=(), operator+=(), operator-=(), operator/=(), and operator==().

bool GSkyMap::is_wcs ( const GFitsHDU hdu) const
private

Check if HDU contains WCS data.

Parameters
[in]hduFITS Header Data Unit.
Returns
True is HDU contains WCS data.

Returns true if the HDU is an image and the HDU has the "NAXIS" keyword set to a value >= 2.

Definition at line 3650 of file GSkyMap.cpp.

References GFitsHDU::exttype(), GFitsHDU::has_card(), GFitsHDU::HT_IMAGE, and GFitsHDU::integer().

Referenced by load(), and read().

void GSkyMap::load ( const GFilename filename)

Load skymap from FITS file.

Parameters
[in]filenameFITS file name..

Loads HEALPix and non HEALPix skymaps. First searches for HEALPix map in FITS file by scanning all HDUs for PIXTYPE=HEALPIX. If no HEALPix map has been found then search load first non-empty image.

Todo:
Do we have to restrict a HEALPix map to a BinTable and a WCS map to a Double precision image???

Definition at line 2511 of file GSkyMap.cpp.

References GFits::at(), clear(), GFits::close(), GFilename::extname(), GFilename::extno(), GFilename::has_extname(), GFilename::has_extno(), is_healpix(), is_wcs(), read_healpix(), read_wcs(), and GFits::size().

Referenced by GSkyMap(), GSkyRegionMap::load(), GModelSpatialDiffuseMap::load(), and GModelSpatialDiffuseCube::load_cube().

int GSkyMap::ndim ( void  ) const
inline

Returns dimension of maps.

Returns
Number of map dimensions.

Definition at line 415 of file GSkyMap.hpp.

References m_shape.

Referenced by create_wcs_hdu().

void GSkyMap::nmaps ( const int &  nmaps)

Set number of maps.

Parameters
[in]nmapsNumber of maps.
Exceptions
GException::invalid_argumentInvalid number of maps specified.

Redefines the number of maps in an GSkyMap object. If the number of maps is increased with respect to the existing number, additional maps with pixel values of zero are append to the object. Existing map pixel values are kept. If the number of maps is decreased with respect to the existing number, the excedent maps are dropped. The remaining map pixel values are kept.

Definition at line 1139 of file GSkyMap.cpp.

References G_NMAPS, m_num_maps, m_num_pixels, m_pixels, m_shape, and nmaps().

const int & GSkyMap::npix ( void  ) const
inline

Returns number of pixels.

Returns
Number of pixels in one sky map.

Returns the number of pixels in one sky map.

Definition at line 347 of file GSkyMap.hpp.

References m_num_pixels.

Referenced by abs(), GCTACubePsf::clear_cube(), GCTACubeEdisp::clear_cube(), clip(), GCOMObservation::compute_drb_phinor(), GCOMDri::compute_dre(), GCOMDri::compute_drg(), GCOMDris::compute_drws(), GCOMDris::compute_drws_energy(), GCOMDris::compute_drws_phibar(), GCOMDri::compute_drx(), GCTACubeEdisp::compute_ebounds(), GSPIResponse::compute_irf(), GCOMDri::cone_content(), GCOMModelDRBPhibarBins::eval(), extract(), GCTACubePsf::fill(), GCTACubeEdisp::fill(), GCTACubeExposure::fill_cube(), GCTACubePsf::fill_cube(), GCTACubeEdisp::fill_cube(), GCOMObservation::get_weighted_drg_map(), GCTACubeBackground::integral(), GResponse::irf_diffuse(), GLATResponse::irf_spatial_bin(), log(), log10(), GModelSpatialDiffuseMap::mc(), GModelSpatialDiffuseCube::mc(), GModelSpatialDiffuseMap::mc_cone(), GModelSpatialDiffuseCube::mc_cone(), GLATEventCube::naxis(), GLATEventCube::npix(), GCTAEventCube::npix(), GCTAModelSkyCube::npred(), operator*=(), operator+=(), operator-=(), operator/=(), GModelSpatialDiffuseMap::prepare_map(), GModelSpatialDiffuseCube::print(), read_healpix(), region_circle(), GSPIResponse::set(), GSkyRegionMap::set_nonzero_indices(), GSkyRegionMap::set_region_circle(), GCTACubePsf::set_to_smooth(), sign(), GLATEventCube::size(), GCTAEventCube::size(), GCOMDri::size(), sqrt(), GCOMObservation::use_event_for_likelihood(), GCOMDris::vetorate_generate(), and GCOMDris::vetorate_setup().

const int & GSkyMap::nx ( void  ) const
inline

Returns number of pixels in x coordinate.

Returns
Number of pixels in the X direction.

Returns the number of pixels in the X direction. If the sky map is a one dimensional array (which is the case for the Healpix projection), the method returns 0.

Definition at line 363 of file GSkyMap.hpp.

References m_num_x.

Referenced by GCOMObservation::check_dri(), gammalib::com_wcs_mer2car(), extract(), GSkyMap(), GSPIResponse::irf_value(), GSPIResponse::load_irfs(), GLATEventCube::naxis(), GCTAEventCube::naxis(), GCOMDri::nchi(), GLATEventCube::nx(), GCTAEventCube::nx(), overlaps_circle(), GLATEventCube::print(), GCOMDri::print(), GSPIResponse::print(), GLATEventCube::read_srcmap(), and region_circle().

const int & GSkyMap::ny ( void  ) const
inline

Returns number of pixels in y coordinate.

Returns
Number of pixels in the Y direction.

Returns the number of pixels in the Y direction. If the sky map is a one dimensional array (which is the case for the Healpix projection), the method returns 0.

Definition at line 379 of file GSkyMap.hpp.

References m_num_y.

Referenced by GCOMObservation::check_dri(), gammalib::com_wcs_mer2car(), extract(), GSkyMap(), GSPIResponse::load_irfs(), GLATEventCube::naxis(), GCTAEventCube::naxis(), GCOMDri::npsi(), GLATEventCube::ny(), GCTAEventCube::ny(), overlaps_circle(), GLATEventCube::print(), GCOMDri::print(), GSPIResponse::print(), GLATEventCube::read_srcmap(), and region_circle().

double & GSkyMap::operator() ( const int &  index,
const int &  map = 0 
)

Pixel index access operator.

Parameters
[in]indexPixel index [0,...,npix()-1].
[in]mapMap index [0,...,nmaps()-1].
Returns
Sky map pixel value.
Exceptions
GException::out_of_rangePixel index and/or map index are outside valid range.

Access sky map pixel by its index, where the most quickly varying axis is the x axis of the map.

Definition at line 789 of file GSkyMap.cpp.

References G_OP_ACCESS_1D, m_num_maps, m_num_pixels, and m_pixels.

Referenced by flux().

const double & GSkyMap::operator() ( const int &  index,
const int &  map = 0 
) const

Pixel index access operator (const variant)

Parameters
[in]indexPixel index [0,...,npix()-1].
[in]mapMap index [0,...,nmaps()-1].
Exceptions
GException::out_of_rangePixel index and/or map index are outside valid range.

Access sky map pixel by its index, where the most quickly varying axis is the x axis of the map.

Definition at line 822 of file GSkyMap.cpp.

References G_OP_ACCESS_1D, m_num_maps, m_num_pixels, and m_pixels.

double & GSkyMap::operator() ( const GSkyPixel pixel,
const int &  map = 0 
)

Sky map pixel access operator.

Parameters
[in]pixelSky map pixel.
[in]mapSky map index [0,...,nmaps()[.
Exceptions
GException::invalid_argumentSky pixel is not contained in sky map.
GException::out_of_rangeSky map index is out of range.

Access sky map pixel by its 2D index (x,y) that is implemented by the GSkyPixel class.

Definition at line 857 of file GSkyMap.cpp.

References contains(), G_OP_ACCESS_2D, m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, pix2inx(), gammalib::str(), GSkyPixel::x(), and GSkyPixel::y().

const double & GSkyMap::operator() ( const GSkyPixel pixel,
const int &  map = 0 
) const

Sky map pixel access operator.

Parameters
[in]pixelSky map pixel.
[in]mapSky map index [0,...,nmaps()[.
Exceptions
GException::invalid_argumentSky pixel is not contained in sky map.
GException::out_of_rangeSky map index is out of range.

Access sky map pixel by its 2D index (x,y) that is implemented by the GSkyPixel class.

Definition at line 897 of file GSkyMap.cpp.

References contains(), G_OP_ACCESS_2D, m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, pix2inx(), gammalib::str(), GSkyPixel::x(), and GSkyPixel::y().

double GSkyMap::operator() ( const GSkyDir dir,
const int &  map = 0 
) const

Return interpolated skymap value for sky direction.

Parameters
[in]dirSky direction.
[in]mapMap index [0,...,nmaps()-1].
Returns
Sky intensity.
Exceptions
GException::out_of_rangeMap index lies outside valid range.

Returns the skymap value for a given sky direction, obtained by bi-linear interpolation of the neighbouring pixels. If the sky direction falls outside the area covered by the skymap, a value of 0 is returned.

The method implements a computation cache that avoids recomputation of interpolation indices and weights in case that the same sky direction is requested several times. This speeds up use cases where skymap values for various map indices have to be returned for the same sky direction.

Definition at line 942 of file GSkyMap.cpp.

References abs(), contains(), GNdarray::data(), dir2pix(), G_OP_VALUE, GBilinear::index1(), GBilinear::index2(), GBilinear::index3(), GBilinear::index4(), m_contained, m_hascache, m_interpol, m_last_dir, m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_proj, GSkyProjection::size(), GBilinear::weight1(), GBilinear::weight2(), GBilinear::weight3(), GBilinear::weight4(), GSkyPixel::x(), and GSkyPixel::y().

GSkyMap GSkyMap::operator* ( const GSkyMap map) const
inline

Binary sky map multiplication.

Parameters
[in]mapSky map.
Returns
Sky map multiplied by map.

Returns the product of two sky maps.

Definition at line 288 of file GSkyMap.hpp.

GSkyMap & GSkyMap::operator*= ( const GSkyMap map)

Multiplication operator.

Parameters
[in]mapSky map.
Returns
Sky map.
Exceptions
GException::invalid_valueMismatch between number of maps in skymap object.

Multiplies the content of map from the skymap. The operator only works on sky maps with an identical number of layers.

If the sky maps have the same definitions, the operator will multiply the values of the sky map pixels. Otherwise, the map values are multiplied by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

Definition at line 578 of file GSkyMap.cpp.

References G_OP_UNARY_MUL, inx2dir(), is_same(), nmaps(), npix(), and gammalib::str().

GSkyMap & GSkyMap::operator*= ( const double &  factor)

Sky map scaling operator.

Parameters
[in]factorScale factor.
Returns
Sky map.

Multiplies all pixels of the sky map by the given scale factor.

Definition at line 641 of file GSkyMap.cpp.

References m_pixels.

GSkyMap GSkyMap::operator+ ( const GSkyMap map) const
inline

Binary sky map addition.

Parameters
[in]mapSky map.
Returns
Sky map to which map was added.

Returns the sum of two sky maps.

Definition at line 254 of file GSkyMap.hpp.

GSkyMap & GSkyMap::operator+= ( const GSkyMap map)

Map addition operator.

Parameters
[in]mapSky map.
Returns
Sky map.
Exceptions
GException::invalid_valueMismatch between number of maps in skymap object.

Adds the content of map to the skymap. The operator only works on sky maps with an identical number of maps.

If the sky maps have the same definitions, the operator will add the values of the sky map pixels. Otherwise, the map values are added by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

Definition at line 398 of file GSkyMap.cpp.

References G_OP_UNARY_ADD, inx2dir(), is_same(), nmaps(), npix(), and gammalib::str().

GSkyMap & GSkyMap::operator+= ( const double &  value)

Value addition operator.

Parameters
[in]valueValue.
Returns
Sky map.

Add value to all sky map pixels.

Definition at line 461 of file GSkyMap.cpp.

References m_pixels.

GSkyMap GSkyMap::operator- ( const GSkyMap map) const
inline

Binary sky map subtraction.

Parameters
[in]mapSky map.
Returns
Sky map to which map was added.

Returns the difference of two sky maps.

Definition at line 271 of file GSkyMap.hpp.

GSkyMap & GSkyMap::operator-= ( const GSkyMap map)

Map subtraction operator.

Parameters
[in]mapSky map.
Returns
Sky map.
Exceptions
GException::invalid_valueMismatch between number of maps in skymap object.

Subtracts the content of map from the skymap. The operator only works on sky maps with an identical number of layers.

If the sky maps have the same definitions, the operator will subtract the values of the sky map pixels. Otherwise, the map values are subtracted by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

Definition at line 488 of file GSkyMap.cpp.

References G_OP_UNARY_SUB, inx2dir(), is_same(), nmaps(), npix(), and gammalib::str().

GSkyMap & GSkyMap::operator-= ( const double &  value)

Value subtraction operator.

Parameters
[in]valueValue.
Returns
Sky map.

Subtracts value from all sky map pixels.

Definition at line 551 of file GSkyMap.cpp.

References m_pixels.

GSkyMap GSkyMap::operator/ ( const GSkyMap map) const
inline

Binary sky map division.

Parameters
[in]mapSky map.
Returns
Sky map divided by map.

Returns the ratio of two sky maps.

Definition at line 305 of file GSkyMap.hpp.

GSkyMap & GSkyMap::operator/= ( const GSkyMap map)

Division operator.

Parameters
[in]mapSky map.
Returns
Sky map.
Exceptions
GException::invalid_valueMismatch between number of maps in skymap object.

Divides the content of the actual skymap by the skymap map. The operator only works on sky maps with an identical number of layers.

If the sky maps have the same definitions, the operator will divide the values of the sky map pixels. Otherwise, the map values are divided by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

On return, all pixels in map that are zero are silently set to zero in the skymap, hence no division by zero exception will be raised in case that zero values are encountered.

Definition at line 672 of file GSkyMap.cpp.

References G_OP_UNARY_DIV, inx2dir(), is_same(), nmaps(), npix(), and gammalib::str().

GSkyMap & GSkyMap::operator/= ( const double &  factor)

Sky map division operator.

Parameters
[in]factorScale factor.
Returns
Sky map.
Exceptions
GException::invalid_argumentDivision by zero error.

Divides all pixels of the sky map by the given factor.

Definition at line 760 of file GSkyMap.cpp.

References G_OP_UNARY_DIV2, and m_pixels.

GSkyMap & GSkyMap::operator= ( const GSkyMap map)

Assignment operator.

Parameters
[in]mapSky map.
Returns
Sky map.

Assigns one sky map to another.

Definition at line 337 of file GSkyMap.cpp.

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

GSkyMap & GSkyMap::operator= ( const double &  value)

Value setting operator.

Parameters
[in]valueValue.
Returns
Sky map.

Sets all sky map pixels to the specified value.

Definition at line 366 of file GSkyMap.cpp.

References m_pixels, and GNdarray::size().

bool GSkyMap::overlaps ( const GSkyRegion region) const

Checks whether a region overlaps with this map.

Parameters
[in]regionRegion
Returns
True if region overlaps with map, false otherwise
Exceptions
GException::feature_not_implementedRegion is not a circular sky region

Definition at line 2102 of file GSkyMap.cpp.

References G_OVERLAPS, overlaps_circle(), and GSkyRegion::type().

Referenced by GCTACubeBackground::fill(), GCTACubeExposure::fill_cube(), GCTACubePsf::fill_cube(), and GCTACubeEdisp::fill_cube().

bool GSkyMap::overlaps_circle ( const GSkyRegionCircle region) const
private

Checks whether a circular region overlaps with this map.

Parameters
[in]regionCircular region
Returns
True if circular region overlaps with map, false otherwise

The check is done by first testing whether the central pointing position of the observation falls into the sky map. If this is false, then pixel positions that border the sky map are tested for whether or not they fall into the observation region. The positions tested can be visualized as follows, where '*' marks the positions tested.

*   *   *   *   *   *
  +---+---+---+---+
* |0,2|1,2|2,2|3,2| *
  +---+---+---+---+
* |0,1|1,1|2,1|3,1| *
  +---+---+---+---+
* |0,0|1,0|2,0|3,0| *
  +---+---+---+---+
*   *   *   *   *   *

Definition at line 3561 of file GSkyMap.cpp.

References GSkyRegionCircle::centre(), GSkyRegionCircle::contains(), contains(), nx(), ny(), pix2dir(), GSkyPixel::x(), and GSkyPixel::y().

Referenced by overlaps().

GSkyDir GSkyMap::pix2dir ( const GSkyPixel pixel) const

Returns sky direction of pixel.

Parameters
[in]pixelSky map pixel.
Returns
Sky direction.
Exceptions
GException::invalid_valueNo valid sky projection found.
GException::invalid_argument2D sky map pixel used to access 1D projection.

Returns sky direction for a given sky map pixel.

Definition at line 1360 of file GSkyMap.cpp.

References G_PIX2DIR, inx2pix(), m_proj, GSkyProjection::name(), GSkyProjection::pix2dir(), GSkyPixel::print(), GSkyProjection::size(), and GSkyPixel::size().

Referenced by extract(), flux(), GLATEventCube::maxrad(), GModelSpatialDiffuseMap::mc_cone(), GModelSpatialDiffuseCube::mc_cone(), overlaps_circle(), region_circle(), GLATEventCube::set_directions(), GCTAEventCube::set_directions(), and GCOMEventCube::set_scatter_directions().

int GSkyMap::pix2inx ( const GSkyPixel pixel) const

Converts sky map pixel into pixel index.

Parameters
[in]pixelSky map pixel.
Returns
Pixel index [0,...,npix()-1].

Converts a sky map pixel into the pixel index.

Definition at line 1407 of file GSkyMap.cpp.

References GSkyPixel::is_1D(), GSkyPixel::is_2D(), m_num_x, GSkyPixel::x(), and GSkyPixel::y().

Referenced by GCOMDri::compute_dre(), dir2inx(), and operator()().

std::string GSkyMap::print ( const GChatter chatter = NORMAL) const
virtual
const GSkyProjection * GSkyMap::projection ( void  ) const
inline

Returns pointer to sky projection.

Returns
Pointer to sky projection (NULL if no projection is defined).

Definition at line 465 of file GSkyMap.hpp.

References m_proj.

Referenced by GCOMObservation::check_dri(), gammalib::com_wcs_mer2car(), flux(), GSkyMap(), GLATEventCube::print(), GCOMDri::print(), GLATEventCube::read_srcmap(), region_circle(), gammalib::resolution(), and set_wcs().

void GSkyMap::projection ( const GSkyProjection proj)

Set sky projection.

Parameters
[in]projSky projection.

Sets the projection from celestial to pixel coordinates. The method performs a deep copy of proj, allowing to destroy the argument after using the method.

Warning: this method may corrupt the GSkyMap object as it allows assigning for example a 1D projection to a 2D skymap. Please use this method only when you know what you're doing.

Todo:
We may restrict this method to not allow changing the projection dimension.

Definition at line 1996 of file GSkyMap.cpp.

References GSkyProjection::clone(), and m_proj.

void GSkyMap::publish ( const std::string &  name = "") const

Publish sky map.

Parameters
[in]nameName of sky map.

Publishes the sky map on a Virtual Observatory Hub. If no Hub is currently active, the method will start a new Hub. If on sky map has been allocated the method does nothing.

Definition at line 2750 of file GSkyMap.cpp.

References GFitsHDU::extname(), GVOClient::publish(), and write().

void GSkyMap::read_healpix ( const GFitsTable table)
private

Read Healpix data from FITS table.

Parameters
[in]tableFITS table.
Exceptions
GException::runtime_errorIncompatible HealPix projection encountered.

HEALPix data may be stored in various formats depending on the application that has writted the data. HEALPix IDL, for example, may store the data in vectors of length 1024 if the number of pixels is a multiple of 1024. On the other hand, vectors may also be used to store several HEALPix maps into a single column. Alternatively, multiple maps may be stored in multiple columns.

Definition at line 3008 of file GSkyMap.cpp.

References GNdarray::data(), G_READ_HEALPIX, m_num_maps, m_num_pixels, m_pixels, m_proj, m_shape, GFitsTable::ncols(), npix(), GFitsTable::nrows(), GFitsTableCol::nrows(), GFitsTableCol::number(), GSkyProjection::read(), GFitsTableCol::real(), and gammalib::str().

Referenced by load(), and read().

void GSkyMap::read_wcs ( const GFitsImage image)
private

Read WCS image from FITS HDU.

Parameters
[in]imageFITS image.
Exceptions
GException::invalid_argumentFITS image has less than two dimensions
GException::invalid_valueSky map covers more than 360 deg in longitude or 180 deg in latitude

Reads sky maps from a FITS image extension containing a set of maps given in World Coordinate System. The method handles general n-dimensional images and sets the map shape attribute according to the number of map dimensions found in the FITS HDU.

Definition at line 3140 of file GSkyMap.cpp.

References abs(), alloc_wcs(), GNdarray::data(), G_READ_WCS, m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_proj, m_shape, GFitsImage::naxes(), GFitsImage::naxis(), GFitsImage::pixel(), GSkyProjection::read(), and gammalib::str().

Referenced by load(), and read().

GSkyRegionCircle GSkyMap::region_circle ( void  ) const

Return sky region circle that encloses the sky map.

Returns
Enclosing sky region circle.

Returns a sky region circle that encloses the sky map.

For a sky map in HealPix projection the method returns a region circle that encloses the full sky, with a centre at Right Ascension and Declination of 0 and a radius of 180 degrees.

For a sky map in World Coordinate projection the method returns a region circle that is centred on the central pixel of the sky map (i.e. the pixel with indices \((n_x/2,n_y/2)\), where \(n_x\) and \(n_y\) are the number of pixels in the X- and Y-drection) and a radius that is determined from the maximum radial distance of all pixels with respect to the central pixel.

Definition at line 2401 of file GSkyMap.cpp.

References gammalib::centre(), GSkyDir::dist_deg(), inx2dir(), inx2pix(), npix(), nx(), ny(), pix2dir(), projection(), GSkyPixel::x(), and GSkyPixel::y().

Referenced by GModelSpatialDiffuseCube::load_cube(), and GModelSpatialDiffuseMap::prepare_map().

void GSkyMap::save ( const GFilename filename,
const bool &  clobber = false 
) const

Save sky map into FITS file.

Parameters
[in]filenameFITS file name.
[in]clobberOverwrite existing file?

Saves the sky map into a FITS file. If the file exists already and the clobber parameter is true, the method will overwrite the content of the existing file. Otherwise, an exception is thrown.

Definition at line 2611 of file GSkyMap.cpp.

References GFits::append(), GSkyProjection::code(), create_healpix_hdu(), create_wcs_hdu(), GFitsHDU::extname(), GFilename::extname(), GFilename::has_extname(), m_proj, GFits::saveto(), and GFilename::url().

void GSkyMap::set_wcs ( const std::string &  wcs,
const std::string &  coords,
const double &  crval1,
const double &  crval2,
const double &  crpix1,
const double &  crpix2,
const double &  cdelt1,
const double &  cdelt2 
)
private

Set World Coordinate System.

Parameters
[in]wcsWorld Coordinate System code.
[in]coordsCoordinate system.
[in]crval1X value of reference pixel.
[in]crval2Y value of reference pixel.
[in]crpix1X index of reference pixel.
[in]crpix2Y index of reference pixel.
[in]cdelt1Increment in x direction at reference pixel (deg).
[in]cdelt2Increment in y direction at reference pixel (deg).
Exceptions
GException::invalid_argumentInvalid wcs parameter (World Coordinate System not known).

This method sets the WCS projection pointer based on the WCS code and sky map parameters. It makes use of the GWcsRegistry class to allocate the correct derived class. Note that this method does not support the HPX projection.

Definition at line 2946 of file GSkyMap.cpp.

References GWcsRegistry::alloc(), GRegistry::content(), G_SET_WCS, m_proj, projection(), GWcs::set(), and gammalib::toupper().

Referenced by GSkyMap().

const std::vector< int > & GSkyMap::shape ( void  ) const
inline
void GSkyMap::shape ( const int &  s1)

Set one-dimensional shape of maps.

Parameters
[in]s1Axis length of first dimension.

Definition at line 1185 of file GSkyMap.cpp.

References shape().

void GSkyMap::shape ( const int &  s1,
const int &  s2 
)

Set two-dimensional shape of maps.

Parameters
[in]s1Axis length of first dimension.
[in]s2Axis length of second dimension.

Definition at line 1207 of file GSkyMap.cpp.

References shape().

void GSkyMap::shape ( const int &  s1,
const int &  s2,
const int &  s3 
)

Set three-dimensional shape of maps.

Parameters
[in]s1Axis length of first dimension.
[in]s2Axis length of second dimension.
[in]s3Axis length of second dimension.

Definition at line 1231 of file GSkyMap.cpp.

References shape().

void GSkyMap::shape ( const std::vector< int > &  shape)

Set shape of maps.

Parameters
[in]shapeShape vector.
Exceptions
GException::invalid_argumentInvalid shape factorisation specified.

Defines a shape for the maps in the object. The shape specifies how the maps are arranged in a n-dimensional array.

Definition at line 1260 of file GSkyMap.cpp.

References G_SHAPE, m_num_maps, m_shape, nmaps(), shape(), and gammalib::str().

void GSkyMap::smooth ( const std::string &  kernel,
const double &  par 
)
inline

Smooth sky map.

Parameters
[in]kernelSmoothing kernel type ("DISK", "GAUSSIAN").
[in]parSmoothing parameter.

Smoothes all sky maps using the specified kernel and a smoothing parameter. For the "DISK" kernel the smoothing parameter is the disk radius in degrees. For the "GAUSSIAN" kernel the smoothing parameter is the Gaussian sigma in degrees.

Definition at line 433 of file GSkyMap.hpp.

References convolve().

Referenced by convolve().

double GSkyMap::solidangle ( const int &  index) const

Returns solid angle of pixel.

Parameters
[in]indexPixel index [0,...,npix()-1].
Returns
Solid angle (steradians)
Exceptions
GException::invalid_valueNo valid sky projection found.

Returns the solid angle of the pixel with the specified index.

Definition at line 1858 of file GSkyMap.cpp.

References G_SOLIDANGLE1, inx2pix(), and m_proj.

Referenced by GCOMDris::compute_drws_energy(), GCOMDris::compute_drws_phibar(), GSkyRegionMap::compute_solid_angle(), flux(), GCOMObservation::get_weighted_drg_map(), GResponse::irf_diffuse(), GLATEventCube::set_directions(), GCTAEventCube::set_directions(), GCOMEventCube::set_scatter_directions(), solidangle(), GCOMDris::vetorate_generate(), and GCOMDris::vetorate_setup().

double GSkyMap::solidangle ( const GSkyPixel pixel) const

Returns solid angle of pixel.

Parameters
[in]pixelSky map pixel.
Returns
Solid angle (steradians)
Exceptions
GException::invalid_valueNo valid sky projection found.

Returns the solid angle of the specified sky map pixel.

Definition at line 1885 of file GSkyMap.cpp.

References G_SOLIDANGLE2, inx2pix(), m_proj, GSkyProjection::name(), GSkyPixel::print(), GSkyProjection::size(), GSkyPixel::size(), GSkyProjection::solidangle(), and solidangle().

double GSkyMap::solidangle ( const GSkyRegion region) const

Returns solid angle within sky region.

Parameters
[in]regionSky region.
Returns
Solid angle within sky region.

The method returns the total solid angle of all sky map pixels that fall within the specified region. Containment is tested using the GSkyRegion::contains() method.

Definition at line 1934 of file GSkyMap.cpp.

References GSkyRegion::contains(), inx2dir(), m_num_pixels, and solidangle().

double GSkyMap::solidangle ( const GSkyRegions regions) const

Returns solid angle within sky regions.

Parameters
[in]regionsSky regions.
Returns
Solid angle within sky region.

The method returns the total solid angle of all sky map pixels that fall within the specified regions. Containment is tested using the GSkyRegions::contains() method.

Definition at line 1962 of file GSkyMap.cpp.

References GSkyRegions::contains(), inx2dir(), m_num_pixels, and solidangle().

double GSkyMap::solidangle ( const GSkyDir dir1,
const GSkyDir dir2,
const GSkyDir dir3 
) const
private

Compute solid angle subtended by 3 sky directions.

Parameters
[in]dir1First sky direction.
[in]dir2Second sky direction.
[in]dir3Third sky direction.
Returns
Solid angle (steradians).

Estimate the solid angle subtended by 3 sky directions using Huilier's theorem.

Below, the definiton of the pixel cornes and sides are shown as used within the code.

        a12
    1---------2
    |        / 
    |       /  
    |      /   
    |     /    
 a13|    /a23
    |   / 
    |  / 
    | /
    |/

Definition at line 3518 of file GSkyMap.cpp.

References atan(), GSkyDir::dist(), solidangle(), sqrt(), and tan().

double GSkyMap::solidangle ( const GSkyDir dir1,
const GSkyDir dir2,
const GSkyDir dir3,
const GSkyDir dir4 
) const
private

Compute solid angle subtended by 4 sky directions.

Parameters
[in]dir1First sky direction.
[in]dir2Second sky direction.
[in]dir3Third sky direction.
[in]dir4Forth sky direction.
Returns
Solid angle (steradians).

Estimate the solid angle subtended by 4 sky directions using Huilier's theorem.

Below, the definiton of the pixel cornes and sides are shown as used within the code.

        a12
    1---------2
    |\       /|
    | \a13  / |
    |  \   /  |
    |   \ /   |
 a14|    X    |a23
    |   / \   |
    |  /   \  |
    | /a24  \ |
    |/       \|
    4---------3
        a34

Definition at line 3430 of file GSkyMap.cpp.

References atan(), GSkyDir::dist(), solidangle(), sqrt(), and tan().

void GSkyMap::stack_maps ( void  )

Stack all maps into a single map.

The methods replaces the sky map by a version with only a single map by summing over the pixel values for all maps. If the sky map has no pixels or there is only a single map in the object, the method does nothing.

Definition at line 2341 of file GSkyMap.cpp.

References GSkyProjection::code(), m_num_maps, m_num_pixels, m_num_x, m_num_y, m_pixels, m_proj, m_shape, and sum().

GFitsHDU * GSkyMap::write ( GFits file,
const std::string &  extname = "" 
) const

Write sky map into FITS file.

Parameters
[in]fileFITS file pointer.
[in]extnameSky map extension name.
Returns
Pointer to written HDU.

Write the sky map into a FITS file. Optionally, the extension name of the FITS HDU can be specified using the extname parameter. The method returns a pointer to the appended HDU. If no HDU has been appended, for example because the sky map is empty, the method will return NULL.

Definition at line 2697 of file GSkyMap.cpp.

References GFits::append(), GSkyProjection::code(), create_healpix_hdu(), create_wcs_hdu(), GFitsHDU::extname(), and m_proj.

Referenced by publish(), GLATEventCube::write(), GCTACubeBackground::write(), GLATLtCubeMap::write(), GCTAEventCube::write(), GCTACubeExposure::write(), GCTACubePsf::write(), GCTACubeEdisp::write(), GSPIResponse::write(), GModelSpatialDiffuseCube::write(), and GCOMDri::write().

Friends And Related Function Documentation

GSkyMap abs ( const GSkyMap map)
friend

Computes the absolute value of sky map elements.

Parameters
[in]mapSky map.
Returns
Sky map containing the absolute value of every element.

Definition at line 4050 of file GSkyMap.cpp.

GSkyMap clip ( const GSkyMap map,
const double &  thresh 
)
friend

Clips map at given value.

Parameters
[in]mapSky map.
[in]threshThreshold value.
Returns
Sky map containing the value in the original map if >= thresh, otherwise thresh

Definition at line 4128 of file GSkyMap.cpp.

GSkyMap log ( const GSkyMap map)
friend

Computes the natural logarithm of sky map elements.

Parameters
[in]mapSky map.
Returns
Sky map containing the natural logarithm of every element.

Definition at line 3970 of file GSkyMap.cpp.

GSkyMap log10 ( const GSkyMap map)
friend

Computes the base 10 logarithm of sky map elements.

Parameters
[in]mapSky map.
Returns
Sky map containing the base 10 logarithm of every element.

Definition at line 4010 of file GSkyMap.cpp.

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

Non-equality operator.

Parameters
[in]aFirst sky map.
[in]bSecond sky map.
Returns
True if a and b are not identical.

Two sky maps are considered different if they either differ in projections, coordinate definiton or number of pixels. The actual content of the map does is not relevant.

Definition at line 4196 of file GSkyMap.cpp.

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

Equality operator.

Parameters
[in]aFirst sky map.
[in]bSecond sky map.
Returns
True if a and b are identical.

Two sky maps are considered identical if they have the same projections, coordinate definiton and number of pixels. The actual content of the map does not need to be identical.

Definition at line 4178 of file GSkyMap.cpp.

GSkyMap sign ( const GSkyMap map)
friend

Computes the sign value of sky map elements.

Parameters
[in]mapSky map.
Returns
Sky map containing the sign value of every pixel.

This method returns a sky map filled with a value of 1 if the pixel is positive, a value of -1 if the pixel is negative or a value of 0 if the pixel is 0.

Definition at line 4086 of file GSkyMap.cpp.

GSkyMap sqrt ( const GSkyMap map)
friend

Computes square root of sky map elements.

Parameters
[in]mapSky map.
Returns
Sky map containing the square root of every element.

Definition at line 3930 of file GSkyMap.cpp.

Member Data Documentation

bool GSkyMap::m_contained
mutableprivate

Sky direction is contained in map.

Definition at line 239 of file GSkyMap.hpp.

Referenced by copy_members(), extract(), init_members(), and operator()().

bool GSkyMap::m_hascache
mutableprivate

Cache is valid.

Definition at line 238 of file GSkyMap.hpp.

Referenced by copy_members(), extract(), init_members(), and operator()().

GBilinear GSkyMap::m_interpol
mutableprivate

Bilinear interpolator.

Definition at line 241 of file GSkyMap.hpp.

Referenced by copy_members(), extract(), init_members(), and operator()().

GSkyDir GSkyMap::m_last_dir
mutableprivate

Last sky direction.

Definition at line 240 of file GSkyMap.hpp.

Referenced by copy_members(), extract(), init_members(), and operator()().

int GSkyMap::m_num_maps
private
int GSkyMap::m_num_pixels
private
int GSkyMap::m_num_x
private
int GSkyMap::m_num_y
private

Number of pixels in y direction (only 2D)

Definition at line 232 of file GSkyMap.hpp.

Referenced by contains(), convolution_kernel(), convolve(), copy_members(), create_wcs_hdu(), extract(), GSkyMap(), init_members(), is_same(), ny(), operator()(), print(), read_wcs(), and stack_maps().

std::vector<int> GSkyMap::m_shape
private

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