GammaLib
2.1.0.dev
|
Fermi/LAT event cube class. More...
#include <GLATEventCube.hpp>
Public Member Functions | |
GLATEventCube (void) | |
Void constructor. More... | |
GLATEventCube (const GFilename &filename) | |
File name constructor. More... | |
GLATEventCube (const GLATEventCube &cube) | |
Copy constructor. More... | |
virtual | ~GLATEventCube (void) |
Destructor. More... | |
virtual GLATEventCube & | operator= (const GLATEventCube &cube) |
Assignment operator. More... | |
virtual GLATEventBin * | operator[] (const int &index) |
Event bin access operator. More... | |
virtual const GLATEventBin * | operator[] (const int &index) const |
Event bin access operator (const version) More... | |
virtual void | clear (void) |
Clear instance. More... | |
virtual GLATEventCube * | clone (void) const |
Clone instance. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual int | size (void) const |
Return number of bins in event cube. More... | |
virtual int | dim (void) const |
Return dimension of event cube. More... | |
virtual int | naxis (const int &axis) const |
Return number of bins in axis. More... | |
virtual void | load (const GFilename &filename) |
Load LAT event cube from FITS file. More... | |
virtual void | save (const GFilename &filename, const bool &clobber=false) const |
Save LAT event cube into FITS file. More... | |
virtual void | read (const GFits &file) |
Read LAT event cube from FITS file. More... | |
virtual void | write (GFits &file) const |
Write LAT event cube into FITS file. More... | |
virtual int | number (void) const |
Return number of events in cube. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print event cube information. More... | |
void | time (const GTime &time) |
Set event cube mean time. More... | |
void | map (const GSkyMap &map) |
Set event cube from sky map. More... | |
void | enodes (const GNodeArray &enodes) |
Set event cube energy nodes. More... | |
void | ontime (const double &ontime) |
Set event cube ontime. More... | |
const GTime & | time (void) const |
Return event cube mean time. More... | |
const GSkyMap & | map (void) const |
Return event cube sky map. More... | |
const GNodeArray & | enodes (void) const |
Return event cube energy nodes. More... | |
const double & | ontime (void) const |
Return event cube ontime. More... | |
int | nx (void) const |
Return number of bins in X direction. More... | |
int | ny (void) const |
Return number of bins in Y direction. More... | |
int | npix (void) const |
Return number of pixels in event cube sky map. More... | |
int | ebins (void) const |
Return number of energy bins in event cube. More... | |
int | ndiffrsp (void) const |
Return number of diffuse model components. More... | |
std::string | diffname (const int &index) const |
Return name of diffuse model. More... | |
GSkyMap * | diffrsp (const int &index) const |
Return diffuse response map. More... | |
double | maxrad (const GSkyDir &dir) const |
Computes the maximum radius (in degrees) around a given source direction that fits spatially into the event cube. More... | |
Public Member Functions inherited from GEventCube | |
GEventCube (void) | |
Void constructor. More... | |
GEventCube (const GEventCube &cube) | |
Copy constructor. More... | |
virtual | ~GEventCube (void) |
Destructor. More... | |
virtual GEventCube & | operator= (const GEventCube &cube) |
Assignment operator. More... | |
Public Member Functions inherited from GEvents | |
GEvents (void) | |
Void constructor. More... | |
GEvents (const GEvents &events) | |
Copy constructor. More... | |
virtual | ~GEvents (void) |
Destructor. More... | |
virtual GEvents & | operator= (const GEvents &events) |
Assignment operator. More... | |
void | ebounds (const GEbounds &ebounds) |
Set energy boundaries. More... | |
void | gti (const GGti >i) |
Set Good Time Intervals. More... | |
const GEbounds & | ebounds (void) const |
Return energy boundaries. More... | |
const GGti & | gti (void) const |
Return Good Time Intervals. More... | |
const GTime & | tstart (void) const |
Return start time. More... | |
const GTime & | tstop (void) const |
Return stop time. More... | |
const GEnergy & | emin (void) const |
Return minimum energy. More... | |
const GEnergy & | emax (void) const |
Return maximum energy. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GLATEventCube &cube) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | read_cntmap (const GFitsImage &hdu) |
Read Fermi/LAT counts map from HDU. More... | |
void | read_srcmap (const GFitsImage &hdu) |
Read LAT source map from HDU. More... | |
void | read_ebds (const GFitsTable &hdu) |
Read energy boundaries from HDU. More... | |
void | read_gti (const GFitsTable &hdu) |
Read GTIs from HDU. More... | |
void | set_directions (void) |
Set sky directions and solid angles of events cube. More... | |
virtual void | set_energies (void) |
Set log mean energies and energy widths of event cube. More... | |
virtual void | set_times (void) |
Set mean event time and ontime of event cube. More... | |
void | set_bin (const int &index) |
Set event bin. More... | |
Protected Member Functions inherited from GEventCube | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEventCube &cube) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GEvents | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GEvents &events) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GLATEventBin | m_bin |
Actual energy bin. More... | |
GSkyMap | m_map |
Counts map stored as sky map. More... | |
GTime | m_time |
Event cube mean time. More... | |
double | m_ontime |
Event cube ontime (sec) More... | |
std::vector< GLATInstDir > | m_dirs |
Array of event directions. More... | |
std::vector< double > | m_solidangle |
Array of solid angles (sr) More... | |
std::vector< GEnergy > | m_energies |
Array of log mean energies. More... | |
std::vector< GEnergy > | m_ewidth |
Array of energy bin widths. More... | |
std::vector< GSkyMap * > | m_srcmap |
Pointers to source maps. More... | |
std::vector< std::string > | m_srcmap_names |
Source map names. More... | |
GNodeArray | m_enodes |
Energy nodes. More... | |
Protected Attributes inherited from GEvents | |
GEbounds | m_ebounds |
Energy boundaries covered by events. More... | |
GGti | m_gti |
Good time intervals covered by events. More... | |
Fermi/LAT event cube class.
Definition at line 53 of file GLATEventCube.hpp.
GLATEventCube::GLATEventCube | ( | void | ) |
Void constructor.
Definition at line 65 of file GLATEventCube.cpp.
References init_members().
Referenced by clone().
|
explicit |
File name constructor.
[in] | filename | Counts cube filename. |
Construct event cube object by loading the events from a FITS file.
Definition at line 82 of file GLATEventCube.cpp.
References init_members(), and load().
GLATEventCube::GLATEventCube | ( | const GLATEventCube & | cube | ) |
Copy constructor.
[in] | cube | LAT event cube. |
Definition at line 100 of file GLATEventCube.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GEventCube.
Definition at line 135 of file GLATEventCube.hpp.
|
virtual |
Clear instance.
This method properly resets the object to an initial state.
Implements GEventCube.
Definition at line 209 of file GLATEventCube.cpp.
References GEventCube::free_members(), free_members(), GEvents::free_members(), GEventCube::init_members(), init_members(), and GEvents::init_members().
Referenced by read().
|
virtual |
Clone instance.
Implements GEventCube.
Definition at line 231 of file GLATEventCube.cpp.
References GLATEventCube().
|
protected |
Copy class members.
[in] | cube | Fermi/LAT event cube. |
Definition at line 721 of file GLATEventCube.cpp.
References m_bin, m_dirs, m_energies, m_enodes, m_ewidth, m_map, m_ontime, m_solidangle, m_srcmap, m_srcmap_names, and m_time.
Referenced by GLATEventCube(), and operator=().
std::string GLATEventCube::diffname | ( | const int & | index | ) | const |
Return name of diffuse model.
[in] | index | Diffuse model index [0,...,ndiffrsp()-1]. |
GException::out_of_range | Model index out of valid range. |
Returns name of diffuse model.
Definition at line 577 of file GLATEventCube.cpp.
References G_DIFFNAME, m_srcmap_names, and ndiffrsp().
Referenced by GLATResponse::irf_spatial_bin().
GSkyMap * GLATEventCube::diffrsp | ( | const int & | index | ) | const |
Return diffuse response map.
[in] | index | Diffuse model index [0,...,ndiffrsp()-1]. |
GException::out_of_range | Model index out of valid range. |
Returns pointer to diffuse model sky map.
Definition at line 603 of file GLATEventCube.cpp.
References G_DIFFRSP, m_srcmap, and ndiffrsp().
Referenced by GLATResponse::irf_spatial_bin().
|
virtual |
Return dimension of event cube.
Implements GEventCube.
Definition at line 257 of file GLATEventCube.cpp.
References m_map, and GSkyMap::nmaps().
Referenced by naxis().
|
inline |
Return number of energy bins in event cube.
Definition at line 270 of file GLATEventCube.hpp.
References m_map, and GSkyMap::nmaps().
Referenced by print(), set_bin(), and set_energies().
|
inline |
Set event cube energy nodes.
[in] | enodes | Energy nodes. |
Definition at line 160 of file GLATEventCube.hpp.
References enodes(), and m_enodes.
Referenced by GLATResponse::irf_spatial_bin().
|
inline |
Return event cube energy nodes.
Definition at line 210 of file GLATEventCube.hpp.
References m_enodes.
Referenced by enodes().
|
protected |
Delete class members.
Definition at line 749 of file GLATEventCube.cpp.
References m_srcmap, and m_srcmap_names.
Referenced by clear(), operator=(), and ~GLATEventCube().
|
protected |
Initialise class members.
Definition at line 696 of file GLATEventCube.cpp.
References GLATEventBin::clear(), GNodeArray::clear(), GTime::clear(), GSkyMap::clear(), m_bin, m_dirs, m_energies, m_enodes, m_ewidth, m_map, m_ontime, m_solidangle, m_srcmap, m_srcmap_names, and m_time.
Referenced by clear(), GLATEventCube(), and operator=().
|
virtual |
Load LAT event cube from FITS file.
[in] | filename | FITS file name. |
Implements GEventCube.
Definition at line 312 of file GLATEventCube.cpp.
References GFits::close(), and read().
Referenced by GLATEventCube(), and GLATObservation::load_binned().
void GLATEventCube::map | ( | const GSkyMap & | map | ) |
Set event cube from sky map.
Definition at line 474 of file GLATEventCube.cpp.
References m_map, map(), and set_directions().
Referenced by GLATMeanPsf::set_map_corrections().
|
inline |
Return event cube sky map.
Definition at line 198 of file GLATEventCube.hpp.
References m_map.
Referenced by map(), and read_srcmap().
double GLATEventCube::maxrad | ( | const GSkyDir & | srcDir | ) | const |
Computes the maximum radius (in degrees) around a given source direction that fits spatially into the event cube.
[in] | srcDir | Source direction. |
By computing the sky directions of the event cube boundaries, the maximum radius is computed that fits fully within the event cube. This method is used for PSF normalization.
Definition at line 629 of file GLATEventCube.cpp.
References GSkyMap::contains(), GSkyDir::dist_deg(), m_map, nx(), ny(), and GSkyMap::pix2dir().
Referenced by GLATMeanPsf::set_map_corrections().
|
virtual |
Return number of bins in axis.
[in] | axis | Axis [0,...,dim()-1] |
GException::out_of_range | Axis is out of range. |
Returns the number of bins along a given event cube axis
.
Implements GEventCube.
Definition at line 278 of file GLATEventCube.cpp.
References dim(), G_NAXIS, m_map, GSkyMap::npix(), GSkyMap::nx(), and GSkyMap::ny().
|
inline |
Return number of diffuse model components.
Definition at line 282 of file GLATEventCube.hpp.
References m_srcmap.
Referenced by diffname(), diffrsp(), and GLATResponse::irf_spatial_bin().
|
inline |
Return number of pixels in event cube sky map.
Definition at line 258 of file GLATEventCube.hpp.
References m_map, and GSkyMap::npix().
Referenced by set_bin(), and set_directions().
|
virtual |
Return number of events in cube.
Implements GEventCube.
Definition at line 451 of file GLATEventCube.cpp.
References m_map, GSkyMap::pixels(), and size().
Referenced by print().
|
inline |
Return number of bins in X direction.
Definition at line 234 of file GLATEventCube.hpp.
References m_map, and GSkyMap::nx().
Referenced by maxrad(), print(), set_directions(), and GLATMeanPsf::set_map_corrections().
|
inline |
Return number of bins in Y direction.
Definition at line 246 of file GLATEventCube.hpp.
References m_map, and GSkyMap::ny().
Referenced by maxrad(), print(), set_directions(), and GLATMeanPsf::set_map_corrections().
|
inline |
Set event cube ontime.
[in] | ontime | Ontime. |
Definition at line 173 of file GLATEventCube.hpp.
|
inline |
Return event cube ontime.
Definition at line 222 of file GLATEventCube.hpp.
References m_ontime.
Referenced by ontime().
|
virtual |
Assignment operator.
[in] | cube | LAT event cube. |
Definition at line 138 of file GLATEventCube.cpp.
References copy_members(), free_members(), init_members(), and GEventCube::operator=().
|
virtual |
Event bin access operator.
[in] | index | Event index [0,...,size()-1]. |
Returns pointer to an event bin.
Implements GEventCube.
Definition at line 170 of file GLATEventCube.cpp.
|
virtual |
Event bin access operator (const version)
[in] | index | Event index [0,...,size()-1]. |
Returns pointer to an event bin.
Implements GEventCube.
Definition at line 188 of file GLATEventCube.cpp.
Print event cube information.
[in] | chatter | Chattiness. |
Implements GEventCube.
Definition at line 493 of file GLATEventCube.cpp.
References ebins(), GEvents::ebounds(), GEvents::emax(), GEvents::emin(), GEvents::gti(), m_map, m_srcmap, m_srcmap_names, number(), nx(), GSkyMap::nx(), ny(), GSkyMap::ny(), gammalib::parformat(), GSkyProjection::print(), GSkyMap::projection(), gammalib::reduce(), SILENT, size(), gammalib::str(), GEvents::tstart(), and GEvents::tstop().
|
virtual |
Read LAT event cube from FITS file.
[in] | fits | FITS file. |
It is assumed that the counts map resides in the primary extension of the FITS file, the energy boundaries reside in the EBOUNDS
extension and the Good Time Intervals reside in the GTI
extension. The method clears the object before loading, thus any events residing in the object before loading will be lost.
Implements GEventCube.
Definition at line 364 of file GLATEventCube.cpp.
References GFits::at(), GFitsHDU::card(), clear(), gammalib::extname_ebounds, gammalib::extname_gti, GFitsHDU::exttype(), GFitsHDU::has_card(), GFitsHDU::HT_IMAGE, GFits::image(), read_cntmap(), read_ebds(), read_gti(), read_srcmap(), GFits::size(), and GFits::table().
Referenced by load().
|
protected |
Read Fermi/LAT counts map from HDU.
[in] | hdu | Image HDU. |
This method reads a Fermi/LAT counts map from a FITS image. The counts map is stored in a GSkyMap object, and a pointer is set up to access the pixels individually. Recall that skymap pixels are stored in the order (ix,iy,ebin).
Definition at line 774 of file GLATEventCube.cpp.
References m_map, GSkyMap::read(), and set_directions().
Referenced by read().
|
protected |
Read energy boundaries from HDU.
[in] | hdu | Energy boundaries table. |
Read the energy boundaries from the HDU.
Definition at line 857 of file GLATEventCube.cpp.
References GEvents::m_ebounds, GEbounds::read(), and set_energies().
Referenced by read().
|
protected |
Read GTIs from HDU.
[in] | hdu | GTI table. |
Reads the Good Time Intervals from the GTI extension. Since the Fermi LAT Science Tools do not set corrently the time reference for source maps, the method automatically adds this missing information so that the time reference is set correctly. The time reference that is assumed for Fermi LAT is
MJDREFI 51910 MJDREFF 0.00074287037037037
Definition at line 885 of file GLATEventCube.cpp.
References GFitsHDU::card(), GFitsTable::clone(), GFitsHDU::has_card(), GFitsHDU::header(), GEvents::m_gti, GGti::read(), set_times(), GFitsHDU::string(), and gammalib::strip_whitespace().
Referenced by read().
|
protected |
Read LAT source map from HDU.
[in] | hdu | Image HDU. |
GException::invalid_argument | Source map in hdu is not compatible with event cube. |
This method reads a LAT source map from a FITS image. The source map is stored in a GSkyMap object and is given in units of counts/pixel/MeV.
Definition at line 798 of file GLATEventCube.cpp.
References GFitsHDU::extname(), G_READ_SRCMAP, m_map, m_srcmap, m_srcmap_names, map(), GSkyMap::nmaps(), GSkyMap::nx(), GSkyMap::ny(), GSkyMap::projection(), GSkyMap::read(), and gammalib::str().
Referenced by read().
|
virtual |
Save LAT event cube into FITS file.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite existing FITS file? (default: false) |
Save the LAT event cube into FITS file.
Implements GEventCube.
Definition at line 336 of file GLATEventCube.cpp.
References GFits::saveto(), and write().
|
protected |
Set event bin.
[in] | index | Event index [0,...,size()-1]. |
GException::out_of_range | Event index is outside valid range. |
GException::invalid_value | Energy vectors have not been set up. Sky directions and solid angles vectors have not been set up. |
This method provides the event attributes to the event bin. The event bin is in fact physically stored in the event cube, and only a single event bin is indeed allocated. This method sets up the pointers in the event bin so that a client can easily access the information of individual bins as if they were stored in an array.
Definition at line 1049 of file GLATEventCube.cpp.
References ebins(), G_SET_BIN, m_bin, GLATEventBin::m_counts, GLATEventBin::m_cube, GLATEventBin::m_dir, m_dirs, m_energies, GLATEventBin::m_energy, GLATEventBin::m_ewidth, m_ewidth, GLATEventBin::m_ieng, GLATEventBin::m_index, GLATEventBin::m_ipix, m_map, GLATEventBin::m_ontime, m_ontime, GLATEventBin::m_solidangle, m_solidangle, GLATEventBin::m_time, m_time, npix(), GSkyMap::pixels(), size(), and gammalib::str().
Referenced by operator[]().
|
protected |
Set sky directions and solid angles of events cube.
GException::invalid_value | No sky pixels found in event cube. |
This method computes the sky directions and solid angles for all event cube pixels. Sky directions are stored in an array of GLATInstDir objects while solid angles are stored in units of sr in a double precision array.
Definition at line 925 of file GLATEventCube.cpp.
References G_SET_DIRECTIONS, m_dirs, m_map, m_solidangle, npix(), nx(), ny(), GSkyMap::pix2dir(), and GSkyMap::solidangle().
Referenced by map(), and read_cntmap().
|
protectedvirtual |
Set log mean energies and energy widths of event cube.
GException::invalid_value | No energy boundaries found in event cube. |
This method computes the log mean energies and the energy widths of the event cube. The log mean energies and energy widths are stored unit independent in arrays of GEnergy objects.
Reimplemented from GEventCube.
Definition at line 966 of file GLATEventCube.cpp.
References GNodeArray::append(), GNodeArray::clear(), ebins(), GEvents::ebounds(), gammalib::elogmean(), GEvents::emax(), GEvents::emin(), G_SET_ENERGIES, log10(), m_energies, m_enodes, and m_ewidth.
Referenced by read_ebds().
|
protectedvirtual |
Set mean event time and ontime of event cube.
GException::invalid_value | No Good Time Intervals found. |
Computes the mean time of the event cube by taking the mean between start and stop time. Computes also the ontime by summing up of all good time intervals.
Reimplemented from GEventCube.
Definition at line 1011 of file GLATEventCube.cpp.
References G_SET_TIMES, GEvents::m_gti, m_ontime, m_time, GGti::ontime(), GGti::size(), GGti::tstart(), and GGti::tstop().
Referenced by read_gti().
|
virtual |
Return number of bins in event cube.
Implements GEventCube.
Definition at line 242 of file GLATEventCube.cpp.
References m_map, GSkyMap::nmaps(), and GSkyMap::npix().
|
inline |
Set event cube mean time.
[in] | time | Event cube mean time. |
Definition at line 147 of file GLATEventCube.hpp.
|
inline |
Return event cube mean time.
Definition at line 186 of file GLATEventCube.hpp.
References m_time.
Referenced by time().
|
virtual |
Write LAT event cube into FITS file.
[in] | fits | FITS file. |
Implements GEventCube.
Definition at line 425 of file GLATEventCube.cpp.
References GEvents::ebounds(), GEvents::gti(), m_map, m_srcmap, GGti::write(), GEbounds::write(), and GSkyMap::write().
Referenced by save().
|
protected |
Actual energy bin.
Definition at line 115 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), operator[](), and set_bin().
|
protected |
Array of event directions.
Definition at line 119 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), and set_directions().
|
protected |
Array of log mean energies.
Definition at line 121 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), and set_energies().
|
protected |
Energy nodes.
Definition at line 125 of file GLATEventCube.hpp.
Referenced by copy_members(), enodes(), init_members(), and set_energies().
|
protected |
Array of energy bin widths.
Definition at line 122 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), and set_energies().
|
protected |
Counts map stored as sky map.
Definition at line 116 of file GLATEventCube.hpp.
Referenced by copy_members(), dim(), ebins(), init_members(), map(), maxrad(), naxis(), npix(), number(), nx(), ny(), print(), read_cntmap(), read_srcmap(), set_bin(), set_directions(), size(), and write().
|
protected |
Event cube ontime (sec)
Definition at line 118 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), ontime(), set_bin(), and set_times().
|
protected |
Array of solid angles (sr)
Definition at line 120 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), and set_directions().
|
protected |
Pointers to source maps.
Definition at line 123 of file GLATEventCube.hpp.
Referenced by copy_members(), diffrsp(), free_members(), init_members(), ndiffrsp(), print(), read_srcmap(), and write().
|
protected |
Source map names.
Definition at line 124 of file GLATEventCube.hpp.
Referenced by copy_members(), diffname(), free_members(), init_members(), print(), and read_srcmap().
|
protected |
Event cube mean time.
Definition at line 117 of file GLATEventCube.hpp.
Referenced by copy_members(), init_members(), set_bin(), set_times(), and time().