Fix/detector tilt #188
+1
-1
@@ -10,7 +10,7 @@ dependencies = [
|
||||
"aarecommon>=0.5.1",
|
||||
"pydantic>=2.11",
|
||||
"numpy",
|
||||
"jfjoch_client==1.0.0rc146",
|
||||
"jfjoch_client>=1.0.0rc146",
|
||||
"pyJWT",
|
||||
"pyzmq",
|
||||
"opencv-python-headless",
|
||||
|
||||
@@ -38,6 +38,11 @@ class Geometry(ABC):
|
||||
@abstractmethod
|
||||
def beam_centre_model(self) -> BeamCenterFromDetectorStage: ...
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def detector_tilt(self) -> tuple[float, float]:
|
||||
"""A tuple of PONI rot1 and rot2 in radians"""
|
||||
|
||||
|
||||
class BeamlineDispatch(ABC):
|
||||
@property
|
||||
|
||||
@@ -2,7 +2,7 @@ from typing import Any
|
||||
|
||||
from aarecommon.config.beamline import MXBeamline
|
||||
|
||||
from aare.beamline_dispatch.default.beamline_dispatch import DefaultDispatch
|
||||
from aare.beamline_dispatch.default.beamline_dispatch import DefaultDispatch, DefaultGeometry
|
||||
from aare.beamline_dispatch.protocols import BecMacros
|
||||
|
||||
|
||||
@@ -52,9 +52,17 @@ class X06daBecMacros(BecMacros):
|
||||
def auto_exposure(): ...
|
||||
|
||||
|
||||
class X06daGeometry(DefaultGeometry):
|
||||
@property
|
||||
def detector_tilt(self) -> tuple[float, float]:
|
||||
poni_rot1_rad = -0.001396263
|
||||
poni_rot2_rad = -0.003839724
|
||||
return poni_rot1_rad, poni_rot2_rad
|
||||
|
||||
|
||||
class X06daDispatch(DefaultDispatch):
|
||||
def __init__(self, beamline: MXBeamline) -> None:
|
||||
super().__init__(beamline=beamline)
|
||||
super().__init__(beamline=beamline, geo_class=X06daGeometry)
|
||||
self._bec_macros = X06daBecMacros()
|
||||
|
||||
@property
|
||||
|
||||
@@ -97,6 +97,10 @@ class X10saGeometry(DefaultGeometry):
|
||||
def beam_centre_model(self) -> BeamCenterModel:
|
||||
return self._model
|
||||
|
||||
@property
|
||||
def detector_tilt(self) -> tuple[float, float]:
|
||||
return 0, 0
|
||||
|
||||
|
||||
class X10saDispatch(DefaultDispatch):
|
||||
def __init__(self, beamline: MXBeamline) -> None:
|
||||
|
||||
+3
-2
@@ -3154,6 +3154,7 @@ class AareDAQ:
|
||||
detector_serial_number = str(metadata.get("detector_serial_number", "unavailable"))
|
||||
energy = self._devs.energy_kev
|
||||
dtz = self._devs.dtz
|
||||
poni_rot1_rad, poni_rot2_rad = self._dispatch.geo.detector_tilt
|
||||
return DiffractionGeometry(
|
||||
energy_keV=energy,
|
||||
dtz_mm=dtz,
|
||||
@@ -3162,8 +3163,8 @@ class AareDAQ:
|
||||
beam_center_pxl=self._devs.detector_beam_centre_px,
|
||||
detector_description=detector_description,
|
||||
detector_serial_number=detector_serial_number,
|
||||
poni_rot1_rad=-0.001396263,
|
||||
poni_rot2_rad=-0.003839724,
|
||||
poni_rot1_rad=poni_rot1_rad,
|
||||
poni_rot2_rad=poni_rot2_rad,
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
@@ -322,8 +322,8 @@ class MainWindow(QMainWindow):
|
||||
beam_center_pxl=(750, 750),
|
||||
detector_description="PILATUS 4",
|
||||
detector_serial_number="1",
|
||||
poni_rot1_rad=-0.001396263,
|
||||
poni_rot2_rad=-0.003839724,
|
||||
poni_rot1_rad=-0,
|
||||
poni_rot2_rad=-0,
|
||||
)
|
||||
|
||||
geom = SampleGeometryModel(
|
||||
|
||||
@@ -49,6 +49,15 @@ def test_pxii_dispatch_beam_center():
|
||||
assert np.isclose(beam_center[1][0], 2242.05, atol=1)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
importlib.util.find_spec("pxii_bec") is None, reason="run only for pxii flavour"
|
||||
)
|
||||
def test_poni_rot_is_0():
|
||||
with patch.dict("os.environ", {"BEAMLINE": "X10SA"}):
|
||||
dispatch = get_beamline_dispatch()
|
||||
assert dispatch.geo.detector_tilt == (0, 0)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
importlib.util.find_spec("pxiii_bec") is None, reason="run only for pxiii flavour"
|
||||
)
|
||||
@@ -56,3 +65,12 @@ def test_pxiii_dispatch_can_be_instantiated():
|
||||
with patch.dict("os.environ", {"BEAMLINE": "X06DA"}):
|
||||
dispatch = get_beamline_dispatch()
|
||||
assert isinstance(dispatch, X06daDispatch)
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
importlib.util.find_spec("pxiii_bec") is None, reason="run only for pxiii flavour"
|
||||
)
|
||||
def test_poni_rot_is_not_0():
|
||||
with patch.dict("os.environ", {"BEAMLINE": "X06DA"}):
|
||||
dispatch = get_beamline_dispatch()
|
||||
assert dispatch.geo.detector_tilt != (0, 0)
|
||||
|
||||
Reference in New Issue
Block a user