From 3a8e5ed9140e5ea357203b6d2d1fc999f3da2e73 Mon Sep 17 00:00:00 2001 From: Marcus Oskarsson Date: Fri, 9 Feb 2024 15:58:48 +0100 Subject: [PATCH] [RESOLUTION] Added keyword argument wavelength to get_limits to be able to retrieve the limits for an arbitrary wavelength. --- mxcubecore/HardwareObjects/Resolution.py | 2 +- .../abstract/AbstractResolution.py | 28 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mxcubecore/HardwareObjects/Resolution.py b/mxcubecore/HardwareObjects/Resolution.py index f1f59936f7..a3e77b18f3 100644 --- a/mxcubecore/HardwareObjects/Resolution.py +++ b/mxcubecore/HardwareObjects/Resolution.py @@ -47,7 +47,7 @@ def set_value(self, value, timeout=None): timeout(float): optional - timeout [s], if timeout is None: wait forever (default). """ - # The precision depoends on the difference between the current + # The precision depends on the difference between the current # resolution and the target value - the smaller the difference, # the better the precision. # We move twice to get the closet possible to the requested resolution. diff --git a/mxcubecore/HardwareObjects/abstract/AbstractResolution.py b/mxcubecore/HardwareObjects/abstract/AbstractResolution.py index 9ae0b5b362..1fc8cc01b0 100644 --- a/mxcubecore/HardwareObjects/abstract/AbstractResolution.py +++ b/mxcubecore/HardwareObjects/abstract/AbstractResolution.py @@ -84,11 +84,37 @@ def get_value(self): def get_limits(self): """Return resolution low and high limits. + + Args: + wavelength: Returns the limits for given wavelength if + passed, current wavelength is otherwised used + + Returns: + (tuple): two floats tuple (low limit, high limit). + """ + _low, _high = self._hwr_detector.distance.get_limits() + + return ( + self.distance_to_resolution(_low), + self.distance_to_resolution(_high), + ) + + def get_limits_for_wavelength(self, wavelength: float): + """Return resolution low and high limits. + + Args: + wavelength: Returns the limits for given wavelength if + passed, current wavelength is otherwised used + Returns: (tuple): two floats tuple (low limit, high limit). """ _low, _high = self._hwr_detector.distance.get_limits() - return (self.distance_to_resolution(_low), self.distance_to_resolution(_high)) + + return ( + self.distance_to_resolution(_low, wavelength=wavelength), + self.distance_to_resolution(_high, wavelength=wavelength), + ) def set_limits(self, limits): """Resolution limits are not settable.