Skip to content

Commit

Permalink
Merge branch 'main' into 591_XDS
Browse files Browse the repository at this point in the history
  • Loading branch information
kif authored Oct 14, 2024
2 parents 45d1e86 + 42c0672 commit c70ef72
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
28 changes: 25 additions & 3 deletions src/fabio/app/eiger2cbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
__author__ = "Jerome Kieffer"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__licence__ = "MIT"
__date__ = "03/12/2021"
__date__ = "07/10/2024"
__status__ = "production"

import logging
Expand Down Expand Up @@ -259,7 +259,7 @@ def convert_one(input_filename, options, start_at=0):
if options.pilatus:
shape = select_pilatus_detecor(shape)

pilatus_headers = cbfimage.PilatusHeader("Silicon sensor, thickness 0.001 m")
pilatus_headers = cbfimage.PilatusHeader()
if isinstance(source, limaimage.LimaImage):
# Populate the Pilatus header from the Lima
entry_name = source.h5.attrs.get("default")
Expand Down Expand Up @@ -290,7 +290,27 @@ def convert_one(input_filename, options, start_at=0):
except Exception as e:
logger.warning("Error in searching for exposure time (%s): %s", type(e), e)
elif isinstance(source, eigerimage.EigerImage):
raise NotImplementedError("Please implement Eiger detector data format parsing or at least open an issue")
entry_name = source.h5.attrs.get("default")
if entry_name:
entry = source.h5.get(entry_name)
try:
nxdetector = entry["instrument/detector"]
except:
logger.error("No detector definition in Eiger file, is this a master file ?")
else:
detector = "%s, S/N %s" % (nxdetector["description"][()].decode(),
nxdetector["detector_number"][()].decode())
pilatus_headers["Detector"] = detector
pilatus_headers["Pixel_size"] = (nxdetector["x_pixel_size"][()],
nxdetector["y_pixel_size"][()])
pilatus_headers["Exposure_time"] = nxdetector["count_time"][()]
pilatus_headers["Exposure_period"] = nxdetector["frame_time"][()]
pilatus_headers["Wavelength"] = entry["instrument/beam/incident_wavelength"][()]
pilatus_headers["Detector_distance"] = nxdetector["detector_distance"][()]
pilatus_headers["Beam_xy"] = (nxdetector["beam_center_x"][()],
nxdetector["beam_center_y"][()])
pilatus_headers["sensor"] = (nxdetector["sensor_material"][()].decode(),
nxdetector["sensor_thickness"][()])
else:
raise NotImplementedError("Unsupported format: %s" % source.__class__.__name__)

Expand All @@ -307,6 +327,8 @@ def convert_one(input_filename, options, start_at=0):
pilatus_headers["Alpha"] = options.alpha
if options.kappa:
pilatus_headers["Kappa"] = options.kappa
if "sensor" not in pilatus_headers:
pilatus_headers["sensor"] = ("Silicon", 0.001)
formula = None
destination = None
if options.chi is not None:
Expand Down
26 changes: 21 additions & 5 deletions src/fabio/app/eiger2crysalis.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
__author__ = "Jerome Kieffer"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__licence__ = "MIT"
__date__ = "15/03/2024"
__date__ = "09/10/2024"
__status__ = "production"

FOOTER = """To import your files as a project:
Expand Down Expand Up @@ -275,7 +275,22 @@ def common_headers(self):
headers["dexposuretimeinsec"] = 1 # meaningfull value.

elif isinstance(source, eigerimage.EigerImage):
raise NotImplementedError("Please implement Eiger detector data format parsing or at least open an issue")
entry_name = source.h5.attrs.get("default")
if entry_name is None:
entry_name = "entry"
entry = source.h5.get(entry_name)
try:
nxdetector = entry["instrument/detector"]
except:
logger.error("No detector definition in Eiger file, is this a master file ?")
else:
headers["drealpixelsizex"] = nxdetector["x_pixel_size"][()] * 1e3
headers["drealpixelsizey"] = nxdetector["y_pixel_size"][()] * 1e3
headers["dxorigininpix"] = nxdetector["beam_center_x"][()]
headers["dyorigininpix"] = nxdetector["beam_center_y"][()]
headers["ddistanceinmm"] = nxdetector["detector_distance"][()] * 1e3
headers["dexposuretimeinsec"] = nxdetector["count_time"][()]
wavelength = entry["instrument/beam/incident_wavelength"][()]
else:
raise NotImplementedError("Unsupported format: %s" % source.__class__.__name__)
if self.mask is None:
Expand Down Expand Up @@ -324,7 +339,7 @@ def common_headers(self):
value = numexpr.NumExpr(self.options.omega)
self.scan_type = "omega"
headers["dom_s"] = headers["dom_e"] = value

return headers

def convert_one(self, input_filename, start_at=0):
Expand Down Expand Up @@ -453,13 +468,14 @@ def treat_mask(self, full=False):
dend = self.headers["dph_s"](self.processed_frames)
dphi = 0.0
domega = self.headers["dom_s"]
else: #Omega-scan
elif self.scan_type=="omega":
iscantype = xcaliburimage.SCAN_TYPE.Omega.value
dstart = self.headers["dom_s"](0)
dend = self.headers["dom_s"](self.processed_frames)
dphi = self.headers["dph_s"]
domega = 0.0

else:
raise RuntimeError("This program only supports Omega and Phi scans, please provide the scan type in the command-line. See the output of the `--help` options.")
oscil = (dend-dstart)/self.processed_frames
sweep = xcaliburimage.Sweep(0,
iscantype,
Expand Down
12 changes: 9 additions & 3 deletions src/fabio/cbfimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
__author__ = "Jérôme Kieffer"
__contact__ = "[email protected]"
__license__ = "MIT"
__date__ = "04/07/2023"
__date__ = "07/10/2024"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"

import os
Expand Down Expand Up @@ -923,9 +923,12 @@ def clean_string(cls, input_string):
i += 1
return lines

def __init__(self, content, convention="PILATUS_1.2"):
def __init__(self, content=None, convention="PILATUS_1.2"):
assert convention == "PILATUS_1.2"
self._dict = self._parse(content)
if content:
self._dict = self._parse(content)
else:
self._dict = OrderedDict()

def __repr__(self):
lines = []
Expand Down Expand Up @@ -973,3 +976,6 @@ def __setitem__(self, key, value):

def __getitem__(self, key):
return self._dict[key]

def __contains__(self, key):
return key in self._dict

0 comments on commit c70ef72

Please sign in to comment.