Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix det.masked_data().select_pulses() in XTDF detector components #571

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions extra_data/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,13 @@ def _init_kwargs(self):
)
return kw

# Overridden for XTDF data to accommodate pulse selection
def _mask_keydata(self):
return self.det[self._mask_key]

def _load_mask(self, module_gaps):
"""Load the mask & convert to boolean (True for bad pixels)"""
mask_data = self.det[self._mask_key].ndarray(module_gaps=module_gaps)
mask_data = self._mask_keydata().ndarray(module_gaps=module_gaps)
if self._mask_bits is None:
return mask_data != 0 # Skip extra temporary array from &
else:
Expand Down Expand Up @@ -1272,7 +1276,8 @@ def dask_array(self, *, labelled=False, subtrain_index='pulseId',

class XtdfMaskedKeyData(DetectorMaskedKeyData, XtdfImageMultimodKeyData):
# Created from xtdf_det.masked_data()
pass
def _mask_keydata(self):
return self.det[self._mask_key].select_pulses(self._pulse_sel)


class FramesFileWriter(FileWriter):
Expand Down
5 changes: 5 additions & 0 deletions extra_data/tests/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ def test_xtdf_masked_data(mock_reduced_spb_proc_run):
line0_2mod[1, 1:32] = np.nan
np.testing.assert_array_equal(arr[:, 0, 0, :], line0_2mod)

# Test with pulse selection (frames per train is consistent but arbitrary)
kd_pulse_sel = kd.select_pulses(np.s_[:3])
assert kd_pulse_sel.shape[1] <= 3
assert kd_pulse_sel.ndarray().shape == kd_pulse_sel.shape

kd = agipd.masked_data(mask_bits=[1, 4], masked_value=-1).select_trains(np.s_[:1])
arr = kd.ndarray()
line0_2mod = np.zeros((2, 128), dtype=np.float32)
Expand Down