From ea8d66ad94a5e033a027797489fc0e76c829ddba Mon Sep 17 00:00:00 2001 From: morcuended Date: Mon, 18 Sep 2023 15:39:16 +0000 Subject: [PATCH 1/4] properly normalize edisp in v0.9 --- lstchain/tools/lstchain_create_irf_files.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lstchain/tools/lstchain_create_irf_files.py b/lstchain/tools/lstchain_create_irf_files.py index 686f8d8a58..3128613c8e 100644 --- a/lstchain/tools/lstchain_create_irf_files.py +++ b/lstchain/tools/lstchain_create_irf_files.py @@ -567,6 +567,15 @@ def start(self): fov_offset_bins, migration_bins, ) + # Different normalization of EDISP had been assumed so far (to the sum of 1). + # According to GADF definition, it should be normalized to the integral of 1. + # See https://github.com/cta-observatory/pyirf/pull/250 + self.log.warning( + "Fixing EDISP normalization for v0.9 data products. The proper " + "normalization is assumed in lstchain v0.10.5 which uses pyirf >= v0.10.0" + ) + bin_width = np.diff(migration_bins) + self.edisp /= bin_width[np.newaxis, :, np.newaxis] self.hdus.append( create_energy_dispersion_hdu( self.edisp, From 0cab5c73789e951fde05911eb8364105e6fa0957 Mon Sep 17 00:00:00 2001 From: morcuended Date: Tue, 19 Sep 2023 08:47:26 +0000 Subject: [PATCH 2/4] remove log warning on fixing edisp normalization --- lstchain/tools/lstchain_create_irf_files.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lstchain/tools/lstchain_create_irf_files.py b/lstchain/tools/lstchain_create_irf_files.py index 3128613c8e..7a3ceb9b9b 100644 --- a/lstchain/tools/lstchain_create_irf_files.py +++ b/lstchain/tools/lstchain_create_irf_files.py @@ -569,11 +569,8 @@ def start(self): ) # Different normalization of EDISP had been assumed so far (to the sum of 1). # According to GADF definition, it should be normalized to the integral of 1. + # This normalization definition is assumed in pyirf >= v0.10.0. # See https://github.com/cta-observatory/pyirf/pull/250 - self.log.warning( - "Fixing EDISP normalization for v0.9 data products. The proper " - "normalization is assumed in lstchain v0.10.5 which uses pyirf >= v0.10.0" - ) bin_width = np.diff(migration_bins) self.edisp /= bin_width[np.newaxis, :, np.newaxis] self.hdus.append( From 813e51c8200c9a7eee9bf8ffc0e3b55dd0666176 Mon Sep 17 00:00:00 2001 From: morcuended Date: Tue, 19 Sep 2023 11:01:39 +0000 Subject: [PATCH 3/4] add FIXEDNRM key to edisp HDU header --- lstchain/tools/lstchain_create_irf_files.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lstchain/tools/lstchain_create_irf_files.py b/lstchain/tools/lstchain_create_irf_files.py index 7a3ceb9b9b..b7a451bbec 100644 --- a/lstchain/tools/lstchain_create_irf_files.py +++ b/lstchain/tools/lstchain_create_irf_files.py @@ -571,6 +571,11 @@ def start(self): # According to GADF definition, it should be normalized to the integral of 1. # This normalization definition is assumed in pyirf >= v0.10.0. # See https://github.com/cta-observatory/pyirf/pull/250 + edisp_header = fits.Header() + edisp_header["FIXEDNRM"] = True + for k, v in extra_headers.items(): + edisp_header[k] = v + bin_width = np.diff(migration_bins) self.edisp /= bin_width[np.newaxis, :, np.newaxis] self.hdus.append( @@ -581,7 +586,7 @@ def start(self): fov_offset_bins, point_like=self.point_like, extname="ENERGY DISPERSION", - **extra_headers, + **edisp_header, ) ) self.log.info("Energy Dispersion HDU created") From 9fc20e41272cb8ce0aa9b9a4525c0aad11886e9b Mon Sep 17 00:00:00 2001 From: Daniel Morcuende Date: Tue, 19 Sep 2023 15:36:03 +0200 Subject: [PATCH 4/4] simply addition of FIXEDNRM key in header Co-authored-by: Maximilian Linhoff --- lstchain/tools/lstchain_create_irf_files.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lstchain/tools/lstchain_create_irf_files.py b/lstchain/tools/lstchain_create_irf_files.py index b7a451bbec..4f86663e1c 100644 --- a/lstchain/tools/lstchain_create_irf_files.py +++ b/lstchain/tools/lstchain_create_irf_files.py @@ -571,11 +571,6 @@ def start(self): # According to GADF definition, it should be normalized to the integral of 1. # This normalization definition is assumed in pyirf >= v0.10.0. # See https://github.com/cta-observatory/pyirf/pull/250 - edisp_header = fits.Header() - edisp_header["FIXEDNRM"] = True - for k, v in extra_headers.items(): - edisp_header[k] = v - bin_width = np.diff(migration_bins) self.edisp /= bin_width[np.newaxis, :, np.newaxis] self.hdus.append( @@ -586,7 +581,8 @@ def start(self): fov_offset_bins, point_like=self.point_like, extname="ENERGY DISPERSION", - **edisp_header, + **extra_headers, + FIXEDNRM=True, ) ) self.log.info("Energy Dispersion HDU created")