From 52d1aaa63f0df8a74f1ba9501c4a8a5e9e24e591 Mon Sep 17 00:00:00 2001 From: Joris Snellenburg Date: Mon, 30 Aug 2021 01:18:13 +0200 Subject: [PATCH] Scale area penalty with number of datasets This fix reproduces the area penalty behavior that was in v0.4.1 with multiple datasets with the same spectral axis. For multiple datasets with different axes a more elaborate solution is required, see #800 for discussion. --- glotaran/analysis/util.py | 9 +++++++-- glotaran/model/clp_penalties.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/glotaran/analysis/util.py b/glotaran/analysis/util.py index d54cb06b0..cc6f5510b 100644 --- a/glotaran/analysis/util.py +++ b/glotaran/analysis/util.py @@ -196,6 +196,9 @@ def calculate_clp_penalties( global_axis: np.ndarray, ) -> np.ndarray: + # TODO: make a decision on how to handle clp_penalties per dataset + # temporary workaround to better match v0.4.1 output + debug_scale = len(model.dataset) penalties = [] for penalty in model.clp_area_penalties: penalty = penalty.fill(model, parameters) @@ -214,8 +217,10 @@ def calculate_clp_penalties( penalty.target_intervals, global_axis, ) - - area_penalty = np.abs(np.sum(source_area) - penalty.parameter * np.sum(target_area)) + area_penalty = np.abs( + debug_scale * np.sum(source_area) + - penalty.parameter * debug_scale * np.sum(target_area) + ) penalties.append(area_penalty * penalty.weight) diff --git a/glotaran/model/clp_penalties.py b/glotaran/model/clp_penalties.py index 2918d9b41..3aa08ea32 100644 --- a/glotaran/model/clp_penalties.py +++ b/glotaran/model/clp_penalties.py @@ -73,6 +73,7 @@ def apply_spectral_penalties( group_tolerance: float, ) -> np.ndarray: + # TODO: seems to duplicate calculate_clp_penalties penalties = [] for penalty in model.clp_area_penalties: