/***********************************************************************//** * @brief Set log mean energies and energy widths of event cube. * * @exception GLATException::no_ebds * 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. ***************************************************************************/ void GLATEventCube::set_energies(void) { // Throw an error if we have no energy bins if (ebins() < 1) { throw GLATException::no_ebds(G_SET_ENERGIES, "Every LAT event cube" " needs a definition of the energy boundaries."); } // Clear old bin energies and energy widths m_energies.clear(); m_ewidth.clear(); m_enodes.clear(); // Reserve space for bin energies and energy widths m_energies.reserve(ebins()); m_ewidth.reserve(ebins()); // Setup bin energies, energy widths and energy nodes for (int i = 0; i < ebins(); ++i) { m_energies.push_back(ebounds().elogmean(i)); m_ewidth.push_back(ebounds().emax(i) - ebounds().emin(i)); m_enodes.append(log10(ebounds().emin(i).MeV())); } m_enodes.append(log10(ebounds().emax(ebins()-1).MeV())); // Return return; }
/***********************************************************************//** * @brief Print event cube information ***************************************************************************/ std::string GCTAEventCube::print(void) const { // Initialise result string std::string result; // Append header result.append("=== GCTAEventCube ==="); result.append("\n"+parformat("Number of events")+str(number())); result.append("\n"+parformat("Number of elements")+str(size())); result.append("\n"+parformat("Number of pixels")+str(npix())); result.append("\n"+parformat("Number of energy bins")+str(ebins())); // Append skymap definition result.append("\n"+m_map.print()); // Append GTI intervals result.append("\n"+parformat("Time interval")); if (gti().size() > 0) { result.append(str(tstart().secs())+" - "+str(tstop().secs())+" sec"); } else { result.append("not defined"); } // Append energy intervals if (ebounds().size() > 0) { result.append("\n"+ebounds().print()); } else { result.append("\n"+parformat("Energy intervals")+"not defined"); } // Return result return result; }
/***********************************************************************//** * @brief Set log mean energies and energy widths of event cube. * * @exception GCTAException::no_ebds * 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. ***************************************************************************/ void GCTAEventCube::set_energies(void) { // Determine number of energy bins int ebins = ebounds().size(); // Throw an error if we have no energy bins if (ebins < 1) { throw GCTAException::no_ebds(G_SET_ENERGIES, "Every CTA event cube" " needs a definition of the energy boundaries."); } // Clear old bin energies and energy widths m_energies.clear(); m_ewidth.clear(); // Reserve space for bin energies and energy widths m_energies.reserve(ebins); m_ewidth.reserve(ebins); // Setup bin energies and energy widths for (int i = 0; i < ebins; ++i) { m_energies.push_back(ebounds().elogmean(i)); m_ewidth.push_back(ebounds().emax(i) - ebounds().emin(i)); } // Return return; }
/***********************************************************************//** * @brief Print event cube information * * @param[in] chatter Chattiness. * @return String containing event cube information. ***************************************************************************/ std::string GCTAEventCube::print(const GChatter& chatter) const { // Initialise result string std::string result; // Continue only if chatter is not silent if (chatter != SILENT) { // Append header result.append("=== GCTAEventCube ==="); result.append("\n"+gammalib::parformat("Number of events") + gammalib::str(number())); result.append("\n"+gammalib::parformat("Number of elements") + gammalib::str(size())); result.append("\n"+gammalib::parformat("Number of pixels") + gammalib::str(npix())); result.append("\n"+gammalib::parformat("Number of energy bins") + gammalib::str(ebins())); // Append GTI intervals result.append("\n"+gammalib::parformat("Time interval")); if (gti().size() > 0) { result.append(gammalib::str(tstart().secs()) + " - " + gammalib::str(tstop().secs())+" sec"); } else { result.append("not defined"); } // Append energy intervals if (gammalib::reduce(chatter) > SILENT) { if (ebounds().size() > 0) { result.append("\n"+ebounds().print(gammalib::reduce(chatter))); } else { result.append("\n"+gammalib::parformat("Energy intervals") + "not defined"); } } // Append skymap definition if (gammalib::reduce(chatter) > SILENT) { result.append("\n"+m_map.print(gammalib::reduce(chatter))); } } // endif: chatter was not silent // Return result return result; }
/***********************************************************************//** * @brief Write CTA event cube into FITS file. * * @param[in] fits FITS file. * * Writes CTA event cube into a FITS file. The following HDUs will be written * * COUNTS - Counts cube * WEIGHTS - Weights for each counts cube bin * EBOUNDS - Energy boundaries * GTI - Good Time Intervals * * The counts cube will be written as a double precision sky map. The * weighing cube contains the weight for each counts cube, computed as the * fraction of the event bin that has been selected in filling the counts * cube. This allows to account for proper stacking of observations with * different energy thresholds, or different regions of interest. The energy * boundaries for all counts cube layers are also written, as well as the * Good Time Intervals that have been used in generating the counts cube. ***************************************************************************/ void GCTAEventCube::write(GFits& fits) const { // Remove HDUs if they exist already if (fits.contains("GTI")) { fits.remove("GTI"); } if (fits.contains("EBOUNDS")) { fits.remove("EBOUNDS"); } if (fits.contains("WEIGHTS")) { fits.remove("WEIGHTS"); } if (fits.contains("COUNTS")) { fits.remove("COUNTS"); } if (fits.contains("Primary")) { fits.remove("Primary"); } // Write counts cube m_map.write(fits, "COUNTS"); // Write cube weighting m_weights.write(fits, "WEIGHTS"); // Write energy boundaries ebounds().write(fits); // Write Good Time intervals gti().write(fits); // Return return; }
/***********************************************************************//** * @brief Write CTA event cube into FITS file. * * @param[in] file FITS file. ***************************************************************************/ void GCTAEventCube::write(GFits& file) const { // Write cube m_map.write(&file); // Write energy boundaries ebounds().write(&file); // Write Good Time intervals gti().write(&file); // Return return; }
/***********************************************************************//** * @brief Write LAT event cube into FITS file * * @param[in] fits FITS file. ***************************************************************************/ void GLATEventCube::write(GFits& fits) const { // Write cube m_map.write(fits); // Write energy boundaries ebounds().write(fits); // Write Good Time intervals gti().write(fits); // Write additional source maps for (int i = 0; i < m_srcmap.size(); ++i) { m_srcmap[i]->write(fits); } // Return return; }
/***********************************************************************//** * @brief Print event cube information * * @param[in] chatter Chattiness (defaults to NORMAL). * @return String containing event cube information. ***************************************************************************/ std::string GLATEventCube::print(const GChatter& chatter) const { // Initialise result string std::string result; // Continue only if chatter is not silent if (chatter != SILENT) { // Append header result.append("=== GLATEventCube ==="); // Append information result.append("\n"+gammalib::parformat("Number of elements") + gammalib::str(size())); result.append("\n"+gammalib::parformat("Number of pixels")); result.append(gammalib::str(m_map.nx()) + " x " + gammalib::str(m_map.ny())); result.append("\n"+gammalib::parformat("Number of energy bins") + gammalib::str(ebins())); result.append("\n"+gammalib::parformat("Number of events") + gammalib::str(number())); // Append time interval result.append("\n"+gammalib::parformat("Time interval")); if (gti().size() > 0) { result.append(gammalib::str(tstart().secs()) + " - " + gammalib::str(tstop().secs())+" sec"); } else { result.append("not defined"); } // Append energy range result.append("\n"+gammalib::parformat("Energy range")); if (ebounds().size() > 0) { result.append(emin().print()+" - "+emax().print(chatter)); } else { result.append("not defined"); } // Append detailed information GChatter reduced_chatter = gammalib::reduce(chatter); if (reduced_chatter > SILENT) { // Append sky projection if (m_map.projection() != NULL) { result.append("\n"+m_map.projection()->print(reduced_chatter)); } // Append source maps result.append("\n"+gammalib::parformat("Number of source maps")); result.append(gammalib::str(m_srcmap.size())); for (int i = 0; i < m_srcmap.size(); ++i) { result.append("\n"+gammalib::parformat(" "+m_srcmap_names[i])); result.append(gammalib::str(m_srcmap[i]->nx())); result.append(" x "); result.append(gammalib::str(m_srcmap[i]->ny())); result.append(" x "); result.append(gammalib::str(m_srcmap[i]->nmaps())); } } } // endif: chatter was not silent // Return result return result; }