fixed TODOs regarding numpy index start > stop
This commit is contained in:
@@ -24,18 +24,14 @@ def calc_radial_integration(results, data, pixel_mask):
|
||||
silent_min = results.get("radial_integration_silent_min", None)
|
||||
silent_max = results.get("radial_integration_silent_max", None)
|
||||
|
||||
if (
|
||||
silent_min is not None and
|
||||
silent_max is not None and
|
||||
#TODO: skipping entirely is a guess, but not obvious -- better to ensure the order min < max by switching them if needed
|
||||
silent_max > silent_min and
|
||||
silent_min > r_min and
|
||||
silent_max < r_max
|
||||
):
|
||||
silent_region = rp[silent_min:silent_max]
|
||||
integral_silent_region = np.sum(silent_region)
|
||||
rp = rp / integral_silent_region
|
||||
results["radint_normalised"] = [silent_min, silent_max]
|
||||
if silent_min is not None and silent_max is not None:
|
||||
# if start > stop, numpy returns an empty array -- better to ensure start < stop by switching them if needed
|
||||
silent_min, silent_max = sorted((silent_min, silent_max))
|
||||
if silent_min > r_min and silent_max < r_max:
|
||||
silent_region = rp[silent_min:silent_max]
|
||||
integral_silent_region = np.sum(silent_region)
|
||||
rp = rp / integral_silent_region
|
||||
results["radint_normalised"] = [silent_min, silent_max]
|
||||
|
||||
results["radint_I"] = rp[r_min:].tolist() #TODO: why not stop at r_max?
|
||||
results["radint_q"] = [r_min, r_max]
|
||||
|
||||
@@ -25,7 +25,10 @@ def calc_roi(results, data):
|
||||
roi_intensities_proj_x = []
|
||||
|
||||
for ix1, ix2, iy1, iy2 in zip(roi_x1, roi_x2, roi_y1, roi_y2):
|
||||
#TODO: if start > stop, numpy returns an empty array, which is not obvious -- better to ensure the order start < stop by switching them if needed
|
||||
# if start > stop, numpy returns an empty array -- better to ensure start < stop by switching them if needed
|
||||
ix1, ix2 = sorted((ix1, ix2))
|
||||
iy1, iy2 = sorted((iy1, iy2))
|
||||
|
||||
data_roi = data[iy1:iy2, ix1:ix2]
|
||||
|
||||
roi_sum = np.nansum(data_roi, dtype=float) # data_roi is np.float32, which cannot be json serialized
|
||||
|
||||
@@ -25,10 +25,10 @@ def threshold(data, vmin, vmax, replacement):
|
||||
"""
|
||||
threshold data in place by replacing values < vmin and values > vmax with replacement
|
||||
"""
|
||||
# if vmin > vmax, data will be overwritten entirely -- better to ensure vmin < vmax by switching them if needed
|
||||
vmin, vmax = sorted((vmin, vmax))
|
||||
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
|
||||
if vmax > vmin:
|
||||
data[data > vmax] = replacement
|
||||
data[data > vmax] = replacement
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user