re-use thresh function
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from .mask import calc_mask_pixels
|
from .mask import calc_mask_pixels
|
||||||
|
from .thresh import threshold
|
||||||
|
|
||||||
|
|
||||||
def calc_force_send(results, data, pixel_mask_pf, image, data_summed, n_aggregated_images):
|
def calc_force_send(results, data, pixel_mask_pf, image, data_summed, n_aggregated_images):
|
||||||
@ -42,10 +43,9 @@ def calc_apply_threshold(results, data):
|
|||||||
|
|
||||||
threshold_min = float(results["threshold_min"])
|
threshold_min = float(results["threshold_min"])
|
||||||
threshold_max = float(results["threshold_max"])
|
threshold_max = float(results["threshold_max"])
|
||||||
data[data < threshold_min] = 0
|
|
||||||
#TODO: skipping max is a guess, but not obvious/symmetric -- better to ensure the order min < max by switching them if needed
|
threshold(data, threshold_min, threshold_max, 0)
|
||||||
if threshold_max > threshold_min:
|
|
||||||
data[data > threshold_max] = 0
|
|
||||||
|
|
||||||
|
|
||||||
def calc_apply_aggregation(results, data, data_summed, n_aggregated_images):
|
def calc_apply_aggregation(results, data, data_summed, n_aggregated_images):
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from .thresh import threshold
|
||||||
from .utils import npmemo
|
from .utils import npmemo
|
||||||
|
|
||||||
|
|
||||||
@ -76,10 +77,8 @@ def calc_apply_threshold(results, data):
|
|||||||
|
|
||||||
threshold_min = float(results["threshold_min"])
|
threshold_min = float(results["threshold_min"])
|
||||||
threshold_max = float(results["threshold_max"])
|
threshold_max = float(results["threshold_max"])
|
||||||
data[data < threshold_min] = np.nan
|
|
||||||
#TODO: skipping max is a guess, but not obvious/symmetric -- better to ensure the order min < max by switching them if needed
|
threshold(data, threshold_min, threshold_max, np.nan)
|
||||||
if threshold_max > threshold_min:
|
|
||||||
data[data > threshold_max] = np.nan
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
@ -16,10 +16,19 @@ def calc_apply_threshold(results, data):
|
|||||||
|
|
||||||
threshold_min = float(results["threshold_min"])
|
threshold_min = float(results["threshold_min"])
|
||||||
threshold_max = float(results["threshold_max"])
|
threshold_max = float(results["threshold_max"])
|
||||||
data[data < threshold_min] = threshold_value
|
|
||||||
|
threshold(data, threshold_min, threshold_max, threshold_value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def threshold(data, vmin, vmax, replacement):
|
||||||
|
"""
|
||||||
|
threshold data in place by replacing values < vmin and values > vmax with replacement
|
||||||
|
"""
|
||||||
|
data[data < vmin] = replacement
|
||||||
#TODO: skipping max is a guess, but not obvious/symmetric -- better to ensure the order min < max by switching them if needed
|
#TODO: skipping max is a guess, but not obvious/symmetric -- better to ensure the order min < max by switching them if needed
|
||||||
if threshold_max > threshold_min:
|
if vmax > vmin:
|
||||||
data[data > threshold_max] = threshold_value
|
data[data > vmin] = replacement
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user