Custom counters in Nexus
Issue
Custom data channels appear as individual NXdetector's in the Nexus file, no matter what their Redis name is.
Solution
Have all counters publish a "type" in the info of all their Redis nodes. This "type"
tells the writer how to parse the This won't work because the writer needs all the names on beforehand for name shortening.node.fullname
to create a valid Nexus structure.
I'm talking about these guys: SpectrumMcaCounter, StatisticsMcaCounter, RoiMcaCounter, MythenCounter, LimaBpmCounter, ImageCounter, RoiStatCounter, SamplingCounter, ...
Description
The Nexus structure of detector data is currently determined by the writer as follows:
- Publish in scan info (on the bliss side): all counter types
for ctr in global_map.get_counters_iter():
if isinstance(ctr, RoiMcaCounter):
device_info = {"type": "mca"}
elif isinstance(ctr, LimaBpmCounter):
device_info = {"type": "lima"}
elif isinstance(ctr, ImageCounter):
device_info = {"type": "lima"}
elif isinstance(ctr, RoiStatCounter):
device_info = {"type": "lima"}
...
- Name parsing in the writer side based on the Redis node name (what to parse) and the device type (how to parse). For example
# name convention for mca:
'xmap1:spectrum_det1'
'xmap1:icr_det1'
'xmap1:roi1'
...
# name convention for lima:
'frelon1:image'
'frelon1:roi_counters:roi1_min'
'frelon1:bpm:fwhm_x'
...
etc
Example:
Suppose you have a LIMA ROI counter (object of type RoiStatCounter
in global_map.get_counters_iter()
)
...:mpx_si_51:roi_counters:roi2_sum
and a counter created on-the-fly (does not appear in global_map.get_counters_iter()
)
...:mpx_si_51:roi_counters:roi2_sum_corr
#bliss.common.auto_filter.acquisition_objects.__init__.py
class _Base:
def __init__(self, auto_filter):
if new_channel.name in auto_filter.counters_for_correction:
corr_chan = AcquisitionChannel(
f"{new_channel.name}{auto_filter.corr_suffix}",
channel.dtype,
channel.shape,
channel.unit,
)
You would expect the Nexus structure to look like this
1.1
|_instrument
|_mpx_si_51(@NXdetector)
| |_data # the image
|
|_mpx_si_51_roi2(@NXdetector)
|_data # the ROI sum
|_corr # the custom counter
but we have this (for reasons explained above)
1.1
|_instrument
|_mpx_si_51(@NXdetector)
| |_data # the image
|
|_mpx_si_51_roi2(@NXdetector)
| |_data # the ROI sum
|
|_mpx_si_51_roi2_sum_corr(@NXdetector)
|_data # the custom counter