Skip to content
Snippets Groups Projects
Commit bba593d9 authored by Egor Sobolev's avatar Egor Sobolev
Browse files

Add ShimadzuHVX2 conditions and detector abstraction

parent ffcdffb9
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !939. Comments created here will be created in the context of that merge request.
from dataclasses import dataclass
from cal_tools.calcat_interface2 import ConditionsBase
@dataclass
class ShimadzuHPVX2Conditions(ConditionsBase):
frame_size: float
calibration_types = {
"Offset": ["Frame Size"],
"DynamicFF": ["Frame Size"],
}
class ShimadzuHPVX2:
channel = "daqOutput"
image_key = "data.image.pixels"
def __init__(self, source_name_pattern: str, channel=None, image_key=None):
self.source_name_pattern = source_name_pattern
if channel is not None:
self.channel = channel
if image_key is not None:
self.image_key = image_key
self.image_index_group = self.image_key.partition('.')[0]
self.instrument = source_name_pattern.split('_')[0]
def conditions(self, dc: "DataCollection", module=None): # noqa: F821
if module is None:
source_pattern = self.source_name_pattern.format(
f"*:{self.channel}")
det_dc = dc.select(source_pattern)
if not det_dc.instrument_sources:
raise ValueError("No detector sources are found")
source_name = list(det_dc.instrument_sources)[0]
else:
source_name = self.instrument_source(module)
keydata = dc[source_name, self.image_key]
num_frames = keydata.shape[-3]
return ShimadzuHPVX2Conditions(frame_size=num_frames / 256)
def instrument_source(self, module: int):
source_name = self.source_name_pattern.format(module)
return f"{source_name}:{self.channel}"
def corrected_source(self, module: int):
source_name = self.source_name_pattern.format(module)
parts = source_name.split('/')
parts[1] = "CORR"
source_name = '/'.join(parts)
return f"{source_name}:output"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment