Compare commits

..

12 Commits

Author SHA1 Message Date
d5d8157514 switch from PUB to PUSH 2026-03-04 14:09:05 +01:00
8c9326349d Update dap/algos/addmask.py 2026-02-26 09:12:46 +01:00
55b9af8bf4 Update dap/algos/addmask.py
killed longer line
2026-02-24 16:36:35 +01:00
8f23cc8110 added switch to enable/disable bsread sender 2026-02-06 12:10:59 +01:00
a58015b278 peak_list_* is not a numpy array 2026-02-05 18:36:36 +01:00
aef6933fab adjust to new import logic 2025-11-24 19:19:08 +01:00
a89a6aded6 handle equals case correctly (i.e., like indices) 2025-11-19 18:53:40 +01:00
4de0c8b7d7 allow vmin/vmax = None for "no limit" 2025-11-19 18:53:33 +01:00
ee79ee98a0 actually do send Nones 2025-11-04 11:32:15 +01:00
c58fbbb8fa added another comment 2025-11-04 11:01:22 +01:00
5273e0cf46 do not send Nones 2025-11-04 10:37:12 +01:00
e514061173 added type 2025-11-04 10:34:17 +01:00
5 changed files with 28 additions and 17 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

@@ -56,11 +56,14 @@ def calc_apply_additional_mask(results, pixel_mask):
pixel_mask[1794, 1503:1550] = 0
# killed by CC
pixel_mask[1499, 655:692] = 0
pixel_mask[1499, 630:692] = 0
# module 12 right column
pixel_mask[68:1096, 1062] = 0
# module 16, asics edge
pixel_mask[774:782, 1315:1385] = 0
# module 16 left column
pixel_mask[0:1028, 1101] = 0

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,12 +1,12 @@
import numpy as np
from bsread.sender import Sender, PUB
from bsread import Sender, PUSH
def make_bsread_sender(host="*", port=None):
if not port:
return None
address = f"tcp://{host}"
sender = Sender(address=address, port=port, block=False, mode=PUB)
sender = Sender(address=address, port=port, block=False, mode=PUSH)
sender.open()
return sender
@@ -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