Skip to content

Commit

Permalink
Fix .ndarray(module_gaps=True) for xtdf detector data
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Jul 17, 2023
1 parent 6a889bc commit b643ad3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion extra_data/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,8 @@ def ndarray(self, *, fill_value=None, out=None, roi=(), astype=None, module_gaps
# dim in raw data (except AGIPD, where it is data/gain)
roi = np.index_exp[:] + roi

for mod_ix, (modno, kd) in enumerate(sorted(self.modno_to_keydata.items())):
for i, (modno, kd) in enumerate(sorted(self.modno_to_keydata.items())):
mod_ix = (modno - self.det._modnos_start_at) if module_gaps else i
for chunk in kd._data_chunks:
self._read_chunk(chunk, reading_view[mod_ix], roi)

Expand Down
13 changes: 12 additions & 1 deletion extra_data/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ def test_get_array_gap(mock_lpd_mini_gap_run):
np.testing.assert_array_equal(arr[1, :, 0, 0, 0], [1, 2, 0, 3, 4])



def test_get_array_roi(mock_fxe_raw_run):
run = RunDirectory(mock_fxe_raw_run)
det = LPD1M(run.select_trains(by_index[:3]))
Expand All @@ -168,6 +167,18 @@ def test_get_array_roi_dssc(mock_scs_run):
assert arr.shape == (1, 128, 64, 5, 12)


def test_ndarray_module_gaps(mock_fxe_raw_run):
run = RunDirectory(mock_fxe_raw_run)
det = LPD1M(run, modules=[2]).select_trains(np.s_[:3])
det_data = det['image.data']
assert det_data.shape == (1, 128 * 3, 256, 256)
assert det_data.ndarray().shape == (1, 128 * 3, 256, 256)

arr_w_gaps = det_data.ndarray(module_gaps=True, fill_value=7)
assert arr_w_gaps.shape == (16, 128 * 3, 256, 256)
assert arr_w_gaps[:, 0, 0, 0].tolist() == ([7] * 2) + [0] + ([7] * 13)


def test_get_array_lpd_parallelgain(mock_lpd_parallelgain_run):
run = RunDirectory(mock_lpd_parallelgain_run)
det = LPD1M(run.select_trains(by_index[:2]), parallel_gain=True)
Expand Down

0 comments on commit b643ad3

Please sign in to comment.