GammaLib
2.1.0.dev
|
Sky map class. More...
#include <GSkyMap.hpp>
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... | |
GSkyMap & | operator= (const GSkyMap &map) |
Assignment operator. More... | |
GSkyMap & | operator= (const double &value) |
Value setting operator. More... | |
GSkyMap & | operator+= (const GSkyMap &map) |
Map addition operator. More... | |
GSkyMap & | operator+= (const double &value) |
Value addition operator. More... | |
GSkyMap & | operator-= (const GSkyMap &map) |
Map subtraction operator. More... | |
GSkyMap & | operator-= (const double &value) |
Value subtraction operator. More... | |
GSkyMap & | operator*= (const GSkyMap &map) |
Multiplication operator. More... | |
GSkyMap & | operator*= (const double &factor) |
Sky map scaling operator. More... | |
GSkyMap & | operator/= (const GSkyMap &map) |
Division operator. More... | |
GSkyMap & | operator/= (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... | |
GSkyMap * | clone (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 ®ion, const int &map=0) const |
Returns flux within sky region. More... | |
double | flux (const GSkyRegions ®ions, 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 ®ion) const |
Returns solid angle within sky region. More... | |
double | solidangle (const GSkyRegions ®ions) 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 ®ion) 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 GSkyProjection * | projection (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... | |
GFitsHDU * | write (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... | |
GFitsBinTable * | create_healpix_hdu (void) const |
Create FITS HDU containing Healpix data. More... | |
GFitsImageDouble * | create_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 ®ion) 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... | |
GSkyProjection * | m_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... | |
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.
GSkyMap::GSkyMap | ( | void | ) |
Void constructor.
Constructs an empty sky map.
Definition at line 116 of file GSkyMap.cpp.
References init_members().
Referenced by clone().
|
explicit |
FITS file constructor.
[in] | filename | FITS 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().
|
explicit |
FITS HDU constructor.
[in] | hdu | FITS 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.
[in] | coords | Coordinate System (CEL or GAL). |
[in] | nside | Nside parameter. |
[in] | order | Pixel ordering (RING or NEST). |
[in] | nmaps | Number of maps in set. |
GException::invalid_argument | Invalid 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.
[in] | wcs | World Coordinate System. |
[in] | coords | Coordinate System (CEL or GAL). |
[in] | x | X coordinate of sky map centre (deg). |
[in] | y | Y coordinate of sky map centre (deg). |
[in] | dx | Pixel size in x direction at centre (deg/pixel). |
[in] | dy | Pixel size in y direction at centre (deg/pixel). |
[in] | nx | Number of pixels in x direction. |
[in] | ny | Number of pixels in y direction. |
[in] | nmaps | Number of maps in set (default=1). |
GException::invalid_argument | Invalid 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.
[in] | map | Sky 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().
|
virtual |
|
private |
Allocate WCS class.
[in] | image | FITS image. |
GException::invalid_argument | CTYPE1 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().
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 319 of file GSkyMap.hpp.
|
virtual |
Clear instance.
Resets the sky map to the initial state.
Implements GBase.
Definition at line 1100 of file GSkyMap.cpp.
References free_members(), and init_members().
Referenced by GSkyRegionMap::init_members(), GCTACubeBackground::init_members(), GLATLtCubeMap::init_members(), GCTAModelSkyCube::init_members(), GCTACubeExposure::init_members(), GLATEventCube::init_members(), GModelSpatialDiffuseMap::init_members(), GCTAEventCube::init_members(), GCTACubePsf::init_members(), GSPIResponse::init_members(), GCTACubeEdisp::init_members(), GModelSpatialDiffuseCube::init_members(), GCOMDri::init_members(), GModelSpatialDiffuseMap::load(), load(), GModelSpatialDiffuseCube::load_cube(), GSPIResponse::load_irfs(), GModelSpatialDiffuseCube::read(), and GSPIResponse::set().
|
virtual |
Clone 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.
[in] | dir | Sky direction. |
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.
[in] | pixel | Sky map pixel. |
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().
|
private |
Return convolution kernel.
[in] | kernel | Convolution kernel type ("DISK", "GAUSSIAN"). |
[in] | par | Convolution parameter (>0). |
[in] | normalise | Normalise 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().
|
private |
Convolve sky map.
[in] | kernel | Convolution kernel type ("DISK", "GAUSSIAN"). |
[in] | par | Convolution parameter. |
[in] | normalise | Normalise 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().
|
private |
Copy class members.
[in] | map | Sky 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=().
|
inline |
Correlates sky map.
[in] | kernel | Correlation kernel type ("DISK", "GAUSSIAN"). |
[in] | par | Correlation 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.
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().
|
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().
|
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.
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().
int GSkyMap::dir2inx | ( | const GSkyDir & | dir | ) | const |
Returns pixel index for a given sky direction.
[in] | dir | Sky direction. |
GException::invalid_value | No 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().
Returns sky map pixel for a given sky direction.
[in] | dir | Sky direction. |
GException::invalid_value | No 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.
[in] | map | First map to extract |
[in] | nmaps | Number of maps to extract |
GException::out_of_range | First map index outside valid range |
GException::invalid_argument | Requested 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.
[in] | startx | Starting bin in X (inclusive) |
[in] | stopx | Last bin in X (inclusive) |
[in] | starty | Starting bin in Y (inclusive) |
[in] | stopy | Last bin in Y (inclusive) |
GException::invalid_argument | Method 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
.
[in] | inclusions | List of GSkyRegion objects |
GException::invalid_argument | Method 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.
GException::invalid_value | No 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.
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.
[in] | pixel | Sky map pixel. |
[in] | map | Map index [0,...,nmaps()-1]. |
GException::invalid_value | No 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.
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.
[in] | region | Sky region. |
[in] | map | Map index [0,...,nmaps()-1]. |
GException::out_of_range | Map 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.
[in] | regions | Sky regions. |
[in] | map | Map index [0,...,nmaps()-1]. |
GException::out_of_range | Map 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.
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().
|
private |
Delete class members.
Definition at line 2911 of file GSkyMap.cpp.
References m_proj.
Referenced by clear(), operator=(), read(), and ~GSkyMap().
|
private |
Initialise class members.
Definition at line 2857 of file GSkyMap.cpp.
References GBilinear::clear(), GSkyDir::clear(), GNdarray::clear(), 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 clear(), GSkyMap(), operator=(), and read().
GSkyDir GSkyMap::inx2dir | ( | const int & | index | ) | const |
Returns sky direction of pixel.
[in] | index | Pixel index [0,...,npix()-1]. |
GException::invalid_value | No valid sky projection found. |
Returns sky direction for a given pixel index.
Definition at line 1331 of file GSkyMap.cpp.
References G_INX2DIR, inx2pix(), m_proj, and GSkyProjection::pix2dir().
Referenced by GCOMDri::compute_drg(), GCOMDris::compute_drws_energy(), GCOMDris::compute_drws_phibar(), GCOMDri::compute_drx(), GCOMDri::cone_content(), GSkyRegionMap::contains(), GCTACubeExposure::fill_cube(), GCTACubePsf::fill_cube(), GCTACubeEdisp::fill_cube(), flux(), GResponse::irf_diffuse(), operator*=(), operator+=(), operator-=(), operator/=(), GSkyRegionMap::overlaps(), region_circle(), GSkyRegionMap::set_region_circle(), solidangle(), GCOMDris::vetorate_generate(), and GCOMDris::vetorate_setup().
GSkyPixel GSkyMap::inx2pix | ( | const int & | index | ) | const |
Converts pixel index into sky map pixel.
[in] | index | Pixel index [0,...,npix()-1]. |
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().
|
inline |
Signals if sky map is empty.
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.
|
private |
Check if HDU contains HEALPix data.
[in] | hdu | FITS Header Data Unit. |
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().
|
private |
Check if map is the same.
[in] | map | Sky map. |
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==().
|
private |
Check if HDU contains WCS data.
[in] | hdu | FITS Header Data Unit. |
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().
void GSkyMap::load | ( | const GFilename & | filename | ) |
Load skymap from FITS file.
[in] | filename | FITS 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.
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().
|
inline |
Returns dimension of maps.
Definition at line 415 of file GSkyMap.hpp.
References m_shape.
Referenced by create_wcs_hdu().
|
inline |
Returns number of maps.
Definition at line 391 of file GSkyMap.hpp.
References m_num_maps.
Referenced by abs(), GCOMObservation::check_dri(), GCTACubePsf::clear_cube(), GCTACubeEdisp::clear_cube(), clip(), GSPIResponse::compute_irf(), GLATEventCube::dim(), GCTAEventCube::dim(), GLATEventCube::ebins(), GCTAEventCube::ebins(), GModelSpatialDiffuseCube::energies(), GCOMModelDRBPhibarBins::eval(), extract(), GCOMDri::GCOMDri(), GCTACubeBackground::GCTACubeBackground(), GCTACubeEdisp::GCTACubeEdisp(), GCTACubeExposure::GCTACubeExposure(), GCTACubePsf::GCTACubePsf(), GCOMObservation::get_weighted_drg_map(), GSkyMap(), GModelSpatialDiffuseCube::load_cube(), GSPIResponse::load_irfs(), log(), log10(), GModelSpatialDiffuseCube::mc_cone(), GCTAEventCube::naxis(), nmaps(), GCOMDri::nphibar(), operator*=(), operator+=(), operator-=(), operator/=(), GCOMDri::print(), GCOMObservation::print(), GModelSpatialDiffuseCube::read(), GLATEventCube::read_srcmap(), GSPIResponse::set(), shape(), sign(), GLATEventCube::size(), GCTAEventCube::size(), GCOMDri::size(), and sqrt().
void GSkyMap::nmaps | ( | const int & | nmaps | ) |
Set number of maps.
[in] | nmaps | Number of maps. |
GException::invalid_argument | Invalid 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().
|
inline |
Returns number of pixels.
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().
|
inline |
Returns number of pixels in x coordinate.
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().
|
inline |
Returns number of pixels in y coordinate.
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.
GException::out_of_range | Pixel 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)
GException::out_of_range | Pixel 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.
[in] | pixel | Sky map pixel. |
[in] | map | Sky map index [0,...,nmaps()[. |
GException::invalid_argument | Sky pixel is not contained in sky map. |
GException::out_of_range | Sky 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.
[in] | pixel | Sky map pixel. |
[in] | map | Sky map index [0,...,nmaps()[. |
GException::invalid_argument | Sky pixel is not contained in sky map. |
GException::out_of_range | Sky 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.
[in] | dir | Sky direction. |
[in] | map | Map index [0,...,nmaps()-1]. |
GException::out_of_range | Map 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().
Binary sky map multiplication.
[in] | map | Sky map. |
map
.Returns the product of two sky maps.
Definition at line 288 of file GSkyMap.hpp.
Multiplication operator.
[in] | map | Sky map. |
GException::invalid_value | Mismatch 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.
[in] | factor | Scale factor. |
Multiplies all pixels of the sky map by the given scale factor
.
Definition at line 641 of file GSkyMap.cpp.
References m_pixels.
Binary sky map addition.
[in] | map | Sky map. |
map
was added.Returns the sum of two sky maps.
Definition at line 254 of file GSkyMap.hpp.
Map addition operator.
[in] | map | Sky map. |
GException::invalid_value | Mismatch 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.
[in] | value | Value. |
Add value
to all sky map pixels.
Definition at line 461 of file GSkyMap.cpp.
References m_pixels.
Binary sky map subtraction.
[in] | map | Sky map. |
map
was added.Returns the difference of two sky maps.
Definition at line 271 of file GSkyMap.hpp.
Map subtraction operator.
[in] | map | Sky map. |
GException::invalid_value | Mismatch 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.
[in] | value | Value. |
Subtracts value
from all sky map pixels.
Definition at line 551 of file GSkyMap.cpp.
References m_pixels.
Binary sky map division.
[in] | map | Sky map. |
map
.Returns the ratio of two sky maps.
Definition at line 305 of file GSkyMap.hpp.
Division operator.
[in] | map | Sky map. |
GException::invalid_value | Mismatch 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.
[in] | factor | Scale factor. |
GException::invalid_argument | Division 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.
Assignment operator.
[in] | map | 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.
[in] | value | Value. |
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.
[in] | region | Region |
GException::feature_not_implemented | Region 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().
|
private |
Checks whether a circular region overlaps with this map.
[in] | region | Circular region |
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().
Returns sky direction of pixel.
[in] | pixel | Sky map pixel. |
GException::invalid_value | No valid sky projection found. |
GException::invalid_argument | 2D 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.
[in] | pixel | Sky map pixel. |
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()().
|
inline |
Returns pointer to pixel data.
Definition at line 477 of file GSkyMap.hpp.
References GNdarray::data(), and m_pixels.
Referenced by GCOMModelDRM::eval(), GCOMModelDRBPhibarBins::eval(), GCOMModelDRBPhibarNodes::eval(), GCOMResponse::irf_diffuse(), GCOMResponse::irf_elliptical(), GCOMResponse::irf_ptsrc(), GCOMResponse::irf_radial(), GLATResponse::irf_spatial_bin(), GLATEventCube::number(), GCTAEventCube::number(), GCOMDri::operator[](), GLATEventCube::set_bin(), and GCTAEventCube::set_bin().
Print sky map.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 2787 of file GSkyMap.cpp.
References m_num_maps, m_num_pixels, m_num_x, m_num_y, m_proj, m_shape, gammalib::parformat(), GSkyProjection::print(), gammalib::reduce(), shape(), SILENT, GSkyProjection::size(), and gammalib::str().
Referenced by GSkyRegionMap::print(), GCOMDri::print(), GCTACubeBackground::print(), GLATLtCubeMap::print(), GModelSpatialDiffuseCube::print(), GCTAEventCube::print(), GCTACubeExposure::print(), GCTACubePsf::print(), and GCTACubeEdisp::print().
|
inline |
Returns pointer to sky projection.
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.
[in] | proj | Sky 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.
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.
[in] | name | Name 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 | ( | const GFitsHDU & | hdu | ) |
Read skymap from FITS HDU.
[in] | hdu | FITS HDU. |
Definition at line 2664 of file GSkyMap.cpp.
References free_members(), init_members(), is_healpix(), is_wcs(), read_healpix(), and read_wcs().
Referenced by GSkyMap(), GCTAModelSkyCube::load(), GCTACubeBackground::read(), GLATLtCubeMap::read(), GCTAEventCube::read(), GCTACubeExposure::read(), GCTACubePsf::read(), GCTACubeEdisp::read(), GSPIResponse::read(), GModelSpatialDiffuseCube::read(), GCOMDri::read(), GLATEventCube::read_cntmap(), GCTAEventCube::read_cntmap(), and GLATEventCube::read_srcmap().
|
private |
Read Healpix data from FITS table.
[in] | table | FITS table. |
GException::runtime_error | Incompatible 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().
|
private |
Read WCS image from FITS HDU.
[in] | image | FITS image. |
GException::invalid_argument | FITS image has less than two dimensions |
GException::invalid_value | Sky 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().
GSkyRegionCircle GSkyMap::region_circle | ( | void | ) | const |
Return sky region circle that encloses the sky map.
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.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite 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().
|
private |
Set World Coordinate System.
[in] | wcs | World Coordinate System code. |
[in] | coords | Coordinate system. |
[in] | crval1 | X value of reference pixel. |
[in] | crval2 | Y value of reference pixel. |
[in] | crpix1 | X index of reference pixel. |
[in] | crpix2 | Y index of reference pixel. |
[in] | cdelt1 | Increment in x direction at reference pixel (deg). |
[in] | cdelt2 | Increment in y direction at reference pixel (deg). |
GException::invalid_argument | Invalid 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().
|
inline |
Returns shape of maps.
Definition at line 403 of file GSkyMap.hpp.
References m_shape.
Referenced by GSPIResponse::compute_irf(), GCTACubeEdisp::GCTACubeEdisp(), GCTACubePsf::GCTACubePsf(), GSPIResponse::irf_value(), GSPIResponse::load_irf(), GSPIResponse::load_irfs(), GSPIResponse::print(), print(), GSPIResponse::set(), and shape().
void GSkyMap::shape | ( | const int & | s1 | ) |
Set one-dimensional shape of maps.
[in] | s1 | Axis 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.
[in] | s1 | Axis length of first dimension. |
[in] | s2 | Axis 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.
[in] | s1 | Axis length of first dimension. |
[in] | s2 | Axis length of second dimension. |
[in] | s3 | Axis 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.
[in] | shape | Shape vector. |
GException::invalid_argument | Invalid 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().
|
inline |
Smooth sky map.
[in] | kernel | Smoothing kernel type ("DISK", "GAUSSIAN"). |
[in] | par | Smoothing 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.
[in] | index | Pixel index [0,...,npix()-1]. |
GException::invalid_value | No 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.
[in] | pixel | Sky map pixel. |
GException::invalid_value | No 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.
[in] | region | 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.
[in] | regions | Sky regions. |
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().
|
private |
Compute solid angle subtended by 3 sky directions.
[in] | dir1 | First sky direction. |
[in] | dir2 | Second sky direction. |
[in] | dir3 | Third sky direction. |
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().
|
private |
Compute solid angle subtended by 4 sky directions.
[in] | dir1 | First sky direction. |
[in] | dir2 | Second sky direction. |
[in] | dir3 | Third sky direction. |
[in] | dir4 | Forth sky direction. |
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().
Write sky map into FITS file.
[in] | file | FITS file pointer. |
[in] | extname | Sky map extension name. |
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().
Computes the absolute value of sky map elements.
[in] | map | Sky map. |
Definition at line 4050 of file GSkyMap.cpp.
Clips map at given value.
[in] | map | Sky map. |
[in] | thresh | Threshold value. |
Definition at line 4128 of file GSkyMap.cpp.
Computes the natural logarithm of sky map elements.
[in] | map | Sky map. |
Definition at line 3970 of file GSkyMap.cpp.
Computes the base 10 logarithm of sky map elements.
[in] | map | Sky map. |
Definition at line 4010 of file GSkyMap.cpp.
Non-equality operator.
[in] | a | First sky map. |
[in] | b | Second sky map. |
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.
Equality operator.
[in] | a | First sky map. |
[in] | b | Second sky map. |
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.
Computes the sign value of sky map elements.
[in] | map | Sky map. |
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.
Computes square root of sky map elements.
[in] | map | Sky map. |
Definition at line 3930 of file GSkyMap.cpp.
|
mutableprivate |
Sky direction is contained in map.
Definition at line 239 of file GSkyMap.hpp.
Referenced by copy_members(), extract(), init_members(), and operator()().
|
mutableprivate |
Cache is valid.
Definition at line 238 of file GSkyMap.hpp.
Referenced by copy_members(), extract(), init_members(), and operator()().
|
mutableprivate |
Bilinear interpolator.
Definition at line 241 of file GSkyMap.hpp.
Referenced by copy_members(), extract(), init_members(), and operator()().
|
mutableprivate |
Last sky direction.
Definition at line 240 of file GSkyMap.hpp.
Referenced by copy_members(), extract(), init_members(), and operator()().
|
private |
Number of maps (used for pixel allocation)
Definition at line 230 of file GSkyMap.hpp.
Referenced by convolve(), copy_members(), counts(), create_healpix_hdu(), create_wcs_hdu(), extract(), flux(), GSkyMap(), init_members(), is_empty(), nmaps(), operator()(), print(), read_healpix(), read_wcs(), shape(), and stack_maps().
|
private |
Number of pixels (used for pixel allocation)
Definition at line 229 of file GSkyMap.hpp.
Referenced by contains(), convolve(), copy_members(), counts(), create_healpix_hdu(), create_wcs_hdu(), extract(), flux(), GSkyMap(), init_members(), is_empty(), nmaps(), npix(), operator()(), print(), read_healpix(), read_wcs(), solidangle(), and stack_maps().
|
private |
Number of pixels in x direction (only 2D)
Definition at line 231 of file GSkyMap.hpp.
Referenced by contains(), convolution_kernel(), convolve(), copy_members(), create_wcs_hdu(), extract(), GSkyMap(), init_members(), inx2pix(), is_same(), nx(), operator()(), pix2inx(), print(), read_wcs(), and stack_maps().
|
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().
|
private |
Skymap pixels.
Definition at line 235 of file GSkyMap.hpp.
Referenced by convolve(), copy_members(), create_healpix_hdu(), create_wcs_hdu(), extract(), flux(), GSkyMap(), init_members(), nmaps(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), pixels(), read_healpix(), read_wcs(), and stack_maps().
|
private |
Pointer to sky projection.
Definition at line 234 of file GSkyMap.hpp.
Referenced by alloc_wcs(), convolution_kernel(), copy_members(), create_healpix_hdu(), create_wcs_hdu(), dir2inx(), dir2pix(), extract(), flux(), free_members(), GSkyMap(), init_members(), inx2dir(), is_same(), operator()(), pix2dir(), print(), projection(), read_healpix(), read_wcs(), save(), set_wcs(), solidangle(), stack_maps(), and write().
|
private |
Shape of the maps.
Definition at line 233 of file GSkyMap.hpp.
Referenced by copy_members(), create_wcs_hdu(), extract(), GSkyMap(), init_members(), ndim(), nmaps(), print(), read_healpix(), read_wcs(), shape(), and stack_maps().