From 36c61c7b8ee852181ab04ad8103eff636d8b55a2 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 31 Oct 2025 18:32:07 +0100 Subject: [PATCH] added boolean copy switch --- dap/algos/thresh.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dap/algos/thresh.py b/dap/algos/thresh.py index bf84ed8..8c00fe0 100644 --- a/dap/algos/thresh.py +++ b/dap/algos/thresh.py @@ -2,14 +2,14 @@ import numpy as np #TODO: this is duplicated in calc_radial_integration and calc_apply_aggregation -def calc_apply_threshold(results, data): +def calc_apply_threshold(results, data, copy=False): apply_threshold = results.get("apply_threshold", False) if not apply_threshold: - return + return data for k in ("threshold_min", "threshold_max"): if k not in results: - return + return data threshold_value_choice = results.get("threshold_value", "NaN") threshold_value = 0 if threshold_value_choice == "0" else np.nan #TODO @@ -17,8 +17,13 @@ def calc_apply_threshold(results, data): threshold_min = float(results["threshold_min"]) threshold_max = float(results["threshold_max"]) + if copy: + data = data.copy() # do the following in-place changes on a copy + threshold(data, threshold_min, threshold_max, threshold_value) + return data + def threshold(data, vmin, vmax, replacement):