diff --git a/ChangeLog b/ChangeLog index 9881d12..31d141d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2019-05-15 + + * Bug fix version 1.5.4 released + ================================ + + Handle new CTA energy dispersion format + + 2019-05-11 * Bug fix version 1.5.3 released diff --git a/NEWS b/NEWS index ab4ac0f..d584641 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ -New Features and Important Changes in GammaLib 1.5.3 +New Features and Important Changes in GammaLib 1.5.4 -5 May 2019 +15 May 2019 1. Introduction @@ -123,7 +123,7 @@ None 20. CTA interface ----------------- -Use "BKG" instead of "BGD" for CTA background column (#2343). +Handle new CTA energy dispersion format. 21. COMPTEL interface diff --git a/dev/conda.recipe/conda_build_config.yaml b/dev/conda.recipe/conda_build_config.yaml index 21ce93b..ac94ceb 100644 --- a/dev/conda.recipe/conda_build_config.yaml +++ b/dev/conda.recipe/conda_build_config.yaml @@ -2,3 +2,4 @@ python: - 2.7 - 3.5 - 3.6 + - 3.7 diff --git a/doc/source/admin/download.rst b/doc/source/admin/download.rst index 2e34234..2dd5e4b 100644 --- a/doc/source/admin/download.rst +++ b/doc/source/admin/download.rst @@ -4,13 +4,14 @@ Download ======== The latest GammaLib release is -`gammalib-1.5.3 `_ -(11 May 2019). +`gammalib-1.5.4 `_ +(15 May 2019). Below a list of older GammaLib releases. Please read the :ref:`sec_release` to learn more about new features and corrected bugs in a given release. To download an older release, click on the corresponding release number: +`1.5.3 `_ `1.5.2 `_ `1.5.1 `_ `1.5.0 `_ diff --git a/doc/source/admin/release_history/1.5.4.rst b/doc/source/admin/release_history/1.5.4.rst new file mode 100644 index 0000000..a42bb54 --- /dev/null +++ b/doc/source/admin/release_history/1.5.4.rst @@ -0,0 +1,13 @@ +.. _1.5.4: + +GammaLib 1.5.4 release (15 May 2019) +==================================== + +Overview +-------- + +GammaLib 1.5.4 is a bug fix release for GammaLib release 1.5. + +The following bugs were fixed: + +* Handle new CTA energy dispersion format diff --git a/doc/source/admin/release_history/index.rst b/doc/source/admin/release_history/index.rst index 82e64de..c08ca17 100644 --- a/doc/source/admin/release_history/index.rst +++ b/doc/source/admin/release_history/index.rst @@ -6,6 +6,7 @@ Release History .. toctree:: :maxdepth: 1 + GammaLib 1.5.4 <1.5.4> GammaLib 1.5.3 <1.5.3> GammaLib 1.5.2 <1.5.2> GammaLib 1.5.1 <1.5.1> diff --git a/inst/cta/src/GCTAEdisp2D.cpp b/inst/cta/src/GCTAEdisp2D.cpp index 6dd72bb..6221169 100644 --- a/inst/cta/src/GCTAEdisp2D.cpp +++ b/inst/cta/src/GCTAEdisp2D.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GCTAEdisp2D.cpp - CTA 2D energy dispersion class * * ----------------------------------------------------------------------- * - * copyright (C) 2015-2018 by Florent Forest * + * copyright (C) 2015-2019 by Florent Forest * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -42,6 +42,7 @@ #include "GFitsTable.hpp" #include "GFitsBinTable.hpp" #include "GCTAEdisp2D.hpp" +#include "GCTASupport.hpp" /* __ Method name definitions ____________________________________________ */ #define G_READ "GCTAEdisp2D::read(GFitsTable&)" @@ -305,8 +306,8 @@ void GCTAEdisp2D::table(const GCTAResponseTable& table) * Reads the energy dispersion form the FITS @p table. The following column * names are mandatory: * - * ETRUE_LO - True energy lower bin boundaries - * ETRUE_HI - True energy upper bin boundaries + * ENERG_LO - True energy lower bin boundaries (alternative name: ETRUE_LO) + * ENERG_HI - True energy upper bin boundaries (alternative name: ETRUE_HI) * MIGRA_LO - Migration lower bin boundaries * MIGRA_HI - Migration upper bin boundaries * THETA_LO - Offset angle lower bin boundaries @@ -373,8 +374,9 @@ void GCTAEdisp2D::write(GFitsBinTable& table) const * * Loads the energy dispersion from a FITS file. * - * If no extension name is provided, the energy dispersion will be loaded - * from the `ENERGY DISPERSION` extension. + * The method does not actually load the FITS file, which will only be loaded + * on request. Only the filename is stored. See the fetch() method for the + * actually loading of the energy dispersion. ***************************************************************************/ void GCTAEdisp2D::load(const GFilename& filename) { @@ -694,9 +696,17 @@ GEbounds GCTAEdisp2D::ebounds_src(const double& logEobs, * @exception GException::invalid_value * No file name has been specified. * - * Fetches the energy dispersion by reading it from a FITS file. This method - * does nothing if the energy dispersion is already loaded, if there is - * nothing to fetch, or if the m_filename member is empty. + * Fetches the energy dispersion by reading it from a FITS file. + * + * If the filename contains no extension name the method scans the `HDUCLASS` + * keywords of all extensions and loads the energy dispersion from the first + * extension for which `HDUCLAS4=EDISP_2D`. + * + * Otherwise, the background will be loaded from the `ENERGY DISPERSION` + * extension. + * + * This method does nothing if the energy dispersion is already loaded, if + * there is nothing to fetch, or if the m_filename member is empty. * * The method is thread save. The method checks whether the file from which * the energy dispersion should be loaded actually exists. @@ -736,12 +746,16 @@ void GCTAEdisp2D::fetch(void) const // Open FITS file GFits fits(m_filename); - // Initialise energy dispersion extension name - std::string extname = - m_filename.extname(gammalib::extname_cta_edisp2d); + // Get the default extension name. If no GADF compliant name + // was found then set the default extension name to + // "ENERGY DISPERSION". + std::string extname = gammalib::gadf_hduclas4(fits, "EDISP_2D"); + if (extname.empty()) { + extname = gammalib::extname_cta_edisp2d; + } // Get energy dispersion table - const GFitsTable& table = *fits.table(extname); + const GFitsTable& table = *fits.table(m_filename.extname(extname)); // Read energy dispersion from table const_cast(this)->read(table); @@ -1184,7 +1198,12 @@ void GCTAEdisp2D::compute_ebounds_src(const double& theta, void GCTAEdisp2D::set_table(void) { // Set table indices - m_inx_etrue = m_edisp.axis("ETRUE"); + if (m_edisp.has_axis("ENERG")) { + m_inx_etrue = m_edisp.axis("ENERG"); + } + else { + m_inx_etrue = m_edisp.axis("ETRUE"); // Old name, should not be used + } m_inx_migra = m_edisp.axis("MIGRA"); m_inx_theta = m_edisp.axis("THETA"); m_inx_matrix = m_edisp.table("MATRIX");