GammaLib  1.7.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...
 
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...
 
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...
 
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...
 
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, const GMatrix &cd, const GVector &pv2)
 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...
 
GNdarray smooth_kernel (const std::string &kernel, const double &par) const
 Return smoothing 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...
 

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 113 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 131 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 152 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::skymap_bad_parInvalid sky map 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 179 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(), and projection().

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::skymap_bad_parInvalid sky map parameter.

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 230 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(), and set_wcs().

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 291 of file GSkyMap.cpp.

References copy_members(), and init_members().

GSkyMap::~GSkyMap ( void  )
virtual

Destructor.

Definition at line 307 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::fits_key_not_foundUnable to find required FITS header keyword.
GException::skymap_bad_ctypeCTYPE1 and CTYPE2 keywords are incompatible.
GException::wcs_invalidWCS projection of FITS file not supported by GammaLib.

Definition at line 2894 of file GSkyMap.cpp.

References GWcsRegistry::alloc(), G_ALLOC_WCS, GWcsRegistry::list(), 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 305 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 1008 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 1779 of file GSkyMap.cpp.

References dir2pix().

Referenced by GCOMDri::compute_dre(), GSkyRegionMap::contains(), 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 1806 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().

void GSkyMap::copy_members ( const GSkyMap map)
private

Copy class members.

Parameters
[in]mapSky map.

Definition at line 2554 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=().

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 1386 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 2934 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 2995 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 1335 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 1362 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 1936 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

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 2003 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

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 2082 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 1441 of file GSkyMap.cpp.

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

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

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

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 1632 of file GSkyMap.cpp.

References m_num_maps, m_num_pixels, and solidangle().

Referenced by flux().

void GSkyMap::free_members ( void  )
private

Delete class members.

Definition at line 2581 of file GSkyMap.cpp.

References m_proj.

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

void GSkyMap::init_members ( void  )
private
GSkyDir GSkyMap::inx2dir ( const int &  index) const
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 1191 of file GSkyMap.cpp.

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

Referenced by extract(), flux(), inx2dir(), pix2dir(), 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 319 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 3290 of file GSkyMap.cpp.

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

Referenced by load(), and read().

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 3316 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 2181 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 401 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 1029 of file GSkyMap.cpp.

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

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 349 of file GSkyMap.hpp.

References m_num_x.

Referenced by GCOMObservation::check_map(), gammalib::com_wcs_mer2car(), extract(), GSkyMap(), GLATEventCube::naxis(), GCTAEventCube::naxis(), GCOMDri::nchi(), GLATEventCube::nx(), GCTAEventCube::nx(), overlaps_circle(), GModelSpatialDiffuseMap::prepare_map(), GLATEventCube::print(), GCOMDri::print(), and GLATEventCube::read_srcmap().

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 365 of file GSkyMap.hpp.

References m_num_y.

Referenced by GCOMObservation::check_map(), gammalib::com_wcs_mer2car(), extract(), GSkyMap(), GLATEventCube::naxis(), GCTAEventCube::naxis(), GCOMDri::npsi(), GLATEventCube::ny(), GCTAEventCube::ny(), overlaps_circle(), GModelSpatialDiffuseMap::prepare_map(), GLATEventCube::print(), GCOMDri::print(), and GLATEventCube::read_srcmap().

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 683 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 716 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]mapMap index [0,...,nmaps()-1].
Exceptions
GException::out_of_rangeSky pixel and/or map index are outside valid range.

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

Todo:
Implement proper skymap exception (actual is for matrix elements)

Definition at line 751 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(), 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]mapMap index [0,...,nmaps()-1].
Exceptions
GException::out_of_rangeSky pixel and/or map index are outside valid range.

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

Todo:
Implement proper skymap exception (actual is for matrix elements)

Definition at line 789 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(), 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 832 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 274 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. The content is multiplied by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

Todo:
The method is not optimized for speed as the transformation is done for each layer separately. A private method should be introduced that does the transformation, allowing to loop more effectively over the layers.

Definition at line 532 of file GSkyMap.cpp.

References G_OP_UNARY_MUL, inx2dir(), 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 572 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 240 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. The content is added by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

Todo:
The method is not optimized for speed as the transformation is done for each layer separately. A private method should be introduced that does the transformation, allowing the to loop more effectively over the layers.

Definition at line 394 of file GSkyMap.cpp.

References G_OP_UNARY_ADD, inx2dir(), 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 434 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 257 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. The content is subtracted by bi-linearily interpolating the values in the source sky map, allowing thus for a reprojection of sky map values.

Todo:
The method is not optimized for speed as the transformation is done for each layer separately. A private method should be introduced that does the transformation, allowing the to loop more effectively over the layers.

Definition at line 463 of file GSkyMap.cpp.

References G_OP_UNARY_SUB, inx2dir(), 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 503 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 291 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. The content is divided by bi-linearily interpolating the values in the skymap 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.

Definition at line 599 of file GSkyMap.cpp.

References G_OP_UNARY_DIV, inx2dir(), 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 654 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 331 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 360 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 1844 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 3227 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 1250 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(), overlaps_circle(), GModelSpatialDiffuseMap::prepare_map(), GLATEventCube::set_directions(), GCTAEventCube::set_directions(), GModelSpatialDiffuseMap::set_mc_cone(), GModelSpatialDiffuseCube::set_mc_cone(), 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 1297 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()().

const double * GSkyMap::pixels ( void  ) const
inline

Returns pointer to pixel data.

Returns
Pointer to pixel data.

Definition at line 425 of file GSkyMap.hpp.

References GNdarray::data(), and m_pixels.

Referenced by GCOMModelDRBFitting::eval(), GLATResponse::irf(), GLATEventCube::number(), GCTAEventCube::number(), GCOMDri::operator[](), GLATEventCube::set_bin(), and GCTAEventCube::set_bin().

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 413 of file GSkyMap.hpp.

References m_proj.

Referenced by GCOMObservation::check_map(), gammalib::com_wcs_mer2car(), flux(), GSkyMap(), GModelSpatialDiffuseMap::prepare_map(), GLATEventCube::print(), GCOMDri::print(), GLATEventCube::read_srcmap(), 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 1752 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 2420 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.

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 2674 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(), and GFitsTableCol::real().

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

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 2281 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,
const GMatrix cd,
const GVector pv2 
)
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).
[in]cdAstrometry parameters (2x2 matrix, deg/pixel).
[in]pv2Projection parameters (length WCS type dependent).
Exceptions
GException::wcs_invalidInvalid 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.

Todo:
Remove cd and pv2 parameters.

Definition at line 2620 of file GSkyMap.cpp.

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

Referenced by GSkyMap().

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

Returns shape of maps.

Returns
Shape of maps in the sky map object.

Definition at line 389 of file GSkyMap.hpp.

References m_shape.

Referenced by GCTACubeEdisp::GCTACubeEdisp(), GCTACubePsf::GCTACubePsf(), print(), and shape().

void GSkyMap::shape ( const int &  s1)

Set one-dimensional shape of maps.

Parameters
[in]s1Axis length of first dimension.

Definition at line 1075 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 1097 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 1121 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 1150 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 
)

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 1878 of file GSkyMap.cpp.

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

GNdarray GSkyMap::smooth_kernel ( const std::string &  kernel,
const double &  par 
) const
private

Return smoothing kernel.

Parameters
[in]kernelSmoothing kernel type ("DISK", "GAUSSIAN").
[in]parSmoothing parameter (>0).
Returns
Array filled with smoothing kernel.

Definition at line 3339 of file GSkyMap.cpp.

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

Referenced by smooth().

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 1670 of file GSkyMap.cpp.

References G_SOLIDANGLE1, inx2pix(), and m_proj.

Referenced by GSkyRegionMap::compute_solid_angle(), flux(), GLATEventCube::set_directions(), GCTAEventCube::set_directions(), GCOMEventCube::set_scatter_directions(), and solidangle().

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 1697 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 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 3181 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 3093 of file GSkyMap.cpp.

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

void GSkyMap::stack_maps ( void  )

Stack all maps into a single map.

Returns
Stacked 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 2135 of file GSkyMap.cpp.

References m_num_maps, m_num_pixels, m_pixels, 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 2367 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(), GCOMDri::write(), and GModelSpatialDiffuseCube::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 3575 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 3653 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 3495 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 3535 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 3611 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 3455 of file GSkyMap.cpp.

Member Data Documentation

bool GSkyMap::m_contained
mutableprivate

Sky direction is contained in map.

Definition at line 225 of file GSkyMap.hpp.

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

bool GSkyMap::m_hascache
mutableprivate

Cache is valid.

Definition at line 224 of file GSkyMap.hpp.

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

GBilinear GSkyMap::m_interpol
mutableprivate

Bilinear interpolator.

Definition at line 227 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 226 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

Number of pixels in x direction (only 2D)

Definition at line 217 of file GSkyMap.hpp.

Referenced by contains(), copy_members(), create_wcs_hdu(), extract(), GSkyMap(), init_members(), inx2pix(), nx(), operator()(), pix2inx(), print(), read_wcs(), smooth(), and smooth_kernel().

int GSkyMap::m_num_y
private

Number of pixels in y direction (only 2D)

Definition at line 218 of file GSkyMap.hpp.

Referenced by contains(), copy_members(), create_wcs_hdu(), extract(), GSkyMap(), init_members(), ny(), operator()(), print(), read_wcs(), smooth(), and smooth_kernel().

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

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