Commit 6b4dfc0c237bad8fcd87918f4e107177b93644f9

Authored by Jürgen Knödlseder
1 parent 9c0c40dc

Handle new CTA energy dispersion format

ChangeLog
  1 +2019-05-15
  2 +
  3 + * Bug fix version 1.5.4 released
  4 + ================================
  5 +
  6 + Handle new CTA energy dispersion format
  7 +
  8 +
1 9 2019-05-11
2 10  
3 11 * Bug fix version 1.5.3 released
... ...
1   -New Features and Important Changes in GammaLib 1.5.3
  1 +New Features and Important Changes in GammaLib 1.5.4
2 2  
3   -5 May 2019
  3 +15 May 2019
4 4  
5 5  
6 6 1. Introduction
... ... @@ -123,7 +123,7 @@ None
123 123  
124 124 20. CTA interface
125 125 -----------------
126   -Use "BKG" instead of "BGD" for CTA background column (#2343).
  126 +Handle new CTA energy dispersion format.
127 127  
128 128  
129 129 21. COMPTEL interface
... ...
dev/conda.recipe/conda_build_config.yaml
... ... @@ -2,3 +2,4 @@ python:
2 2 - 2.7
3 3 - 3.5
4 4 - 3.6
  5 + - 3.7
... ...
doc/source/admin/download.rst
... ... @@ -4,13 +4,14 @@ Download
4 4 ========
5 5  
6 6 The latest GammaLib release is
7   -`gammalib-1.5.3 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.3.tar.gz>`_
8   -(11 May 2019).
  7 +`gammalib-1.5.4 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.4.tar.gz>`_
  8 +(15 May 2019).
9 9  
10 10 Below a list of older GammaLib releases. Please read the :ref:`sec_release` to
11 11 learn more about new features and corrected bugs in a given release.
12 12  
13 13 To download an older release, click on the corresponding release number:
  14 +`1.5.3 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.3.tar.gz>`_
14 15 `1.5.2 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.2.tar.gz>`_
15 16 `1.5.1 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.1.tar.gz>`_
16 17 `1.5.0 <http://cta.irap.omp.eu/ctools/releases/gammalib/gammalib-1.5.0.tar.gz>`_
... ...
doc/source/admin/release_history/1.5.4.rst 0 → 100644
  1 +.. _1.5.4:
  2 +
  3 +GammaLib 1.5.4 release (15 May 2019)
  4 +====================================
  5 +
  6 +Overview
  7 +--------
  8 +
  9 +GammaLib 1.5.4 is a bug fix release for GammaLib release 1.5.
  10 +
  11 +The following bugs were fixed:
  12 +
  13 +* Handle new CTA energy dispersion format
... ...
doc/source/admin/release_history/index.rst
... ... @@ -6,6 +6,7 @@ Release History
6 6 .. toctree::
7 7 :maxdepth: 1
8 8  
  9 + GammaLib 1.5.4 <1.5.4>
9 10 GammaLib 1.5.3 <1.5.3>
10 11 GammaLib 1.5.2 <1.5.2>
11 12 GammaLib 1.5.1 <1.5.1>
... ...
inst/cta/src/GCTAEdisp2D.cpp
1 1 /***************************************************************************
2 2 * GCTAEdisp2D.cpp - CTA 2D energy dispersion class *
3 3 * ----------------------------------------------------------------------- *
4   - * copyright (C) 2015-2018 by Florent Forest *
  4 + * copyright (C) 2015-2019 by Florent Forest *
5 5 * ----------------------------------------------------------------------- *
6 6 * *
7 7 * This program is free software: you can redistribute it and/or modify *
... ... @@ -42,6 +42,7 @@
42 42 #include "GFitsTable.hpp"
43 43 #include "GFitsBinTable.hpp"
44 44 #include "GCTAEdisp2D.hpp"
  45 +#include "GCTASupport.hpp"
45 46  
46 47 /* __ Method name definitions ____________________________________________ */
47 48 #define G_READ "GCTAEdisp2D::read(GFitsTable&)"
... ... @@ -305,8 +306,8 @@ void GCTAEdisp2D::table(const GCTAResponseTable&amp; table)
305 306 * Reads the energy dispersion form the FITS @p table. The following column
306 307 * names are mandatory:
307 308 *
308   - * ETRUE_LO - True energy lower bin boundaries
309   - * ETRUE_HI - True energy upper bin boundaries
  309 + * ENERG_LO - True energy lower bin boundaries (alternative name: ETRUE_LO)
  310 + * ENERG_HI - True energy upper bin boundaries (alternative name: ETRUE_HI)
310 311 * MIGRA_LO - Migration lower bin boundaries
311 312 * MIGRA_HI - Migration upper bin boundaries
312 313 * THETA_LO - Offset angle lower bin boundaries
... ... @@ -373,8 +374,9 @@ void GCTAEdisp2D::write(GFitsBinTable&amp; table) const
373 374 *
374 375 * Loads the energy dispersion from a FITS file.
375 376 *
376   - * If no extension name is provided, the energy dispersion will be loaded
377   - * from the `ENERGY DISPERSION` extension.
  377 + * The method does not actually load the FITS file, which will only be loaded
  378 + * on request. Only the filename is stored. See the fetch() method for the
  379 + * actually loading of the energy dispersion.
378 380 ***************************************************************************/
379 381 void GCTAEdisp2D::load(const GFilename& filename)
380 382 {
... ... @@ -694,9 +696,17 @@ GEbounds GCTAEdisp2D::ebounds_src(const double&amp; logEobs,
694 696 * @exception GException::invalid_value
695 697 * No file name has been specified.
696 698 *
697   - * Fetches the energy dispersion by reading it from a FITS file. This method
698   - * does nothing if the energy dispersion is already loaded, if there is
699   - * nothing to fetch, or if the m_filename member is empty.
  699 + * Fetches the energy dispersion by reading it from a FITS file.
  700 + *
  701 + * If the filename contains no extension name the method scans the `HDUCLASS`
  702 + * keywords of all extensions and loads the energy dispersion from the first
  703 + * extension for which `HDUCLAS4=EDISP_2D`.
  704 + *
  705 + * Otherwise, the background will be loaded from the `ENERGY DISPERSION`
  706 + * extension.
  707 + *
  708 + * This method does nothing if the energy dispersion is already loaded, if
  709 + * there is nothing to fetch, or if the m_filename member is empty.
700 710 *
701 711 * The method is thread save. The method checks whether the file from which
702 712 * the energy dispersion should be loaded actually exists.
... ... @@ -736,12 +746,16 @@ void GCTAEdisp2D::fetch(void) const
736 746 // Open FITS file
737 747 GFits fits(m_filename);
738 748  
739   - // Initialise energy dispersion extension name
740   - std::string extname =
741   - m_filename.extname(gammalib::extname_cta_edisp2d);
  749 + // Get the default extension name. If no GADF compliant name
  750 + // was found then set the default extension name to
  751 + // "ENERGY DISPERSION".
  752 + std::string extname = gammalib::gadf_hduclas4(fits, "EDISP_2D");
  753 + if (extname.empty()) {
  754 + extname = gammalib::extname_cta_edisp2d;
  755 + }
742 756  
743 757 // Get energy dispersion table
744   - const GFitsTable& table = *fits.table(extname);
  758 + const GFitsTable& table = *fits.table(m_filename.extname(extname));
745 759  
746 760 // Read energy dispersion from table
747 761 const_cast<GCTAEdisp2D*>(this)->read(table);
... ... @@ -1184,7 +1198,12 @@ void GCTAEdisp2D::compute_ebounds_src(const double&amp; theta,
1184 1198 void GCTAEdisp2D::set_table(void)
1185 1199 {
1186 1200 // Set table indices
1187   - m_inx_etrue = m_edisp.axis("ETRUE");
  1201 + if (m_edisp.has_axis("ENERG")) {
  1202 + m_inx_etrue = m_edisp.axis("ENERG");
  1203 + }
  1204 + else {
  1205 + m_inx_etrue = m_edisp.axis("ETRUE"); // Old name, should not be used
  1206 + }
1188 1207 m_inx_migra = m_edisp.axis("MIGRA");
1189 1208 m_inx_theta = m_edisp.axis("THETA");
1190 1209 m_inx_matrix = m_edisp.table("MATRIX");
... ...