From 020801083274ce91c9bca0bd7dbab3567bb98227 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 21 Mar 2019 16:02:19 +0100 Subject: [PATCH] Add kludge to handle incomplete Fermi-LAT source maps (#2850) --- ChangeLog | 3 ++- NEWS | 8 ++++++-- doc/source/admin/release_history/1.6.rst | 2 ++ inst/lat/src/GLATEventCube.cpp | 31 ++++++++++++++++++++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9624691..9e7f018 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ -2019-03-06 +2019-03-21 * Version 1.6.0 released ======================== + Add kludge to handle incomplete Fermi-LAT source maps (#2850) Correct Nbgd computation in GCTAOnOffObservation for Non=0 (#2838) Improve OpenMP handling in GWcs::dir2pix (#2770) Add support for Fermi/LAT P8V3 response functions diff --git a/NEWS b/NEWS index 486065f..c305f9e 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in GammaLib 1.6.0 -6 March 2019 +21 March 2019 1. Introduction @@ -313,7 +313,11 @@ None 19. Fermi-LAT interface ----------------------- +----------------------- +Add kludge that allows handling of source maps that do not have WCS information +in the diffuse model maps. Such source maps are produced by the fermitools +version 1.0 (#2850). + The P8V3 Fermi/LAT response functions are now included in the package and unit tests for that response functions were added. diff --git a/doc/source/admin/release_history/1.6.rst b/doc/source/admin/release_history/1.6.rst index 4f86b05..a95d0bd 100644 --- a/doc/source/admin/release_history/1.6.rst +++ b/doc/source/admin/release_history/1.6.rst @@ -51,6 +51,8 @@ Bug fixes Improvements ------------ +* [`2850 `_] - + Add kludge to handle incomplete Fermi-LAT source maps * [`2770 `_] - Improve OpenMP handling in ``GWcs::dir2pix`` * Add support for Fermi/LAT P8V3 response functions diff --git a/inst/lat/src/GLATEventCube.cpp b/inst/lat/src/GLATEventCube.cpp index 8c59f68..cafcfa6 100644 --- a/inst/lat/src/GLATEventCube.cpp +++ b/inst/lat/src/GLATEventCube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GLATEventCube.cpp - Fermi/LAT event cube class * * ----------------------------------------------------------------------- * - * copyright (C) 2009-2018 by Juergen Knoedlseder * + * copyright (C) 2009-2019 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -48,6 +48,7 @@ /* __ Macros _____________________________________________________________ */ /* __ Coding definitions _________________________________________________ */ +#define G_MISSING_WCS_KLUDGE //!< Handle source maps with missing WCS /* __ Debug definitions __________________________________________________ */ @@ -380,11 +381,35 @@ void GLATEventCube::read(const GFits& fits) // Load additional source maps for (int i = 1; i < fits.size(); ++i) { + + // Only consider image extensions if (fits.at(i)->exttype() == GFitsHDU::HT_IMAGE) { + + // Get FITS image const GFitsImage& hdu_srcmap = *fits.image(i); + + // Handle files that do not have WCS in their additional + // source map extensions + #if defined(G_MISSING_WCS_KLUDGE) + std::string keys[] = {"CTYPE1", "CTYPE2", "CTYPE3", + "CRPIX1", "CRPIX2", "CRPIX3", + "CRVAL1", "CRVAL2", "CRVAL3", + "CDELT1", "CDELT2", "CDELT3", + "CUNIT1", "CUNIT2", "CUNIT3", + "CROTA2"}; + for (int i = 0; i < 16; ++i) { + if (!hdu_srcmap.has_card(keys[i])) { + const_cast(hdu_srcmap).card(hdu_cntmap.card(keys[i])); + } + } + #endif + + // Read source map read_srcmap(hdu_srcmap); - } - } + + } // endif: extension is an image + + } // endfor: looped over additional source maps // Return return; -- libgit2 0.21.4