Skip to content

Commit

Permalink
FormatXTC: add wavelength_fallback parameter
Browse files Browse the repository at this point in the history
If the wavelength cannot be found from the XTC stream, fall back to using this value instead

Also fixes some serialtbx imports
  • Loading branch information
phyy-nx committed Mar 12, 2024
1 parent 78147cc commit 6d3bb73
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/XXX.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
XTC support: add wavelength_fallback parameter
8 changes: 7 additions & 1 deletion src/dxtbx/format/FormatXTC.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
for any events with a dropped spectrum. If the spectrum is \
present and calibration constants are provided, \
wavelength_offset is ignored.
wavelength_fallback = None
.type = float
.help = If the wavelength cannot be found from the XTC stream, fall \
back to using this value instead
spectrum_address = FEE-SPEC0
.type = str
.help = Address for incident beam spectrometer
Expand Down Expand Up @@ -391,7 +395,7 @@ def get_psana_timestamp(self, index):
sec = time[0]
nsec = time[1]

return serialtbx.util.timestamp((sec, nsec / 1e6))
return serialtbx.util.time.timestamp((sec, nsec / 1e6))

def get_num_images(self):
return self.n_images
Expand All @@ -416,6 +420,8 @@ def _beam(self, index=None):
wavelength = serialtbx.detector.xtc.evt_wavelength(
evt, delta_k=self.params.wavelength_delta_k
)
if wavelength is None or wavelength <= 0:
wavelength = self.params.wavelength_fallback
if self.params.wavelength_offset is not None:
wavelength += self.params.wavelength_offset
if wavelength is None:
Expand Down
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatXTCJungfrau.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def understand(image_file):
return any(["jungfrau" in src.lower() for src in params.detector_address])

def get_raw_data(self, index=None):
from serialtbx.detector.util import jungfrau
from serialtbx.detector import jungfrau

if index is None:
index = 0
Expand Down

0 comments on commit 6d3bb73

Please sign in to comment.