Compare commits
4 Commits
701d90ae78
...
28f7248500
| Author | SHA1 | Date | |
|---|---|---|---|
| 28f7248500 | |||
| 603f9215e8 | |||
| 36c61c7b8e | |||
| 32adb370cd |
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
data = data.copy() # do the following in-place changes on a copy
|
||||
|
||||
threshold_min = float(results["threshold_min"])
|
||||
threshold_max = float(results["threshold_max"])
|
||||
|
||||
threshold(data, threshold_min, threshold_max, np.nan)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
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, value=None, 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
|
||||
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"])
|
||||
|
||||
threshold(data, threshold_min, threshold_max, threshold_value)
|
||||
if copy:
|
||||
data = data.copy() # do the following in-place changes on a copy
|
||||
|
||||
threshold(data, threshold_min, threshold_max, value)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user