The Large Pixel Detector (LPD) is made of 16 modules which record data separately.
karabo_data
includes convenient interfaces to access this data together.
This example stands by itself, but if you need more generic access to the data, please see Reading data with karabo_data.
First, let's load a run containing LPD data:
In [1]:
from karabo_data import RunDirectory, by_index
run = RunDirectory('fxe_example_run/')
# Using only the first three trains to keep this example light:
run = run.select_trains(by_index[:3])
run.instrument_sources
Out[1]:
Normal access methods give us each module separately:
In [2]:
data_module0 = run.get_array('FXE_DET_LPD1M-1/DET/0CH0:xtdf', 'image.data')
data_module0.shape
Out[2]:
The class karabo_data.components.LPD1M
can piece these together:
In [3]:
from karabo_data.components import LPD1M
lpd = LPD1M(run)
lpd
Out[3]:
In [4]:
image_data = lpd.get_array('image.data')
print("Data shape:", image_data.shape)
print("Dimensions:", image_data.dims)
Note: This class pulls the data together, but it doesn't know how the modules are physically arranged, so it can't produce a detector image. Other examples show how to use detector geometry to produce images.
You can also select only certain modules of the detector. For example, modules 2 (Q1M3), 7 (Q2M4), 8 (Q3M1) and 13 (Q4M2) are the four modules around the center of the detector:
In [5]:
lpd = LPD1M(run, modules=[2, 7, 8, 13])
image_data = lpd.get_array('image.data')
print("Data shape:", image_data.shape)
print("Dimensions:", image_data.dims)
print()
print("Data for one pulse:")
print(image_data.sel(train=10000, pulse=0))
The returned array is an xarray object with labelled axes. See Indexing and selecting data in the xarray docs for more on what you can do with it.
This interface also supports iterating train-by-train through detector data, giving labelled arrays again:
In [6]:
for tid, train_data in lpd.trains(pulses=by_index[:16]):
print("Train", tid)
print("Keys in data:", sorted(train_data.keys()))
print("Image data shape:", train_data['image.data'].shape)
print()