Skip to content

Commit 233815b

Browse files
authored
Merge pull request #418 from European-XFEL/rm-lpd-mini
Remove LPD Mini component class (pending redesign)
2 parents b255776 + 96f7220 commit 233815b

7 files changed

Lines changed: 28 additions & 103 deletions

File tree

docs/agipd_lpd_data.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ DSSC and JUNGFRAU, pulling together the separate modules into a single array.
2727

2828
The methods of this class are identical to those of :class:`LPD1M`, below.
2929

30-
.. autoclass:: LPDMini
31-
32-
The methods of this class are identical to those of :class:`LPD1M:, below.
33-
3430
.. autoclass:: LPD1M
3531

3632
.. automethod:: get_array

docs/lpd_data.ipynb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,6 @@
292292
"source": [
293293
"LPD data may also be recorded in *parallel gain* mode, resulting in high-, medium- and low-gain frames for each pulse. To read this kind of data with the correct labels, use `LPD1M(run, parallel_gain=True)`. This will retrieve data with an extra gain dimension, labelled with 0, 1 and 2 for high-, medium- and low-gain respectively."
294294
]
295-
},
296-
{
297-
"cell_type": "markdown",
298-
"metadata": {},
299-
"source": [
300-
"The LPD Mini consists of a single module. \n",
301-
"Its data can be accessed similarly using the `LPDMini` class."
302-
]
303295
}
304296
],
305297
"metadata": {

extra_data/components.py

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
'AGIPD500K',
2020
'DSSC1M',
2121
'LPD1M',
22-
'LPDMini',
2322
'JUNGFRAU',
2423
'identify_multimod_detectors',
2524
]
@@ -1430,8 +1429,30 @@ class DSSC1M(XtdfDetectorBase):
14301429
module_shape = (128, 512)
14311430

14321431

1433-
class LPDBase:
1434-
"""Base LPD class supporting parallel gain mode."""
1432+
@multimod_detectors
1433+
class LPD1M(XtdfDetectorBase):
1434+
"""An interface to LPD-1M data.
1435+
1436+
Parameters
1437+
----------
1438+
data: DataCollection
1439+
A data collection, e.g. from :func:`.RunDirectory`.
1440+
modules: set of ints, optional
1441+
Detector module numbers to use. By default, all available modules
1442+
are used.
1443+
detector_name: str, optional
1444+
Name of a detector, e.g. 'FXE_DET_LPD1M-1'. This is only needed
1445+
if the dataset includes more than one LPD detector.
1446+
min_modules: int
1447+
Include trains where at least n modules have data. Default is 1.
1448+
parallel_gain: bool
1449+
Set to True to read this data as parallel gain data, where high, medium
1450+
and low gain data are stored sequentially within each train. This will
1451+
repeat the pulse & cell IDs from the first 1/3 of each train, and add gain
1452+
stage labels from 0 (high-gain) to 2 (low-gain).
1453+
"""
1454+
_source_re = re.compile(r'(?P<detname>.+_LPD1M.*)/DET/(?P<modno>\d+)CH')
1455+
module_shape = (256, 256)
14351456

14361457
def __init__(self, data: DataCollection, detector_name=None, modules=None,
14371458
*, min_modules=1, parallel_gain=False):
@@ -1515,56 +1536,6 @@ def _make_image_index(self, tids, inner_ids, inner_name='pulse'):
15151536
)
15161537

15171538

1518-
@multimod_detectors
1519-
class LPD1M(LPDBase, XtdfDetectorBase):
1520-
"""An interface to LPD-1M data.
1521-
1522-
Parameters
1523-
----------
1524-
data: DataCollection
1525-
A data collection, e.g. from :func:`.RunDirectory`.
1526-
modules: set of ints, optional
1527-
Detector module numbers to use. By default, all available modules
1528-
are used.
1529-
detector_name: str, optional
1530-
Name of a detector, e.g. 'FXE_DET_LPD1M-1'. This is only needed
1531-
if the dataset includes more than one LPD detector.
1532-
min_modules: int
1533-
Include trains where at least n modules have data. Default is 1.
1534-
parallel_gain: bool
1535-
Set to True to read this data as parallel gain data, where high, medium
1536-
and low gain data are stored sequentially within each train. This will
1537-
repeat the pulse & cell IDs from the first 1/3 of each train, and add gain
1538-
stage labels from 0 (high-gain) to 2 (low-gain).
1539-
"""
1540-
_source_re = re.compile(r'(?P<detname>.+_LPD1M.*)/DET/(?P<modno>\d+)CH')
1541-
module_shape = (256, 256)
1542-
1543-
1544-
@multimod_detectors
1545-
class LPDMini(LPDBase, XtdfDetectorBase):
1546-
"""An interface to LPD-Mini data.
1547-
1548-
Parameters
1549-
----------
1550-
data: DataCollection
1551-
A data collection, e.g. from :func:`.RunDirectory`.
1552-
modules: set of ints, optional
1553-
Detector module numbers to use. By default, all available modules
1554-
are used.
1555-
detector_name: str, optional
1556-
Name of a detector, e.g. 'FXE_DET_LPD_MINI'. This is only needed
1557-
if the dataset includes more than one LPD detector.
1558-
parallel_gain: bool
1559-
Set to True to read this data as parallel gain data, where high, medium
1560-
and low gain data are stored sequentially within each train. This will
1561-
repeat the pulse & cell IDs from the first 1/3 of each train, and add gain
1562-
stage labels from 0 (high-gain) to 2 (low-gain).
1563-
"""
1564-
_source_re = re.compile(r'(?P<detname>.+_LPD_MINI.*)/DET/(?P<modno>\d+)CH')
1565-
module_shape = (256, 256)
1566-
1567-
15681539
@multimod_detectors
15691540
class JUNGFRAU(MultimodDetectorBase):
15701541
"""An interface to JUNGFRAU data.

extra_data/tests/make_examples.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,6 @@ def make_fxe_run(dir_path, raw=True, format_version='0.5'):
242242
frames_per_train=128)
243243
], ntrains=480, chunksize=32, format_version=format_version)
244244

245-
path = osp.join(dir_path, f'{prefix}-R0450-LPDMINI00-S00000.h5')
246-
write_file(path, [
247-
LPDModule('FXE_DET_LPD_MINI/DET/0CH0', raw=raw, frames_per_train=128)
248-
], ntrains=480, chunksize=32, format_version=format_version)
249-
250245
if not raw:
251246
return
252247
write_file(osp.join(dir_path, 'RAW-R0450-DA01-S00000.h5'), [
@@ -273,10 +268,6 @@ def make_lpd_parallelgain_run(dir_path, raw=True, format_version='0.5'):
273268
frames_per_train=300)
274269
], ntrains=100, chunksize=32, format_version=format_version)
275270

276-
path = osp.join(dir_path, f'{prefix}-R0450-LPDMINI00-S00000.h5')
277-
write_file(path, [
278-
LPDModule('FXE_DET_LPD_MINI/DET/0CH0', raw=raw, frames_per_train=300)
279-
], ntrains=100, chunksize=32, format_version=format_version)
280271

281272
def make_lpd_run_mini_missed_train(dir_path):
282273
write_file(osp.join(dir_path, 'RAW-R0450-LPD00-S00000.h5'), [

extra_data/tests/test_components.py

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from extra_data.reader import RunDirectory, H5File, by_id, by_index
99
from extra_data.components import (
10-
AGIPD1M, DSSC1M, LPD1M, LPDMini, JUNGFRAU, identify_multimod_detectors,
10+
AGIPD1M, DSSC1M, LPD1M, JUNGFRAU, identify_multimod_detectors,
1111
)
1212

1313

@@ -179,17 +179,6 @@ def test_get_array_lpd_parallelgain(mock_lpd_parallelgain_run):
179179
np.testing.assert_array_equal(arr.coords['gain'], np.arange(3))
180180
np.testing.assert_array_equal(arr.coords['pulse'], np.arange(100))
181181

182-
run = RunDirectory(mock_lpd_parallelgain_run)
183-
det = LPDMini(run.select_trains(by_index[:2]), parallel_gain=True)
184-
assert det.detector_name == 'FXE_DET_LPD_MINI'
185-
186-
arr = det.get_array('image.data')
187-
assert arr.shape == (1, 2, 3, 100, 256, 256)
188-
assert arr.dims == ('module', 'train', 'gain', 'pulse', 'slow_scan', 'fast_scan')
189-
np.testing.assert_array_equal(arr.coords['gain'], np.arange(3))
190-
np.testing.assert_array_equal(arr.coords['pulse'], np.arange(100))
191-
192-
193182

194183
def test_get_array_lpd_parallelgain_select_pulses(mock_lpd_parallelgain_run):
195184
run = RunDirectory(mock_lpd_parallelgain_run)
@@ -206,20 +195,6 @@ def test_get_array_lpd_parallelgain_select_pulses(mock_lpd_parallelgain_run):
206195
assert arr.shape == (16, 2, 3, 5, 256, 256)
207196
np.testing.assert_array_equal(arr.coords['pulse'], np.arange(5))
208197

209-
run = RunDirectory(mock_lpd_parallelgain_run)
210-
det = LPDMini(run.select_trains(by_index[:2]), parallel_gain=True)
211-
assert det.detector_name == 'FXE_DET_LPD_MINI'
212-
213-
arr = det.get_array('image.data', pulses=np.s_[:5])
214-
assert arr.shape == (1, 2, 3, 5, 256, 256)
215-
assert arr.dims == ('module', 'train', 'gain', 'pulse', 'slow_scan', 'fast_scan')
216-
np.testing.assert_array_equal(arr.coords['gain'], np.arange(3))
217-
np.testing.assert_array_equal(arr.coords['pulse'], np.arange(5))
218-
219-
arr = det.get_array('image.data', pulses=by_id[:5])
220-
assert arr.shape == (1, 2, 3, 5, 256, 256)
221-
np.testing.assert_array_equal(arr.coords['pulse'], np.arange(5))
222-
223198

224199
def test_get_array_jungfrau(mock_jungfrau_run):
225200
run = RunDirectory(mock_jungfrau_run)
@@ -609,7 +584,7 @@ def test_write_selected_frames_proc(mock_spb_proc_run, tmp_path):
609584
test_file.unlink()
610585

611586
def test_identify_multimod_detectors(mock_fxe_raw_run):
612-
run = RunDirectory(mock_fxe_raw_run, include='*LPD[!MINI]*')
587+
run = RunDirectory(mock_fxe_raw_run)
613588
name, cls = identify_multimod_detectors(run, single=True)
614589
assert name == 'FXE_DET_LPD1M-1'
615590
assert cls is LPD1M

extra_data/tests/test_reader_mockdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def test_iterate_trains_require_all(mock_sa3_control_data):
161161

162162
def test_read_fxe_raw_run(mock_fxe_raw_run):
163163
run = RunDirectory(mock_fxe_raw_run)
164-
assert len(run.files) == 19 # 16 LPD 1M, 1 LPD Minimodules + 2 control data files
164+
assert len(run.files) == 18 # 16 LPD 1M + 2 control data files
165165
assert run.train_ids == list(range(10000, 10480))
166166
run.info() # Smoke test
167167

extra_data/tests/test_streamer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def test_merge_detector(mock_fxe_raw_run, mock_fxe_control_data, mock_spb_proc_run):
14-
with RunDirectory(mock_fxe_raw_run, include="*LPD[!MINI]*") as run:
14+
with RunDirectory(mock_fxe_raw_run) as run:
1515
for tid, data in _iter_trains(run, merge_detector=True):
1616
assert 'FXE_DET_LPD1M-1/DET/APPEND' in data
1717
assert 'FXE_DET_LPD1M-1/DET/0CH0:xtdf' not in data

0 commit comments

Comments
 (0)