GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTACubeExposure.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTACubeExposure.cpp - CTA cube analysis exposure class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2014-2020 by Chia-Chun Lu *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GCTACubeExposure.cpp
23  * @brief CTA cube analysis exposure class implementation
24  * @author Chia-Chun Lu
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GTools.hpp"
32 #include "GMath.hpp"
33 #include "GLog.hpp"
34 #include "GObservations.hpp"
35 #include "GSkyRegionCircle.hpp"
36 #include "GCTATypemaps.hpp"
37 #include "GCTACubeExposure.hpp"
38 #include "GCTAObservation.hpp"
39 #include "GCTAResponse.hpp"
40 #include "GCTAResponseIrf.hpp"
41 #include "GCTAEventCube.hpp"
42 
43 /* __ Method name definitions ____________________________________________ */
44 #define G_FILL_CUBE "GCTACubeExposure::fill_cube(GCTAObservation&, GLog*)"
45 
46 /* __ Macros _____________________________________________________________ */
47 
48 /* __ Coding definitions _________________________________________________ */
49 
50 /* __ Debug definitions __________________________________________________ */
51 
52 /* __ Constants __________________________________________________________ */
53 
54 
55 /*==========================================================================
56  = =
57  = Constructors/destructors =
58  = =
59  ==========================================================================*/
60 
61 /***********************************************************************//**
62  * @brief Void constructor
63  ***************************************************************************/
65 {
66  // Initialise class members
67  init_members();
68 
69  // Return
70  return;
71 }
72 
73 
74 /***********************************************************************//**
75  * @brief Copy constructor
76  *
77  * @param[in] cube Exposure cube.
78  ***************************************************************************/
80 {
81  // Initialise class members
82  init_members();
83 
84  // Copy members
85  copy_members(cube);
86 
87  // Return
88  return;
89 }
90 
91 
92 /***********************************************************************//**
93  * @brief File constructor
94  *
95  * @param[in] filename Exposure cube filename.
96  *
97  * Construct exposure cube by loading the information from an exposure cube
98  * file.
99  ***************************************************************************/
101 {
102  // Initialise class members
103  init_members();
104 
105  // Load exposure cube from file
106  load(filename);
107 
108  // Return
109  return;
110 }
111 
112 
113 /***********************************************************************//**
114  * @brief Event cube constructor
115  *
116  * @param[in] cube Event cube.
117  *
118  * Construct exposure cube using the same binning and sky projection that is
119  * used for the event cube.
120  ***************************************************************************/
122 {
123  // Initialise class members
124  init_members();
125 
126  // Store energy boundaries
127  m_energies.set(cube.ebounds());
128 
129  // Set GNodeArray used for interpolation
130  set_eng_axis();
131 
132  // Set exposure cube to event cube
133  m_cube = cube.counts();
135 
136  // Set all exposure cube pixels to zero as we want to have a clean map
137  // upon construction
138  m_cube = 0.0;
139 
140  // Return
141  return;
142 
143 }
144 
145 
146 /***********************************************************************//**
147  * @brief Exposure cube constructor
148  *
149  * @param[in] wcs World Coordinate System.
150  * @param[in] coords Coordinate System (CEL or GAL).
151  * @param[in] x X coordinate of sky map centre (deg).
152  * @param[in] y Y coordinate of sky map centre (deg).
153  * @param[in] dx Pixel size in x direction at centre (deg/pixel).
154  * @param[in] dy Pixel size in y direction at centre (deg/pixel).
155  * @param[in] nx Number of pixels in x direction.
156  * @param[in] ny Number of pixels in y direction.
157  * @param[in] energies Energies.
158  *
159  * Constructs an exposure cube by specifying the sky map grid and the
160  * energies.
161  ***************************************************************************/
162 GCTACubeExposure::GCTACubeExposure(const std::string& wcs,
163  const std::string& coords,
164  const double& x,
165  const double& y,
166  const double& dx,
167  const double& dy,
168  const int& nx,
169  const int& ny,
170  const GEnergies& energies)
171 {
172  // Initialise class members
173  init_members();
174 
175  // Store energies
177 
178  // Set GNodeArray used for interpolation
179  set_eng_axis();
180 
181  // Create sky map
182  m_cube = GSkyMap(wcs, coords, x, y, dx, dy, nx, ny, m_energies.size());
183 
184  // Return
185  return;
186 }
187 
188 
189 /***********************************************************************//**
190  * @brief Destructor
191  ***************************************************************************/
193 {
194  // Free members
195  free_members();
196 
197  // Return
198  return;
199 }
200 
201 
202 /*==========================================================================
203  = =
204  = Operators =
205  = =
206  ==========================================================================*/
207 
208 /***********************************************************************//**
209  * @brief Assignment operator
210  *
211  * @param[in] cube Exposure cube.
212  * @return Exposure cube.
213  ***************************************************************************/
215 {
216  // Execute only if object is not identical
217  if (this != &cube) {
218 
219  // Free members
220  free_members();
221 
222  // Initialise private members
223  init_members();
224 
225  // Copy members
226  copy_members(cube);
227 
228  } // endif: object was not identical
229 
230  // Return this object
231  return *this;
232 }
233 
234 
235 /***********************************************************************//**
236  * @brief Return exposure (in units of cm**2 s)
237  *
238  * @param[in] dir Coordinate of the true photon position.
239  * @param[in] energy Energy of the true photon.
240  * @return Exposure (in units of cm**2 s)
241  ***************************************************************************/
242 double GCTACubeExposure::operator()(const GSkyDir& dir, const GEnergy& energy) const
243 {
244  // Set indices and weighting factors for interpolation
245  update(energy.log10TeV());
246 
247  // Perform interpolation
248  double exposure = m_wgt_left * m_cube(dir, m_inx_left) +
250 
251  // Make sure that exposure does not become negative
252  if (exposure < 0.0) {
253  exposure = 0.0;
254  }
255 
256  // Return exposure
257  return exposure;
258 }
259 
260 
261 /*==========================================================================
262  = =
263  = Public methods =
264  = =
265  ==========================================================================*/
266 
267 /***********************************************************************//**
268  * @brief Clear instance
269  *
270  * This method properly resets the object to an initial state.
271  ***************************************************************************/
273 {
274  // Free class members
275  free_members();
276 
277  // Initialise members
278  init_members();
279 
280  // Return
281  return;
282 }
283 
284 
285 /***********************************************************************//**
286  * @brief Clone exposure cube
287  *
288  * @return Deep copy of exposure cube instance.
289  ***************************************************************************/
291 {
292  return new GCTACubeExposure(*this);
293 }
294 
295 
296 /***********************************************************************//**
297  * @brief Set exposure cube for one CTA observation
298  *
299  * @param[in] obs CTA observation.
300  *
301  * Set the exposure cube for one CTA observation. The cube pixel values are
302  * computed as product of the effective area and the livetime.
303  ***************************************************************************/
305 {
306  // Clear GTIs, reset livetime and exposure cube pixels
307  m_gti.clear();
308  m_livetime = 0.0;
309  m_cube = 0.0;
310 
311  // Fill exposure cube
312  fill_cube(obs);
313 
314  // Return
315  return;
316 }
317 
318 
319 /***********************************************************************//**
320  * @brief Fill exposure cube from observation container
321  *
322  * @param[in] obs Observation container.
323  * @param[in] log Pointer to logger.
324  *
325  * Set the exposure cube by summing the exposure for all CTA observations in
326  * an observation container. The cube pixel values are computed as the sum
327  * over the products of the effective area and the livetime.
328  ***************************************************************************/
330 {
331  // Clear GTIs, reset livetime and exposure cube pixels
332  m_gti.clear();
333  m_livetime = 0.0;
334  m_cube = 0.0;
335 
336  // Loop over all observations in container
337  for (int i = 0; i < obs.size(); ++i) {
338 
339  // Get observation and continue only if it is a CTA observation
340  const GCTAObservation* cta = dynamic_cast<const GCTAObservation*>
341  (obs[i]);
342 
343  // Skip observation if it's not CTA
344  if (cta == NULL) {
345  if (log != NULL) {
346  *log << "Skipping ";
347  *log << obs[i]->instrument();
348  *log << " observation ";
349  *log << "\"" << obs[i]->name() << "\"";
350  *log << " (id=" << obs[i]->id() << ")" << std::endl;
351  }
352  continue;
353  }
354 
355  // Skip observation if we have a binned observation
356  if (cta->eventtype() == "CountsCube") {
357  if (log != NULL) {
358  *log << "Skipping binned ";
359  *log << cta->instrument();
360  *log << " observation ";
361  *log << "\"" << cta->name() << "\"";
362  *log << " (id=" << cta->id() << ")" << std::endl;
363  }
364  continue;
365  }
366 
367  // Fill exposure cube
368  fill_cube(*cta, log);
369 
370  } // endfor: looped over observations
371 
372  // Return
373  return;
374 }
375 
376 
377 /***********************************************************************//**
378  * @brief Read exposure cube from FITS object
379  *
380  * @param[in] fits FITS object.
381  *
382  * Read the exposure cube from a FITS object.
383  ***************************************************************************/
384 void GCTACubeExposure::read(const GFits& fits)
385 {
386  // Clear object
387  clear();
388 
389  // Get HDUs
390  const GFitsImage& hdu_expcube = *fits.image("Primary");
391  const GFitsTable& hdu_energies = *fits.table(gammalib::extname_energies);
392  const GFitsTable& hdu_gti = *fits.table(gammalib::extname_gti);
393 
394  // Read cube
395  m_cube.read(hdu_expcube);
396 
397  // Read cube attributes
398  read_attributes(hdu_expcube);
399 
400  // Read energies
401  m_energies.read(hdu_energies);
402 
403  // Read GTIs
404  m_gti.read(hdu_gti);
405 
406  // Set energy node array
407  set_eng_axis();
408 
409  // Return
410  return;
411 }
412 
413 
414 /***********************************************************************//**
415  * @brief Write CTA exposure cube into FITS file.
416  *
417  * @param[in] fits FITS file.
418  *
419  * Writes the exposure cube image, the energies and the Good Time Intervals
420  * into the FITS file.
421  ***************************************************************************/
423 {
424  // Write cube
425  m_cube.write(fits);
426 
427  // Get last HDU and write attributes
428  if (fits.size() > 0) {
429  GFitsHDU& hdu = *fits[fits.size()-1];
430  write_attributes(hdu);
431  }
432 
433  // Write energies
434  m_energies.write(fits);
435 
436  // Write GTIs
437  m_gti.write(fits);
438 
439  // Return
440  return;
441 }
442 
443 
444 /***********************************************************************//**
445  * @brief Load exposure cube from FITS file
446  *
447  * @param[in] filename Performance table file name.
448  *
449  * Loads the exposure cube from a FITS file into the object.
450  ***************************************************************************/
451 void GCTACubeExposure::load(const GFilename& filename)
452 {
453  // Put into OpenMP criticial zone
454  #pragma omp critical(GCTACubeExposure_load)
455  {
456 
457  // Open FITS file
458  GFits fits(filename);
459 
460  // Read PSF cube
461  read(fits);
462 
463  // Close FITS file
464  fits.close();
465 
466  } // end of OpenMP critical zone
467 
468  // Store filename
470 
471  // Return
472  return;
473 }
474 
475 
476 /***********************************************************************//**
477  * @brief Save exposure cube into FITS file
478  *
479  * @param[in] filename Exposure cube FITS file name.
480  * @param[in] clobber Overwrite existing file?
481  *
482  * Save the exposure cube into a FITS file.
483  ***************************************************************************/
484 void GCTACubeExposure::save(const GFilename& filename, const bool& clobber) const
485 {
486  // Put into OpenMP criticial zone
487  #pragma omp critical(GCTACubeExposure_save)
488  {
489 
490  // Create FITS file
491  GFits fits;
492 
493  // Write exposure cube
494  write(fits);
495 
496  // Save FITS file
497  fits.saveto(filename, clobber);
498 
499  // Close Edisp file
500  fits.close();
501 
502  } // end of OpenMP critical zone
503 
504  // Store filename
506 
507  // Return
508  return;
509 }
510 
511 
512 /***********************************************************************//**
513  * @brief Print exposure cube information
514  *
515  * @param[in] chatter Chattiness.
516  * @return String containing exposure cube information.
517  *
518  * @todo Add content
519  ***************************************************************************/
520 std::string GCTACubeExposure::print(const GChatter& chatter) const
521 {
522  // Initialise result string
523  std::string result;
524 
525  // Continue only if chatter is not silent
526  if (chatter != SILENT) {
527 
528  // Append header
529  result.append("=== GCTACubeExposure ===");
530 
531  // Append information
532  result.append("\n"+gammalib::parformat("Filename")+m_filename);
533  result.append("\n"+gammalib::parformat("Livetime"));
534  result.append(gammalib::str(m_livetime)+" sec");
535 
536  // Append energies
537  if (m_energies.size() > 0) {
538  result.append("\n"+m_energies.print(chatter));
539  }
540  else {
541  result.append("\n"+gammalib::parformat("Energies") +
542  "not defined");
543  }
544 
545  // Append GTIs
546  if (m_gti.size() > 0) {
547  result.append("\n"+m_gti.print(chatter));
548  }
549  else {
550  result.append("\n"+gammalib::parformat("Good Time Intervals") +
551  "not defined");
552  }
553 
554  // Append skymap definition
555  result.append("\n"+m_cube.print(chatter));
556 
557  } // endif: chatter was not silent
558 
559  // Return result
560  return result;
561 }
562 
563 
564 /*==========================================================================
565  = =
566  = Private methods =
567  = =
568  ==========================================================================*/
569 
570 /***********************************************************************//**
571  * @brief Initialise class members
572  ***************************************************************************/
574 {
575  // Initialise members
576  m_filename.clear();
577  m_cube.clear();
578  m_energies.clear();
579  m_elogmeans.clear();
580  m_gti.clear();
581  m_livetime = 0.0;
582 
583  // Initialise cache
584  m_inx_left = 0;
585  m_inx_right = 0;
586  m_wgt_left = 0.0;
587  m_wgt_right = 0.0;
588 
589  // Set CTA time reference for GTIs
590  m_gti.reference(GTimeReference(G_CTA_MJDREF, "s", "TT", "LOCAL"));
591 
592  // Return
593  return;
594 }
595 
596 
597 /***********************************************************************//**
598  * @brief Copy class members
599  *
600  * @param[in] cube Exposure cube
601  ***************************************************************************/
603 {
604  // Copy members
605  m_filename = cube.m_filename;
606  m_cube = cube.m_cube;
607  m_energies = cube.m_energies;
608  m_elogmeans = cube.m_elogmeans;
609  m_gti = cube.m_gti;
610  m_livetime = cube.m_livetime;
611 
612  // Copy cache
613  m_inx_left = cube.m_inx_left;
614  m_inx_right = cube.m_inx_right;
615  m_wgt_left = cube.m_wgt_left;
616  m_wgt_right = cube.m_wgt_right;
617 
618  // Return
619  return;
620 }
621 
622 /***********************************************************************//**
623  * @brief Delete class members
624  ***************************************************************************/
626 {
627  // Return
628  return;
629 }
630 
631 
632 /***********************************************************************//**
633  * @brief Fill exposure cube for one observation
634  *
635  * @param[in] obs Observation.
636  * @param[in] log Pointer to logger.
637  *
638  * @exception GException::invalid_value
639  * No RoI or response found in CTA observation.
640  *
641  * Fill the exposure cube from one CTA observations. The exposure cube pixel
642  * values are computed as the product of the effective area and the livetime.
643  ***************************************************************************/
645 {
646  // Only continue if we have an event list
647  if (obs.eventtype() == "EventList") {
648 
649  // Extract pointing direction, energy boundaries and ROI from
650  // observation
651  GSkyDir pnt = obs.pointing().dir();
652  GEbounds obs_ebounds = obs.ebounds();
653  GCTARoi roi = obs.roi();
654 
655  // Check for RoI sanity
656  if (!roi.is_valid()) {
657  std::string msg = "No RoI information found in "+obs.instrument()+
658  " observation \""+obs.name()+"\". Run ctselect "
659  "to specify an RoI for this observation.";
661  }
662 
663  // Convert RoI into a circular region for overlap checking
664  GSkyRegionCircle roi_reg(roi.centre().dir(), roi.radius());
665 
666  // Extract response from observation
667  const GCTAResponseIrf* rsp = dynamic_cast<const GCTAResponseIrf*>
668  (obs.response());
669  if (rsp == NULL) {
670  std::string msg = "No valid instrument response function found in "+
671  obs.instrument()+" observation \""+obs.name()+
672  "\". Please specify the instrument response "
673  "function for this observation.";
675  }
676 
677  // Skip observation if livetime is zero
678  if (obs.livetime() == 0.0) {
679  if (log != NULL) {
680  *log << "Skipping unbinned ";
681  *log << obs.instrument();
682  *log << " observation ";
683  *log << "\"" << obs.name() << "\"";
684  *log << " (id=" << obs.id() << ") due to zero livetime";
685  *log << std::endl;
686  }
687  }
688 
689  // Skip observation if observation is outside the bounds of the cube
690  else if (!m_cube.overlaps(roi_reg)) {
691  if (log != NULL) {
692  *log << "Skipping unbinned ";
693  *log << obs.instrument();
694  *log << " observation ";
695  *log << "\"" << obs.name() << "\"";
696  *log << " (id=" << obs.id() << ") since it does not overlap ";
697  *log << "with the exposure cube.";
698  *log << std::endl;
699  }
700  }
701 
702  // ... otherwise continue
703  else {
704 
705  // Announce observation usage
706  if (log != NULL) {
707  *log << "Including ";
708  *log << obs.instrument();
709  *log << " observation \"" << obs.name();
710  *log << "\" (id=" << obs.id() << ")";
711  *log << " in exposure cube computation." << std::endl;
712  }
713 
714  // Loop over all pixels in sky map
715  for (int pixel = 0; pixel < m_cube.npix(); ++pixel) {
716 
717  // Get pixel sky direction
718  GSkyDir dir = m_cube.inx2dir(pixel);
719 
720  // Skip pixel if it is outside the RoI
721  if (roi.centre().dir().dist_deg(dir) > roi.radius()) {
722  continue;
723  }
724 
725  // Compute theta angle with respect to pointing direction in
726  // radians
727  double theta = pnt.dist(dir);
728 
729  // Loop over all exposure cube energies
730  for (int iebin = 0; iebin < m_energies.size(); ++iebin){
731 
732  // Get logE/TeV
733  double logE = m_energies[iebin].log10TeV();
734 
735  // Add to exposure cube (effective area * livetime)
736  m_cube(pixel, iebin) += rsp->aeff(theta, 0.0, 0.0, 0.0, logE) *
737  obs.livetime();
738 
739  } // endfor: looped over energy bins
740 
741  } // endfor: looped over all pixels
742 
743  // If GTI is empty then set its time reference from the
744  // observation. From then on we keep that time reference
745  if (m_gti.is_empty()) {
746  m_gti.reference(obs.gti().reference());
747  }
748 
749  // Append GTIs and increment livetime
750  m_gti.extend(obs.gti());
751  m_livetime += obs.livetime();
752 
753  } // endelse: livetime was not zero
754 
755  } // endif: observation contained an event list
756 
757  // Return
758  return;
759 }
760 
761 
762 /***********************************************************************//**
763  * @brief Update 1D cache
764  *
765  * @param[in] logE Log10 energy in TeV.
766  *
767  * Updates the 1D interpolation cache. The interpolation cache is composed
768  * of two indices and weights that define 2 data values of the 2D skymap
769  * that are used for linear interpolation.
770  *
771  * @todo Write down formula
772  ***************************************************************************/
773 void GCTACubeExposure::update(const double& logE) const
774 {
775  // Set value for node array
776  m_elogmeans.set_value(logE);
777 
778  // Set indices and weighting factors for interpolation
783 
784  // Return
785  return;
786 }
787 
788 
789 /***********************************************************************//**
790  * @brief Set nodes for a logarithmic (base 10) energy axis
791  *
792  * Set axis nodes so that each node is the logarithm of the energy values.
793  ***************************************************************************/
795 {
796  // Get number of bins
797  int bins = m_energies.size();
798 
799  // Clear node array
800  m_elogmeans.clear();
801 
802  // Compute nodes
803  for (int i = 0; i < bins; ++i) {
804 
805  // Get logE/TeV
806  m_elogmeans.append(m_energies[i].log10TeV());
807 
808  } // endfor: looped over energy bins
809 
810  // Return
811  return;
812 }
813 
814 
815 /***********************************************************************//**
816  * @brief Read exposure attributes
817  *
818  * @param[in] hdu FITS HDU.
819  *
820  * Reads CTA exposure attributes from the HDU.
821  ***************************************************************************/
823 {
824  // Read mandatory attributes
825  m_livetime = (hdu.has_card("LIVETIME")) ? hdu.real("LIVETIME") : 0.0;
826 
827  // Return
828  return;
829 }
830 
831 
832 /***********************************************************************//**
833  * @brief Write attributes to exposure extension
834  *
835  * @param[in] hdu FITS HDU.
836  ***************************************************************************/
838 {
839  // Compute some attributes
840  double tstart = m_gti.tstart().convert(m_gti.reference());
841  double tstop = m_gti.tstop().convert(m_gti.reference());
842  double telapse = m_gti.telapse();
843  double ontime = m_gti.ontime();
844  double deadc = (ontime > 0.0 && m_livetime > 0.0) ?
845  m_livetime / ontime : 1.0;
846  std::string utc_obs = m_gti.tstart().utc();
847  std::string utc_end = m_gti.tstop().utc();
848  std::string date_obs = utc_obs.substr(0, 10);
849  std::string time_obs = utc_obs.substr(11, 8);
850  std::string date_end = utc_end.substr(0, 10);
851  std::string time_end = utc_end.substr(11, 8);
852 
853  // Set observation information
854  hdu.card("CREATOR", "GammaLib", "Program which created the file");
855  hdu.card("TELESCOP", "unknown", "Telescope");
856  hdu.card("OBS_ID", "unknown", "Observation identifier");
857  hdu.card("DATE-OBS", date_obs, "Observation start date");
858  hdu.card("TIME-OBS", time_obs, "Observation start time");
859  hdu.card("DATE-END", date_end, "Observation end date");
860  hdu.card("TIME-END", time_end, "Observation end time");
861 
862  // Set observation time information
863  hdu.card("TSTART", tstart, "[s] Mission time of start of observation");
864  hdu.card("TSTOP", tstop, "[s] Mission time of end of observation");
865  m_gti.reference().write(hdu);
866  hdu.card("TELAPSE", telapse, "[s] Mission elapsed time");
867  hdu.card("ONTIME", ontime, "[s] Total good time including deadtime");
868  hdu.card("LIVETIME", m_livetime, "[s] Total livetime");
869  hdu.card("DEADC", deadc, "Deadtime correction factor");
870  hdu.card("TIMEDEL", 1.0, "Time resolution");
871 
872  // Set exposure cube units
873  hdu.card("BUNIT", "cm**2 s", "Unit of exposure cube");
874 
875  // Return
876  return;
877 }
std::string print(const GChatter &chatter=NORMAL) const
Print energy container information.
Definition: GEnergies.cpp:698
void clear(void)
Clear energy container.
Definition: GEnergies.cpp:227
CTA exposure cube class.
Sky map class.
Definition: GSkyMap.hpp:89
Abstract FITS image base class.
Definition: GFitsImage.hpp:43
double operator()(const GSkyDir &dir, const GEnergy &energy) const
Return exposure (in units of cm**2 s)
void read(const GFitsTable &table)
Read energies from FITS table.
Definition: GEnergies.cpp:615
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Definition: GFits.cpp:482
double m_livetime
Livetime (sec)
bool has_card(const int &cardno) const
Check existence of header card.
Definition: GFitsHDU.hpp:233
void write(GFits &file, const std::string &extname=gammalib::extname_energies) const
Write energies into FITS object.
Definition: GEnergies.cpp:659
void fill(const GObservations &obs, GLog *log=NULL)
Fill exposure cube from observation container.
void write(GFits &file) const
Write CTA exposure cube into FITS file.
Definition of GammaLib CTA typemaps.
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
Definition: GEvents.cpp:136
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
bool overlaps(const GSkyRegion &region) const
Checks whether a region overlaps with this map.
Definition: GSkyMap.cpp:2102
#define G_FILL_CUBE
GEbounds ebounds(void) const
Get energy boundaries.
CTA instrument response function class definition.
void clear(void)
Clear instance.
void read(const GFits &fits)
Read exposure cube from FITS object.
const double & radius(void) const
Returns radius of region of interest in degrees.
Definition: GCTARoi.hpp:125
const double & wgt_left(void) const
Returns left node weight.
Definition: GNodeArray.hpp:264
virtual void response(const GResponse &rsp)
Set response function.
void clear(void)
Clear node array.
Definition: GNodeArray.cpp:235
void counts(const GSkyMap &counts)
Set event cube counts from sky map.
double log10TeV(void) const
Return log10 of energy in TeV.
Definition: GEnergy.cpp:457
void write_attributes(GFitsHDU &hdu) const
Write attributes to exposure extension.
Interface for the CTA region of interest class.
Definition: GCTARoi.hpp:49
Gammalib tools definition.
GCTACubeExposure & operator=(const GCTACubeExposure &exp)
Assignment operator.
FITS file class.
Definition: GFits.hpp:63
const std::string extname_gti
Definition: GGti.hpp:44
Interface for the circular sky region class.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
Definition: GNodeArray.cpp:587
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
void init_members(void)
Initialise class members.
std::string print(const GChatter &chatter=NORMAL) const
Print Good Time Intervals.
Definition: GGti.cpp:1106
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
Definition: GSkyMap.cpp:2664
void dir(const GSkyDir &dir)
Set sky direction.
GCTACubeExposure * clone(void) const
Clone exposure cube.
void update(const double &logE) const
Update 1D cache.
Energy container class.
Definition: GEnergies.hpp:60
std::string print(const GChatter &chatter=NORMAL) const
Print exposure cube information.
void fill_cube(const GCTAObservation &obs, GLog *log=NULL)
Fill exposure cube for one observation.
int size(void) const
Return number of Good Time Intervals.
Definition: GGti.hpp:154
void id(const std::string &id)
Set observation identifier.
void load(const GFilename &filename)
Load exposure cube from FITS file.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
Definition: GFits.cpp:1293
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
Definition: GSkyMap.cpp:2787
double real(const std::string &keyname) const
Return card value as double precision.
Definition: GFitsHDU.hpp:423
void reference(const GTimeReference &ref)
Set time reference for Good Time Intervals.
Definition: GGti.hpp:257
Information logger interface definition.
Definition: GLog.hpp:62
CTA event bin container class.
virtual double livetime(void) const
Return livetime.
GCTACubeExposure(void)
Void constructor.
void clear(void)
Clear Good Time Intervals.
Definition: GGti.cpp:237
const double & wgt_right(void) const
Returns right node weight.
Definition: GNodeArray.hpp:279
Energy boundaries container class.
Definition: GEbounds.hpp:60
const int & nmaps(void) const
Returns number of maps.
Definition: GSkyMap.hpp:389
GSkyDir inx2dir(const int &index) const
Returns sky direction of pixel.
Definition: GSkyMap.cpp:1331
GCTARoi roi(void) const
Get Region of Interest.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
Definition: GSkyMap.cpp:2697
Filename class.
Definition: GFilename.hpp:62
GGti gti(void) const
Get Good Time Intervals.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Definition: GCTARoi.hpp:111
const GEnergies & energies(void) const
Return energies.
int size(void) const
Return number of energies in container.
Definition: GEnergies.hpp:170
virtual std::string instrument(void) const
Return instrument name.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1274
const GFilename & filename(void) const
Return exposure cube filename.
GSkyMap m_cube
Average Exposure cube.
double m_wgt_right
Weight of right node.
GFilename m_filename
Filename.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
void read_attributes(const GFitsHDU &hdu)
Read exposure attributes.
GChatter
Definition: GTypemaps.hpp:33
double deadc(void) const
Return deadtime correction.
const int & inx_left(void) const
Returns left node index.
Definition: GNodeArray.hpp:235
void clear(void)
Clear instance.
Definition: GSkyMap.cpp:1100
int size(void) const
Return number of observations in container.
const GTime & tstop(void) const
Returns latest stop time in Good Time Intervals.
Definition: GGti.hpp:207
CTA response abstract base class definition.
const GTime & tstart(void) const
Returns earliest start time in Good Time Intervals.
Definition: GGti.hpp:194
CTA observation class interface definition.
Observation container class.
void copy_members(const GCTACubeExposure &exp)
Copy class members.
CTA instrument response function class.
const int & inx_right(void) const
Returns right node index.
Definition: GNodeArray.hpp:249
const std::string extname_energies
Definition: GEnergies.hpp:44
void set(const GEbounds &ebounds)
Set energies from energy boundaries.
Definition: GEnergies.cpp:421
void name(const std::string &name)
Set observation name.
void free_members(void)
Delete class members.
void save(const GFilename &filename, const bool &clobber=false) const
Save exposure cube into FITS file.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
Definition: GFits.cpp:368
Information logger class definition.
void clear(void)
Clear file name.
Definition: GFilename.cpp:188
void set(const GCTAObservation &obs)
Set exposure cube for one CTA observation.
void read(const GFitsTable &table)
Read Good Time Intervals and time reference from FITS table.
Definition: GGti.cpp:753
int size(void) const
Return number of HDUs in FITS file.
Definition: GFits.hpp:237
const double & ontime(void) const
Return ontime.
CTA event bin container class interface definition.
int m_inx_right
Index of right node.
std::string eventtype(void) const
Return event type string.
bool is_valid(void) const
Checks if RoI is valid.
Definition: GCTARoi.hpp:152
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Definition: GSkyDir.hpp:271
Implements a time reference.
int m_inx_left
Index of left node.
virtual ~GCTACubeExposure(void)
Destructor.
GNodeArray m_elogmeans
Mean energy for the Exposure cube.
CTA cube analysis exposure class definition.
#define G_CTA_MJDREF
Reference of CTA time frame.
CTA observation class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1143
void append(const double &node)
Append one node to array.
Definition: GNodeArray.cpp:351
const double & telapse(void) const
Returns elapsed time.
Definition: GGti.hpp:224
const int & npix(void) const
Returns number of pixels.
Definition: GSkyMap.hpp:345
bool is_empty(void) const
Signal if there are no Good Time Intervals.
Definition: GGti.hpp:166
GFitsHeaderCard & card(const int &cardno)
Return header card.
Definition: GFitsHDU.hpp:259
Observations container class interface definition.
Sky direction class.
Definition: GSkyDir.hpp:62
void write(GFits &fits, const std::string &extname=gammalib::extname_gti) const
Write Good Time Intervals and time reference into FITS object.
Definition: GGti.cpp:796
void close(void)
Close FITS file.
Definition: GFits.cpp:1342
std::string utc(const int &precision=0) const
Return time as string in UTC time system.
Definition: GTime.cpp:465
Circular sky region class interface definition.
void extend(const GGti &gti)
Append Good Time Intervals.
Definition: GGti.cpp:624
const double & ontime(void) const
Returns ontime.
Definition: GGti.hpp:240
GEnergies m_energies
Energy values for the Exposure cube.
double convert(const GTimeReference &ref) const
Return time in specified reference.
Definition: GTime.cpp:698
GGti m_gti
Good time interval for the Exposure cube.
Mathematical function definitions.
double m_wgt_left
Weight of left node.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:489