diff --git a/dap/algos/aggregation.py b/dap/algos/aggregation.py index e6fcae9..abd5947 100644 --- a/dap/algos/aggregation.py +++ b/dap/algos/aggregation.py @@ -1,5 +1,5 @@ from .mask import calc_mask_pixels -from .thresh import threshold +from .thresh import calc_apply_threshold def calc_apply_aggregation(results, data, pixel_mask, aggregator): @@ -7,7 +7,7 @@ def calc_apply_aggregation(results, data, pixel_mask, aggregator): if aggregator.is_ready(): aggregator.reset() - calc_apply_threshold(results, data) # changes data in place + calc_apply_threshold(results, data, value=0) # changes data in place data = calc_aggregate(results, data, aggregator) calc_mask_pixels(data, pixel_mask) # changes data in place @@ -18,23 +18,6 @@ def calc_apply_aggregation(results, data, pixel_mask, aggregator): -#TODO: this is duplicated in calc_apply_threshold and calc_radial_integration -def calc_apply_threshold(results, data): - apply_threshold = results.get("apply_threshold", False) - if not apply_threshold: - return - - for k in ("threshold_min", "threshold_max"): - if k not in results: - return - - threshold_min = float(results["threshold_min"]) - threshold_max = float(results["threshold_max"]) - - threshold(data, threshold_min, threshold_max, 0) - - - def calc_aggregate(results, data, aggregator): apply_aggregation = results.get("apply_aggregation", False) if not apply_aggregation: diff --git a/dap/algos/radprof.py b/dap/algos/radprof.py index fd42d91..438e796 100644 --- a/dap/algos/radprof.py +++ b/dap/algos/radprof.py @@ -1,6 +1,6 @@ import numpy as np -from .thresh import threshold +from .thresh import calc_apply_threshold from .utils import npmemo @@ -17,7 +17,7 @@ def calc_radial_integration(results, data, pixel_mask): r_min = min(rad) r_max = max(rad) + 1 - data = calc_apply_threshold(results, data) + data = calc_apply_threshold(results, data, value=np.nan, copy=True) rp = radial_profile(data, rad, norm, pixel_mask) @@ -59,24 +59,3 @@ def radial_profile(data, rad, norm, keep_pixels): -#TODO: this is duplicated in calc_apply_threshold and calc_apply_aggregation -def calc_apply_threshold(results, data): - apply_threshold = results.get("apply_threshold", False) - if not apply_threshold: - return data - - for k in ("threshold_min", "threshold_max"): - if k not in results: - return data - - threshold_min = float(results["threshold_min"]) - threshold_max = float(results["threshold_max"]) - - data = data.copy() # do the following in-place changes on a copy - - threshold(data, threshold_min, threshold_max, np.nan) - - return data - - - diff --git a/dap/algos/thresh.py b/dap/algos/thresh.py index eeaa695..844b995 100644 --- a/dap/algos/thresh.py +++ b/dap/algos/thresh.py @@ -1,7 +1,6 @@ import numpy as np -#TODO: this is duplicated in calc_radial_integration and calc_apply_aggregation def calc_apply_threshold(results, data, value=None, copy=False): apply_threshold = results.get("apply_threshold", False) if not apply_threshold: