From d0096357fbb019cd3d8874d392b8c32a2ee6b8e1 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Tue, 3 Nov 2020 10:57:49 +0100 Subject: [PATCH] Fix implementation of fix_spat_for_ts parameter in ctlike (#3426) --- ChangeLog | 4 +++- NEWS | 7 +++++-- README.md | 2 +- doc/source/admin/release_history/2.0.rst | 15 +++------------ src/ctlike/ctlike.cpp | 26 ++++++++++++++++++++------ 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1fc0c43..f66d9d3 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -2020-10-19 +2020-11-03 * Version 2.0.0 released ======================== + Fix implementation of fix_spat_for_ts parameter in ctlike (#3426) + 2020-09-04 diff --git a/NEWS b/NEWS index 7f2f0a1..eb6c726 100755 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in ctools 2.0.0 -19 October 2020 +3 November 2020 Introduction @@ -76,7 +76,10 @@ None ctlike - Maximum likelihood fitting ----------------------------------- -None +A bug was fixed in the implementation of the fix_spat_for_ts parameter that +only fixed the spatial parameters for the first of the sky models but left +the spatial parameters free for all additional sky models. Now the parameters +are fixed for all sky models (#3426). ctmapcube - CTA map cube generation diff --git a/README.md b/README.md index 1201a77..d6a0bfd 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ctools information ================== -* Version: 2.0.0.dev (19 October 2020) +* Version: 2.0.0.dev (3 November 2020) * GammaLib dependency: 2.0.0.dev [![Build Status](https://cta-jenkins.irap.omp.eu/buildStatus/icon?job=ctools-integrate-os)](https://cta-jenkins.irap.omp.eu/job/ctools-integrate-os/) diff --git a/doc/source/admin/release_history/2.0.rst b/doc/source/admin/release_history/2.0.rst index d5d88a8..11116a6 100644 --- a/doc/source/admin/release_history/2.0.rst +++ b/doc/source/admin/release_history/2.0.rst @@ -1,6 +1,6 @@ .. _2.0: -ctools 2.0 release (19 October 2020) +ctools 2.0 release (3 November 2020) ==================================== Overview @@ -17,26 +17,17 @@ In particular, this release provides: Bug fixes --------- -* [`2883 `_] - - ... +* [`3426 `_] - + Fix implementation of ``fix_spat_for_ts`` parameter in :ref:`ctlike` Improvements ------------ -* [`2883 `_] - - ... - New features ------------ -* [`2883 `_] - - ... - Clean up -------- - -* [`2883 `_] - - ... diff --git a/src/ctlike/ctlike.cpp b/src/ctlike/ctlike.cpp index 59a257c..7813a5e 100755 --- a/src/ctlike/ctlike.cpp +++ b/src/ctlike/ctlike.cpp @@ -281,17 +281,31 @@ void ctlike::run(void) // Loop over stored models, remove source and refit for (int i = 0; i < ts_srcs.size(); ++i) { - models.remove(ts_srcs[i]); - m_obs.models(models); + + // Create copy of models + GModels models_copy = models; + + // Remove source of interest + models_copy.remove(ts_srcs[i]); + + // Set models for fitting + m_obs.models(models_copy); + + // Re-optimise log-likelihood for the source removed double logL_nosrc = reoptimize_lm(); - double ts = 2.0 * (logL_src-logL_nosrc); + + // Compute source TS value + double ts = 2.0 * (logL_src-logL_nosrc); + + // Store TS value in original model models_orig[ts_srcs[i]]->ts(ts); - models = models_orig; - } + + } // endfor: looped over sources // Restore best fit values m_obs.models(models_orig); - } + + } // endif: requested TS computation // Compute number of observed events in all observations double num_events = 0.0; -- libgit2 0.21.4