Skip to content

Commit

Permalink
Use raw data instead of corrected data for cbf_writer (cctbx#660)
Browse files Browse the repository at this point in the history
Found by @dermen

For cbf_writer, use imageset.get_raw_data(i) instead of imageset[i], the latter of which applies gain correction.  Solves two problems:

1) Avoids promoting int arrays to floats to save file space
2) Avoids applying the gain twice downstream, since gain is also set on the detector model

Also fix missing encode call for int data

Co-authored-by: Derek Mendez <dermen@lbl.gov>
  • Loading branch information
phyy-nx and dermen committed Sep 7, 2023
1 parent 593c0ef commit 258a65e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions newsfragments/660.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Bugfix for dxtbx.image_average: handle detector gain and pixel data type better
6 changes: 3 additions & 3 deletions src/dxtbx/format/cbf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ def add_data_to_cbf(self, cbf, index=None, data=None, verbose=False):
"""
if data is None:
if index is None:
data = self.imageset[0]
data = self.imageset.get_raw_data(0)
else:
data = self.imageset[index]
data = self.imageset.get_raw_data(index)
if not isinstance(data, tuple):
data = (data,)

Expand Down Expand Up @@ -539,7 +539,7 @@ def add_data_to_cbf(self, cbf, index=None, data=None, verbose=False):
if dataisint[i]:
elsize = 4
elsigned = 1

byteorder = byteorder.encode()
cbf.set_integerarray_wdims_fs(
pycbf.CBF_PACKED,
binary_id,
Expand Down

0 comments on commit 258a65e

Please sign in to comment.