diff --git a/smi_analysis/Detector.py b/smi_analysis/Detector.py index bc13c15..2c04d5b 100644 --- a/smi_analysis/Detector.py +++ b/smi_analysis/Detector.py @@ -1,6 +1,6 @@ import numpy as np from pyFAI import detectors -from pyFAI.detectors import Pilatus, Pilatus300kw, Pilatus1M, Pilatus100k, Pilatus300k, Eiger1M +from pyFAI.detectors import Pilatus, Pilatus300kw, Pilatus1M, Pilatus100k, Pilatus300k, Eiger1M, Eiger500k from pyFAI.detectors._common import Detector @@ -289,3 +289,24 @@ def calc_mask(self, img): :] = False, False, False, False return np.logical_not(mask) + +class Eiger500k_xeuss(Eiger500k): + ''' + Eiger1M class inherited from the pyFAI Eiger1M class + This class is used to add a specific masking for the Eiger1M of the xeuss instru at CEA + ''' + aliases = ["Eiger1M_xeuss"] + + def calc_mask(self, img): + ''' + :return: (a 2D array) A mask array with 0 and 1 with 0s where the image will be masked + ''' + + mask = np.logical_not(np.zeros(np.shape(img))) + self.shape= np.shape(img) + mask[np.where(img<-0.5)]=False + + mask[:, :5], mask[:, -5:], mask[:5, :], mask[-5:, + :] = False, False, False, False + + return np.logical_not(mask) diff --git a/smi_analysis/SMI_beamline.py b/smi_analysis/SMI_beamline.py index 229ccc1..ca598ef 100644 --- a/smi_analysis/SMI_beamline.py +++ b/smi_analysis/SMI_beamline.py @@ -72,8 +72,10 @@ def define_detector(self): self.det = Detector.Pilatus300k_OPLS() elif self.detector == 'Eiger1M_xeuss': self.det = Detector.Eiger1M_xeuss() + elif self.detector == 'Eiger500k_xeuss': + self.det = Detector.Eiger500k_xeuss() else: - raise Exception('Unknown detector for SMI. Should be either: Pilatus1m or Pilatus900kw or Pilatus300kw or rayonix') + raise Exception('Unknown detector for SMI. Should be either: Pilatus1m or Pilatus900kw or Pilatus300kw or rayonix or Eiger1M_xeuss or Eiger500k_xeuss') def open_data(self, path, lst_img, optional_mask=None): """ @@ -92,7 +94,7 @@ def open_data(self, path, lst_img, optional_mask=None): self.bs = self.bs + [[0, 0]]*(len(lst_img) - len(self.bs)) for i, (img, bs) in enumerate(zip(lst_img, self.bs)): - if self.detector != 'rayonix' and self.detector != 'Eiger1M_xeuss': + if self.detector != 'rayonix' and self.detector != 'Eiger1M_xeuss' and self.detector != 'Eiger500k_xeuss': if self.detector == 'Pilatus900kw': masks = self.det.calc_mask(bs=bs, bs_kind=self.bs_kind, optional_mask=optional_mask) self.masks.append(masks[:, :195]) @@ -139,7 +141,7 @@ def open_data_db(self, lst_img, optional_mask=None): self.imgs = [] for img, bs in zip(lst_img, self.bs): - if self.detector != 'rayonix' and self.detector != 'Eiger1M_xeuss': + if self.detector != 'rayonix' and self.detector != 'Eiger1M_xeuss' and self.detector != 'Eiger500k_xeuss': self.masks.append(self.det.calc_mask(bs=bs, bs_kind=self.bs_kind, optional_mask=optional_mask)) if self.detector == 'Pilatus1m': self.imgs.append(img) @@ -166,7 +168,7 @@ def calculate_integrator_trans(self, det_rots): ) ai.set_wavelength(self.wav) - if self.detector == 'Eiger1M_xeuss': + if self.detector == 'Eiger1M_xeuss' or self.detector == 'Eiger500k_xeuss': if len(det_rots) == len(self.center) and len(det_rots) == len(self.sdd): for i, (det_rot, center, sdd) in enumerate(zip(det_rots, self.center, self.sdd)): ai.setFit2D(sdd, center[0], center[1]) @@ -193,7 +195,7 @@ def calculate_integrator_trans(self, det_rots): def calculate_integrator_gi(self, det_rots): ai = Transform(wavelength=self.wav, detector=self.det, incident_angle=self.alphai) - if self.detector == 'Eiger1M_xeuss': + if self.detector == 'Eiger1M_xeuss' or self.detector == 'Eiger500k_xeuss': if len(det_rots) == len(self.center) and len(det_rots) == len(self.sdd): for i, (det_rot, center, sdd) in enumerate(zip(det_rots, self.center, self.sdd)): ai.setFit2D(directDist=sdd, centerX=center[0], centerY=center[1])