Compare commits

...

9 Commits

4 changed files with 23 additions and 15 deletions

View File

@@ -15,7 +15,8 @@ ENTRIES_TO_SKIP = [
"htype",
"pedestal_file",
"pulse_id",
"timestamp"
"timestamp",
"type"
]
@@ -70,6 +71,10 @@ def accumulate(accumulator_addr, bsread_host, bsread_port, bsread_window):
if not sender:
continue
enable_bsread = results.get("enable_bsread", False)
if not enable_bsread:
continue
timestamp = tuple(results["timestamp"])
data = pack_bsread_data(results, detector, skip=ENTRIES_TO_SKIP)
sorter.add(pulse_id, (timestamp, data))

View File

@@ -54,8 +54,8 @@ def calc_peakfinder_analysis(results, data, pixel_mask):
results["number_of_spots"] = number_of_spots
# to coordinates where position of first pixel/point is (1, 1)
results["spot_x"] = peak_list_x + 0.5
results["spot_y"] = peak_list_y + 0.5
results["spot_x"] = [x + 0.5 for x in peak_list_x]
results["spot_y"] = [y + 0.5 for y in peak_list_y]
results["spot_intensity"] = copy(peak_list_value) #TODO: why is this copy needed?
npeaks_threshold_hit = results.get("npeaks_threshold_hit", 15)

View File

@@ -6,17 +6,16 @@ def calc_apply_threshold(results, data, value=None, copy=False):
if not apply_threshold:
return data
for k in ("threshold_min", "threshold_max"):
if k not in results:
return data
threshold_min = results.get("threshold_min")
threshold_max = results.get("threshold_max")
if threshold_min is None and threshold_max is None:
return data
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"])
if copy:
data = data.copy() # do the following in-place changes on a copy
@@ -28,12 +27,15 @@ def calc_apply_threshold(results, data, value=None, copy=False):
def threshold(data, vmin, vmax, replacement):
"""
threshold data in place by replacing values < vmin and values > vmax with 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
data[data > vmax] = replacement
if vmin is not None and vmax is not None:
# if vmin > vmax, data will be overwritten entirely -- better to ensure vmin < vmax by switching them if needed
vmin, vmax = sorted((vmin, vmax))
if vmin is not None:
data[data < vmin] = replacement
if vmax is not None:
data[data >= vmax] = replacement

View File

@@ -1,5 +1,5 @@
import numpy as np
from bsread.sender import Sender, PUB
from bsread import Sender, PUB
def make_bsread_sender(host="*", port=None):
@@ -18,6 +18,7 @@ def pack_bsread_data(orig, prefix, skip=None):
if k in skip:
continue
if isinstance(v, bool):
# bsread expects bools as ints
v = int(v)
elif isinstance(v, list):
# bsread fails for empty lists and non-1D lists