Compare commits
9 Commits
8e1073cfd1
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f23cc8110 | |||
| a58015b278 | |||
| aef6933fab | |||
| a89a6aded6 | |||
| 4de0c8b7d7 | |||
| ee79ee98a0 | |||
| c58fbbb8fa | |||
| 5273e0cf46 | |||
| e514061173 |
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user