diff --git a/src/diffraction_utils/data_file.py b/src/diffraction_utils/data_file.py index 4ad290f..12686d3 100644 --- a/src/diffraction_utils/data_file.py +++ b/src/diffraction_utils/data_file.py @@ -63,6 +63,7 @@ def __init__( # Run the various parsers to initialize non-trivial attributes. self.probe_energy = self._parse_probe_energy() + self.probe_wavelength = self._calc_probe_wavelength() self.default_axis_name = self._parse_default_axis_name() self.default_signal_name = self._parse_default_signal_name() self.default_axis = self._parse_default_axis() @@ -149,6 +150,12 @@ def _parse_probe_energy(self): The energy of the probe particle, in eV. """ + @abstractmethod + def _calc_probe_wavelength(self): + """ + The energy of the probe particle, in eV. + """ + @abstractmethod def _parse_default_signal(self) -> np.ndarray: """ @@ -326,7 +333,7 @@ def _try_to_find_files(filenames: List[str], additional_search_paths: List[str]) firstfile = filenames[0].split("/")[-1] # assume if first file is found that paths are good if os.path.exists(localpath / firstfile): - found_files = [localpath / file.split("/")[-1] for file in filenames] + found_files = [str(localpath / file.split("/")[-1]) for file in filenames] return found_files # This function was written to handle strings, not pathlib.Paths. diff --git a/src/diffraction_utils/diffractometers/diamond_i07.py b/src/diffraction_utils/diffractometers/diamond_i07.py index 9035da8..c750108 100644 --- a/src/diffraction_utils/diffractometers/diamond_i07.py +++ b/src/diffraction_utils/diffractometers/diamond_i07.py @@ -7,7 +7,6 @@ """ import numpy as np -from scipy.constants import Planck, elementary_charge, speed_of_light from scipy.spatial.transform import Rotation from ..diffractometer_base import DiffractometerBase @@ -18,16 +17,6 @@ INSB_LATTICE_PARAMETER = 6.479 # In Å. -def _energy_to_wavelength(energy_in_ev): - """ - Converts the incident beam energy into wavelength in Å. - - Args: - Energy of the probe particle in electron volts. - """ - return Planck * speed_of_light / (energy_in_ev * elementary_charge) * 1e10 - - class I07Diffractometer(DiffractometerBase): """ Implementation of DiffractometerBase for the diffractometer in Diamond's I07 @@ -199,9 +188,8 @@ def _insb_111_theta(self): Returns the scattering theta of the InSb (111) reflection. Needed to calculate the incident beam orientation in the DCD setup. """ - wavelength = _energy_to_wavelength(self.data_file.probe_energy) d_111 = INSB_LATTICE_PARAMETER / np.sqrt(3) - return np.arcsin(wavelength / (2 * d_111)) * 180 / np.pi + return np.arcsin(self.data_file.probe_wavelength / (2 * d_111)) * 180 / np.pi @property def _insb_220_theta(self): @@ -209,6 +197,5 @@ def _insb_220_theta(self): Returns the scattering theta of the InSb (220) reflection. Needed to calculate the incident beam orientation in the DCD setup. """ - wavelength = _energy_to_wavelength(self.data_file.probe_energy) d_220 = INSB_LATTICE_PARAMETER / np.sqrt(8) - return np.arcsin(wavelength / (2 * d_220)) * 180 / np.pi + return np.arcsin(self.data_file.probe_wavelength / (2 * d_220)) * 180 / np.pi diff --git a/src/diffraction_utils/io.py b/src/diffraction_utils/io.py index 2f2ad7f..99b0e45 100644 --- a/src/diffraction_utils/io.py +++ b/src/diffraction_utils/io.py @@ -18,6 +18,7 @@ class and its children. import json from abc import abstractmethod +from dataclasses import dataclass from pathlib import Path from typing import Dict, List, Union from warnings import warn @@ -26,6 +27,7 @@ class and its children. import numpy as np import pandas as pd from nexusformat.nexus import nxload +from scipy.constants import Planck, elementary_charge, speed_of_light from .data_file import DataFileBase from .frame_of_reference import Frame @@ -40,6 +42,16 @@ class and its children. ) +def _energy_to_wavelength(energy_in_ev): + """ + Converts the incident beam energy into wavelength in Å. + + Args: + Energy of the probe particle in electron volts. + """ + return Planck * speed_of_light / (energy_in_ev * elementary_charge) * 1e10 + + class BadNexusFileError(Exception): """ Warns that a nexus file cannot be parsed because it is incorrectly @@ -310,6 +322,48 @@ def _parse_motors(self) -> Dict[str, np.ndarray]: """ +@dataclass +class detector_info: + name: str + pixel_size: float + image_shape: tuple + is_pilatus: bool = False + is_eiger: bool = False + is_excalibur: bool = False + + +@dataclass +class excalibur_detector_info(detector_info): + name: str + pixel_size: float = 55e-6 + image_shape: tuple = (515, 2069) + is_excalibur: bool = True + + +@dataclass +class p2m_detector_info(detector_info): + name: str + pixel_size: float = 172e-6 + image_shape: tuple = (1679, 1475) + is_pilatus: bool = True + + +@dataclass +class p100k_detector_info(detector_info): + name: str + pixel_size: float = 172e-6 + image_shape: tuple = (195, 487) + is_pilatus: bool = True + + +@dataclass +class eiger_detector_info(detector_info): + name: str + pixel_size: float = 75e-6 + image_shape: tuple = (2162, 2068) + is_eiger: bool = True + + class I07Nexus(NexusBase): """ This class extends NexusBase with methods useful for scraping information @@ -339,19 +393,21 @@ class I07Nexus(NexusBase): """ # Detectors. - excalibur_detector_2021 = "excroi" - excalibur_04_2022 = "exr" - excalibur_2022_fscan = "EXCALIBUR" - pilatus_2021 = "pil2roi" - pilatus_2022 = "PILATUS" - pilatus_2_stats = "pil2stats" - pilatus_eh2_2022 = "pil3roi" - pilatus_eh2_stats = "pil3stats" - pilatus_eh2_scan = "p3r" - p2r = "p2r" - excalibur_08_2023_stats = "excstats" - excalibur_08_2023_roi = "excroi" - eiger_detector_01_2026 = "eir" + excalibur_04_2022 = excalibur_detector_info(name="exr") + excalibur_2022_fscan = excalibur_detector_info(name="EXCALIBUR") + excalibur_08_2023_stats = excalibur_detector_info(name="excstats") + excalibur_08_2023_roi = excalibur_detector_info(name="excroi") + + p2r = p2m_detector_info(name="p2r") + pilatus_2021 = p2m_detector_info(name="pil2roi") + pilatus_2_stats = p2m_detector_info(name="pil2stats") + + pilatus_2022 = p100k_detector_info(name="PILATUS") + pilatus_eh2_2022 = p100k_detector_info("pil3roi") + pilatus_eh2_stats = p100k_detector_info("pil3stats") + pilatus_eh2_scan = p100k_detector_info("p3r") + + eiger_detector_01_2026 = eiger_detector_info(name="eir") # Setups. horizontal = "horizontal" vertical = "vertical" @@ -374,7 +430,7 @@ def __init__( # initialization. self.nxfile = nxload(local_path) self.nx_entry = self._parse_nx_entry() - self.detector_name = self._parse_detector_name() + self.detector_info = self._parse_detector_info() # Initially, just set the detector rotation to be 0. This will be parsed # properly later, but some value is needed to run super().__init__() @@ -424,6 +480,8 @@ def __init__( self.dpsy = self._parse_dpsy() self.dpsz = self._parse_dpsz() self.dpsz2 = self._parse_dpsz2() + self.default_axis_type = self._parse_default_axis_type() + self.probe_energy = self._parse_probe_energy() # Get the UB and U matrices, if they have been stored. self.ub_matrix = self._parse_ub() @@ -576,7 +634,7 @@ def _is_eh1(self) -> bool: # an empty list in this code. Instead lets look for keys in the detector # that begin with diff1. # TODO: if this ever breaks, get angry. - for key in self.nx_entry[self.detector_name]: + for key in self.nx_entry[self.detector_info.name]: # Make sure that the key is utf-8. key = _get_utf_8(key) if key.startswith("diff1"): @@ -586,9 +644,12 @@ def _is_eh1(self) -> bool: # with pil2 it's most likely the P2M, which would be very difficult to # use in EH2. So, let's run a check against this too. large_det_starts = ["pil2", "p2", "eir"] - if any([self.detector_name.startswith(phrase) for phrase in large_det_starts]): + if any( + [self.detector_info.name.startswith(phrase) for phrase in large_det_starts] + ): + return True + if type(self.detector_info) is p2m_detector_info: return True - # Similarly, it's very likely that the experiment is in EH1 if the # excalibur detector is being used. if self.is_excalibur: @@ -605,11 +666,7 @@ def _is_eh2(self) -> bool: # Currently working on the assumption that 'pil3' is associated with # the p100k; also assuming that the p100k is only used in eh2. Hardly # bulletproof. - if self._parse_detector_name() in [ - I07Nexus.pilatus_eh2_2022, - I07Nexus.pilatus_eh2_stats, - I07Nexus.pilatus_eh2_scan, - ]: + if self.detector_info.name in ["pil3roi", "pil3stats", "p3r"]: return True # This check is very basic, but at the same time, should be robust. If @@ -636,7 +693,7 @@ def _is_eh2(self) -> bool: # an empty list in this code. Instead lets look for keys in the detector # that begin with diff2. # TODO: if this ever breaks, get angry. - for key in self.nx_entry[self.detector_name]: + for key in self.nx_entry[self.detector_info.name]: # Make sure that the key is utf-8. key = _get_utf_8(key) if key.startswith("diff2"): @@ -733,45 +790,27 @@ def _parse_probe_energy(self): """ return float(self.nx_instrument.dcm1energy.value) * 1e3 + def _calc_probe_wavelength(self): + """ + converts energy in eV into wavelength in Angstrom + """ + return _energy_to_wavelength(self.probe_energy) + def _parse_pixel_size(self) -> float: """ Returns the side length of pixels in the detector that's being used. """ - if self.is_excalibur: - return 55e-6 - if self.is_pilatus: - return 172e-6 - if self.is_dectris: - return 75e-6 - raise ValueError(f"Detector name {self.detector_name} is unknown.") + return self.detector_info.pixel_size - def _parse_image_shape(self) -> float: + def _parse_image_shape(self) -> tuple: """ Returns the shape of the images we expect to be recorded by this detector. """ - # In hutch 2, currently only the pilatus 100k is used. - if self._is_eh2: - if self.is_rotated: - return (195, 487) - return (195, 487) - - # In experimental hutch 1, it could be the P2M or the excalibur. - if self.is_excalibur: - # this might not be needed, as rotations can be done elsewhere in - # code - if self.is_rotated: - return 2069, 515 - return 515, 2069 - if self.is_pilatus: - if self.is_rotated: - return 1475, 1679 - return 1679, 1475 - if self.is_dectris: - if self.is_rotated: - return 2068, 2162 - return 2162, 2068 - raise ValueError(f"Detector name {self.detector_name} is unknown.") + outshape = self.detector_info.image_shape + if self.is_rotated: + return (outshape[1], outshape[0]) + return outshape def _parse_raw_image_paths(self): """ @@ -794,7 +833,7 @@ def _parse_nx_detector(self): camera, which we can parse exploiting the fact that we work out what the detector name is elsewhere. """ - return self.nx_instrument[self.detector_name] + return self.nx_instrument[self.detector_info.name] def _parse_motors(self) -> Dict[str, np.ndarray]: """ @@ -842,13 +881,19 @@ def _parse_motors(self) -> Dict[str, np.ndarray]: "dpsz2", # DPS values. ] motor_names_eh1_fourc = [ - "fourc.diff1delta", "fourc.diff1gamma", # Basic motors. - "fourc.diff1theta", "fourc.diff1chi", # Basic motors. - "dcdomega", "dcdc2rad", "diff1prot", # DCD values. - "dpsx", "dpsy", "dpsz", "dpsz2" # DPS values. + "fourc.diff1delta", + "fourc.diff1gamma", # Basic motors. + "fourc.diff1theta", + "fourc.diff1chi", # Basic motors. + "dcdomega", + "dcdc2rad", + "diff1prot", # DCD values. + "dpsx", + "dpsy", + "dpsz", + "dpsz2", # DPS values. ] - # The motors of interest in eh2. motor_names_eh2 = [ "diff2delta", @@ -861,13 +906,16 @@ def _parse_motors(self) -> Dict[str, np.ndarray]: if self._is_eh2: motor_names = motor_names_eh2 + fourc_check = any( + [val.startswith("fourc") for val in self.nx_instrument.keys()] + ) # Set the fourc names if our detector name is pil3roi. - fourcnames_eh2 = [I07Nexus.pilatus_eh2_2022, I07Nexus.pilatus_eh2_scan] - if self.detector_name in fourcnames_eh2: + fourcnames_eh2 = ["pil3roi", "p3r"] + if (self.detector_info.name in fourcnames_eh2) and (fourc_check): motor_names = motor_names_eh2_fourc - fourcnames_eh1 = [I07Nexus.excalibur_detector_2021] - if self.detector_name in fourcnames_eh1: + fourcnames_eh1 = ["excroi"] + if (self.detector_info.name in fourcnames_eh1) and (fourc_check): motor_names = motor_names_eh1_fourc motors_dict = {} @@ -927,123 +975,85 @@ def _parse_dcd_omega(self) -> np.ndarray: if self.is_eh1: return self.motors["dcdomega"] - def _parse_delta(self) -> np.ndarray: - """ - Returns a numpy array of the delta values throughout the scan. - """ + def _parse_diff2motor(self, name: str, zeros: bool = False): + try: + return self.motors[f"diff2{name}"] + except KeyError: + if zeros: + return np.zeros((self.scan_length)) + return self.motors[f"fourc.diff2{name}"] + + def _parse_diff1motor(self, name: str, zeros: bool = False): + try: + return self.motors[f"diff1{name}"] + except KeyError: + if zeros: + return np.zeros((self.scan_length)) + return self.motors[f"fourc.diff1{name}"] + + def _parse_diff_motor(self, name: str): # Force set this to zero if we're using the DPS system. This is # important, because moving the diffractometer arm out of the way for # dps experiments means that this often ends up at around 90 degrees! - if self.using_dps: - return np.zeros((self.scan_length)) # also need to set to zero if using p2m without dps - p2mlist = ["pil2stats", "pil2roi", "p2r"] - if self.detector_name in p2mlist: + if (self.detector_info is p2m_detector_info) or (self.using_dps): return np.zeros((self.scan_length)) - if self.is_eh2: - try: - return self.motors["diff2delta"] - except KeyError: - return self.motors["fourc.diff2delta"] - if self.is_eh1: - try: - return self.motors["diff1delta"] - except KeyError: - return self.motors["fourc.diff1delta"] + self._parse_diff2motor(name) + return self._parse_diff1motor(name) + + def _parse_delta(self) -> np.ndarray: + """ + Returns a numpy array of the delta values throughout the scan. + """ + return self._parse_diff_motor("delta") def _parse_gamma(self) -> np.ndarray: """ Returns a numpy array of the gamma values throughout the scan. """ - # Force set this to zero if we're using the DPS system. This is - # important, because moving the diffractometer arm out of the way for - # dps experiments means that this could take any value! - if self.using_dps: - return np.zeros((self.scan_length)) - # also need to set to zero if using p2m without dps - p2mlist = ["pil2stats", "pil2roi", "p2r"] - if self.detector_name in p2mlist: - return np.zeros((self.scan_length)) - - if self.is_eh2: - try: - return self.motors["diff2gamma"] - except KeyError: - return self.motors["fourc.diff2gamma"] - if self.is_eh1: - try: - return self.motors["diff1gamma"] - except KeyError: - return self.motors["fourc.diff1gamma"] + return self._parse_diff_motor("gamma") def _parse_omega(self) -> np.ndarray: """ Returns a numpy array of the omega values throughout the scan. """ if self.is_eh2: - try: - return self.motors["diff2omega"] - except KeyError: - return self.motors["fourc.diff2omega"] - try: - return self.motors["diff1omega"] - except KeyError: - return np.zeros((self.scan_length)) + return self._parse_diff2motor("omega") + return self._parse_diff1motor(name="omega", zeros=True) def _parse_alpha(self) -> np.ndarray: """ Returns a numpy array of the alpha values throughout the scan. """ if self.is_eh2: - try: - return self.motors["diff2alpha"] - except KeyError: - return self.motors["fourc.diff2alpha"] - try: - return self.motors["diff1alpha"] - except KeyError: - return np.zeros((self.scan_length)) + return self._parse_diff2motor("alpha") + return self._parse_diff1motor(name="alpha", zeros=True) def _parse_theta(self) -> np.ndarray: """ Returns a numpy array of the theta values throughout the scan. """ if self.is_eh1: - try: - return self.motors["diff1theta"] - except KeyError: - return self.motors["fourc.diff1theta"] - - # In eh2, just return a bunch of zeros. In reality, there isn't a - # diff2theta field, but we can equivalently represent that by an array - # of zeroes. - return np.zeros((self.scan_length)) + return self._parse_diff1motor(name="theta") + return self._parse_diff2motor(name="theta", zeros=True) def _parse_chi(self) -> np.ndarray: """ Returns a numpy array of the chi values throughout the scan. """ if self.is_eh1: - try: - return self.motors["diff1chi"] - except KeyError: - return self.motors["fourc.diff1chi"] - - # In eh2, just return a bunch of zeros. In reality, there isn't a - # diff2chi field, but we can equivalently represent that by an array - # of zeroes. - return np.zeros((self.scan_length)) + return self._parse_diff1motor(name="chi") + return self._parse_diff2motor(name="chi", zeros=True) def _parse_detector_rot(self) -> float: """ Returns the orientation of the detector. """ - p2mlist = ["pil2stats", "pil2roi", "p2r"] - if (self.is_eh1) & (self._parse_detector_name() not in p2mlist): + if (self.is_eh1) & (type(self.detector_info) is not p2m_detector_info): return self.motors["diff1prot"][0] # For now, assume unrotated detectors in eh2. - return 0 + return 0.0 def _parse_dpsx(self) -> np.ndarray: """ @@ -1073,12 +1083,12 @@ def _parse_dpsz2(self) -> np.ndarray: if self.is_eh1: return self.motors["dpsz2"] / 1e3 - def _parse_detector_name(self) -> str: + def _parse_detector_info(self) -> detector_info: """ Returns the name of the detector that we're using. Because life sucks, this is a function of time. """ - entry_checknames = { + checknames = { "exr": I07Nexus.excalibur_04_2022, "pil2roi": I07Nexus.pilatus_2021, "PILATUS": I07Nexus.pilatus_2022, @@ -1088,31 +1098,31 @@ def _parse_detector_name(self) -> str: "pil3roi": I07Nexus.pilatus_eh2_2022, "pil3stats": I07Nexus.pilatus_eh2_stats, "p3r": I07Nexus.pilatus_eh2_scan, - "excstats": I07Nexus.excalibur_08_2023_stats, "excroi": I07Nexus.excalibur_08_2023_roi, "eir": I07Nexus.eiger_detector_01_2026, + "excstats": I07Nexus.excalibur_08_2023_stats, } # assuming duplicate value is from obsolete naming - "excroi":I07Nexus.excalibur_detector_2021, - instrument_checknames = { - "excroi": I07Nexus.excalibur_08_2023_roi, - "exr": I07Nexus.excalibur_04_2022, - "pil2roi": I07Nexus.pilatus_2021, - "PILATUS": I07Nexus.pilatus_2022, - "pil2stats": I07Nexus.pilatus_2_stats, - "p2r": I07Nexus.p2r, - "EXCALIBUR": I07Nexus.excalibur_2022_fscan, - "pil3roi": I07Nexus.pilatus_eh2_2022, - "pil3stats": I07Nexus.pilatus_eh2_stats, - "p3r": I07Nexus.pilatus_eh2_scan, - "eir": I07Nexus.eiger_detector_01_2026, - } - - for key, val in entry_checknames.items(): + # instrument_checknames = { + # "excroi": I07Nexus.excalibur_08_2023_roi, + # "exr": I07Nexus.excalibur_04_2022, + # "pil2roi": I07Nexus.pilatus_2021, + # "PILATUS": I07Nexus.pilatus_2022, + # "pil2stats": I07Nexus.pilatus_2_stats, + # "p2r": I07Nexus.p2r, + # "EXCALIBUR": I07Nexus.excalibur_2022_fscan, + # "pil3roi": I07Nexus.pilatus_eh2_2022, + # "pil3stats": I07Nexus.pilatus_eh2_stats, + # "p3r": I07Nexus.pilatus_eh2_scan, + # "eir": I07Nexus.eiger_detector_01_2026, + # } + + for key, val in checknames.items(): if key in self.nx_entry: return val - for key, val in instrument_checknames.items(): + for key, val in checknames.items(): if key in self.nx_entry.NXinstrument[0]: return val @@ -1128,6 +1138,31 @@ class GOD_DAMNIT_FIX_YOUR_NXDETECTOR_Error(Exception): "Your detector changed name again..." ) + def _parse_default_axis_type(self) -> str: + """ + Returns the type of our default axis, either being 'q', 'th' or 'tth'. + """ + if self.default_axis_name == "qdcd": + return "q" + if self.default_axis_name == "diff1chi": + return "th" + if self.default_axis_name == "diff1delta": + return "tth" + + # add in option for EH2 scanning alpha + diff2alphanames = ["diff2alpha_value_set", "diff2alpha"] + if self.default_axis_name in diff2alphanames: + return "th" + + # add in option for EH1 scanning chi + if self.default_axis_name == "diff1chi_value_set": + return "th" + + # It's also possible that self.default_axis_name isn't recorded in some + # nexus files. Just in case, let's check the length of diff1delta. + if isinstance(self.nx_instrument["diff1delta"].value.nxdata, np.ndarray): + return "tth" + @warn_missing_metadata def _parse_signal_regions(self) -> List[Region]: """ @@ -1137,10 +1172,10 @@ def _parse_signal_regions(self) -> List[Region]: """ # This handles the fact that ROIs used to be stored in a completely # different way. - if self.detector_name == I07Nexus.excalibur_detector_2021: + if self.detector_info.name == "excroi": return [self._get_ith_region(i=1)] # This attempts to parse an invalid json file. - if self.detector_name == I07Nexus.excalibur_04_2022: + if self.detector_info.name == I07Nexus.excalibur_04_2022: # Make sure our code executes for bytes and strings. try: json_str = self.nx_instrument["ex_rois/excalibur_ROIs"]._value.decode( @@ -1156,7 +1191,7 @@ def _parse_signal_regions(self) -> List[Region]: roi_dict = json.loads(json_str) return [Region.from_dict(roi_dict["Region_1"])] - if self.detector_name == I07Nexus.excalibur_08_2023_roi: + if self.detector_info.name == I07Nexus.excalibur_08_2023_roi: regionsfull = list( filter(lambda x: "Region" in x, self.nx_instrument.excroi.keys()) ) @@ -1178,10 +1213,10 @@ def _parse_signal_regions(self) -> List[Region]: # use similar setting to other version where it returns just the # region of region1 return [Region.from_dict(total_dict["Region_1"])] - if self.detector_name == I07Nexus.excalibur_2022_fscan: + if self.detector_info.name == I07Nexus.excalibur_2022_fscan: # Just ignore the region of interest for fscans. return - if self.detector_name == I07Nexus.excalibur_08_2023_stats: + if self.detector_info.name == I07Nexus.excalibur_08_2023_stats: # Just ignore use of regions if using excstats. return raise NotImplementedError() @@ -1213,11 +1248,15 @@ def background_regions(self) -> List[Region]: Currently we just ignore the zeroth region and call the rest of them background regions. """ - if self.detector_name == I07Nexus.excalibur_detector_2021: + if self.detector_info.name == "excroi": return [ self._get_ith_region(i) for i in range(2, self._number_of_regions + 1) ] - if self.detector_name == I07Nexus.excalibur_04_2022: + excalibur_roi_list = [ + "exr", + "EXCALIBUR", + ] # I07Nexus.excalibur_04_2022, I07Nexus.excalibur_2022_fscan] + if self.detector_info.name in excalibur_roi_list: # Make sure our code executes for bytes and strings. try: json_str = self.nx_instrument["ex_rois/excalibur_ROIs"]._value.decode( @@ -1296,36 +1335,21 @@ def is_excalibur(self) -> bool: """ Returns whether or not we're currently using the excalibur detector. """ - return self.detector_name in ["excroi", "exr", "EXCALIBUR", "excstats"] + return self.detector_info.is_excalibur @property def is_pilatus(self) -> bool: """ Returns whether or not we're currently using the pilatus detector. """ - return self.detector_name in [ - I07Nexus.pilatus_2021, - I07Nexus.pilatus_2022, - I07Nexus.pilatus_2_stats, - I07Nexus.p2r, - I07Nexus.pilatus_eh2_2022, - I07Nexus.pilatus_eh2_stats, - I07Nexus.pilatus_eh2_scan, - ] - - @property - def is_dectris(self) -> bool: - """ - Returns whether or not detector is a dectris detector - """ - return self.detector_name in [I07Nexus.eiger_detector_01_2026] + return self.detector_info.is_pilatus @property - def is_dectris(self) -> bool: + def is_eiger(self) -> bool: """ - Returns whether or not detector is a dectris detector + Returns whether or not detector is a eiger detector """ - return self.detector_name in [I07Nexus.eiger_detector_01_2026] + return self.detector_info.is_eiger @warn_missing_metadata def _parse_u(self) -> np.ndarray: diff --git a/tests/test_io.py b/tests/test_io.py index d8a2636..7100bf4 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -12,7 +12,7 @@ def test_excalibur_name(): """ Make sure that we're spelling the detector names properly! """ - assert I07Nexus.excalibur_detector_2021 == "excroi" - assert I07Nexus.excalibur_04_2022 == "exr" - assert I07Nexus.pilatus_2021 == "pil2roi" - assert I07Nexus.pilatus_2022 == "PILATUS" + assert I07Nexus.excalibur_08_2023_roi.name == "excroi" + assert I07Nexus.excalibur_04_2022.name == "exr" + assert I07Nexus.pilatus_2021.name == "pil2roi" + assert I07Nexus.pilatus_2022.name == "PILATUS"