From 8346a5226c2b70ab1235fe1e7359ab3646f45c8d Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 16 Jul 2019 10:24:30 +0200 Subject: [PATCH] Correct handling of flux for diffuse cube models in csspec (#2954) --- ChangeLog | 1 + NEWS | 3 ++- cscripts/csspec.py | 11 ++++++++++- doc/source/admin/release_history/1.6.2.rst | 2 ++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index df3c010..732c6f7 100755 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ ================================ Improve documentation and tutorials (#2962) + Correct handling of flux for diffuse cube models in csspec (#2954) Fix OpenMP issue in ctbin when using energy bounds from file (#2912) Fix multi-instrument handling in csbkgmodel (#2862) diff --git a/NEWS b/NEWS index a078b74..2d7c130 100755 --- a/NEWS +++ b/NEWS @@ -255,7 +255,8 @@ None csspec - Generates Spectral Energy Distribution ----------------------------------------------- -None +If a diffuse cube sky model is used the script now correctly multiplies the +result with the diffuse cube sky model spectrum (#2954). cssrcdetect - Detects sources in sky map diff --git a/cscripts/csspec.py b/cscripts/csspec.py index 466a19d..af952a6 100755 --- a/cscripts/csspec.py +++ b/cscripts/csspec.py @@ -2,7 +2,7 @@ # ========================================================================== # Generates a spectrum. # -# Copyright (C) 2014-2018 Michael Mayer +# Copyright (C) 2014-2019 Michael Mayer # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -729,6 +729,15 @@ class csspec(ctools.csobservation): else: e_flux = 0.0 + # If the source model is a cube then multiply-in the cube + # spectrum + if source.spatial().classname() == 'GModelSpatialDiffuseCube': + dir = gammalib.GSkyDir() + source.spatial().set_mc_cone(dir, 180.0) + norm = source.spatial().spectrum().eval(elogmean) + fitted_flux *= norm + e_flux *= norm + # Convert differential flux and flux error to nuFnu elogmean2 = elogmean.MeV() * elogmean.MeV() result['flux'] = fitted_flux * elogmean2 * gammalib.MeV2erg diff --git a/doc/source/admin/release_history/1.6.2.rst b/doc/source/admin/release_history/1.6.2.rst index 6df63c1..28d336b 100644 --- a/doc/source/admin/release_history/1.6.2.rst +++ b/doc/source/admin/release_history/1.6.2.rst @@ -12,6 +12,8 @@ The following bugs were fixed: * [`2962 `_] - Improve documentation and tutorials +* [`2954 `_] - + Correct handling of flux for diffuse cube models in csspec * [`2912 `_] - Fix OpenMP issue in ctbin when using energy bounds from file * [`2862 `_] - -- libgit2 0.21.4