From bae400e9c37ccc8136b1c9fe88451d80b2e2f9d2 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Tue, 2 Jun 2026 10:31:22 +0200 Subject: [PATCH] diffraction_geometry.py: added a if __name__ == "__main__": block for testing --- src/aare/common/diffraction_geometry.py | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/aare/common/diffraction_geometry.py b/src/aare/common/diffraction_geometry.py index 92f29a97..a850227e 100644 --- a/src/aare/common/diffraction_geometry.py +++ b/src/aare/common/diffraction_geometry.py @@ -48,4 +48,35 @@ class DiffractionGeometry(BaseModel): if x >= 1.0 or x <= -1.0: return 0.0 theta = math.asin(x) - return self.detector_radius_mm / math.tan(2*theta) \ No newline at end of file + return self.detector_radius_mm / math.tan(2*theta) + +if __name__ == "__main__": + from aare.devices.jfjoch import JFJochWrapper + from aare.common.beamline import mx_beamline + from aare.daq.config import BeamlineConfig + bl = mx_beamline() + client = JFJochWrapper(bl) + cfg = BeamlineConfig(bl) + print(cfg) + det_cfg = client.detector() + print(det_cfg) + print(f"pixel_size: {det_cfg.pixel_size_mm:.4f} mm") + print(f"Detector height: {det_cfg.height:.2f} pixel") + print(f"Detector width: {det_cfg.width:.2f} pixel") + print(f"beam centre = ({cfg.beam_center[0]:.2f}, {cfg.beam_center[1]:.2f})") + geom = DiffractionGeometry( + energy_keV=12.4, + dtz_mm=200.0, + pixel_size_mm=det_cfg.pixel_size_mm, + beam_center_pxl=(det_cfg.width/2, det_cfg.height/2), + detector_size_pxl=(det_cfg.width, det_cfg.height), + detector_description=det_cfg.description, + detector_serial_number=det_cfg.serial_number, + poni_rot1_rad=-0.001396263, + poni_rot2_rad=-0.003839724, + ) + print(f"geom.max_resolution_angstrom: {geom.max_resolution_angstrom:.2f} Angstrom") + print(f"geom.calc_dtz_mm(3.9): {geom.calc_dtz_mm(3.9):.2f} mm") + + print(f"geom.resolution_angstrom(1244.42): {geom.resolution_angstrom(1244.42):.2f} Angstrom") + print(f"geom.detector_radius_mm: {geom.detector_radius_mm:.2f} mm")