Skip to content

Commit

Permalink
Adding Eiger500k for the Xeuss WAXS detector
Browse files Browse the repository at this point in the history
  • Loading branch information
gfreychet committed Nov 4, 2024
1 parent 4f67df2 commit ddad2b2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
23 changes: 22 additions & 1 deletion smi_analysis/Detector.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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)
12 changes: 7 additions & 5 deletions smi_analysis/SMI_beamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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])
Expand Down Expand Up @@ -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)
Expand All @@ -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])
Expand All @@ -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])
Expand Down

0 comments on commit ddad2b2

Please sign in to comment.