Skip to content

Commit

Permalink
Add versatility to Rayonix XTC class (cctbx#723)
Browse files Browse the repository at this point in the history
Defaults for detz_offset and cent_mm were calibrated using mfxl032222 (April 2024)
  • Loading branch information
dermen authored Apr 8, 2024
1 parent 6818056 commit bb93372
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions newsfragments/723.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Additional features for `FormatXTCRayonix`
32 changes: 29 additions & 3 deletions src/dxtbx/format/FormatXTCRayonix.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
bin_size = None
.type = int
.help = Detector binning mode
cent_mm = [170.77,169]
.type = floats
.help = center coordinate in millimeters (fast-scan, slow-scan). These values will drift, update them using calibration samples (e.g., AgBe). Default value callibrated April 2024, for Rayonix XFEL MX-340 which is 340 mm across.
detz_encoder = detector_z
.type = str
.help = Name of the detector z encoder in the EPICS data (commonly detector_z or MFX:DET:MMS:04.RBV or CXI:DS1:MMS:06.RBV)
detz_offset = -140.2
.type = float
.help = offset to add to the detector_z encoder value in order to produce the correct distance (units are millimeters). This value will drift, update it with calibration samples (e.g., AgBe). Default value calibrated April 2024.
}
"""

Expand All @@ -43,8 +52,15 @@ def __init__(self, image_file, **kwargs):
bin_size = rayonix_cfg.binning_f()
if self.params.rayonix.bin_size is not None:
assert bin_size == self.params.rayonix.bin_size
self._pixel_size = rayonix.get_rayonix_pixel_size(bin_size)
self._pixel_size = rayonix.get_rayonix_pixel_size(bin_size) # in mm
self._image_size = rayonix.get_rayonix_detector_dimensions(self._ds.env())
self._detz_encoder = None
try:
self._detz_encoder = psana.Detector(self.params.rayonix.detz_encoder)
except KeyError:
pass
self._distance_mm = 100 # a default to fall back on
self._center_mm = self.params.rayonix.cent_mm

@staticmethod
def understand(image_file):
Expand All @@ -64,13 +80,23 @@ def get_raw_data(self, index=None):
return flex.double(data)

def get_detector(self, index=None):
if (
self.params.rayonix.detz_offset is not None
and self._detz_encoder is not None
):
self._distance_mm = (
self._detz_encoder(self.current_event) + self.params.rayonix.detz_offset
)
assert (
self._distance_mm > 0
), "something is wrong with encoder or detz_offset"
return self._detector()

def _detector(self):
return self._detector_factory.simple(
sensor="UNKNOWN",
distance=100.0,
beam_centre=(50.0, 50.0),
distance=self._distance_mm,
beam_centre=self.params.rayonix.cent_mm,
fast_direction="+x",
slow_direction="-y",
pixel_size=(self._pixel_size, self._pixel_size),
Expand Down

0 comments on commit bb93372

Please sign in to comment.