From 603f9215e82ff82f121fa41b300e1f184fea3f83 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 31 Oct 2025 18:35:11 +0100 Subject: [PATCH] added replacement value as argument --- dap/algos/thresh.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dap/algos/thresh.py b/dap/algos/thresh.py index 8c00fe0..eeaa695 100644 --- a/dap/algos/thresh.py +++ b/dap/algos/thresh.py @@ -2,7 +2,7 @@ import numpy as np #TODO: this is duplicated in calc_radial_integration and calc_apply_aggregation -def calc_apply_threshold(results, data, copy=False): +def calc_apply_threshold(results, data, value=None, copy=False): apply_threshold = results.get("apply_threshold", False) if not apply_threshold: return data @@ -11,8 +11,9 @@ def calc_apply_threshold(results, data, copy=False): if k not in results: return data - threshold_value_choice = results.get("threshold_value", "NaN") - threshold_value = 0 if threshold_value_choice == "0" else np.nan #TODO + if value is None: + threshold_value = results.get("threshold_value", "NaN") + value = 0 if threshold_value == "0" else np.nan #TODO threshold_min = float(results["threshold_min"]) threshold_max = float(results["threshold_max"]) @@ -20,7 +21,7 @@ def calc_apply_threshold(results, data, copy=False): if copy: data = data.copy() # do the following in-place changes on a copy - threshold(data, threshold_min, threshold_max, threshold_value) + threshold(data, threshold_min, threshold_max, value) return data