Pymepix Postprocessing¶
Raw data acquired from the camera can be processed using the command line or triggered from the PymepixViewer.
To process from the command line:
pymepix post-process -f FILE -o OUTPUT_FILE [-t TIMEWALK_FILE] [-c CENT_TIMEWALK_FILE] [-n NUMBER_OF_PROCESSES]
The output is an HDF5 file containing the following possible datagroups:
centroided: Contains centroided data with datasets: “trigger nr”, “x”, “y”, “tof”, “tot avg”, “tot max”, and “clustersize”.
trigger nr: Event number
x/y: Centroid coordinates
tof: Time-of-flight (time-of-arrival corrected for timewalk)
tot avg: Average TOT across cluster voxels
tot max: Maximum TOT
clustersize: Number of voxels in the cluster
raw: Event voxel data synchronized to the first trigger with datasets: “trigger nr”, “x”, “y”, “tof”, and “tot”.
timing/timepix: Contains “trigger nr”, “timestamp”, and “event trigger” datasets:
timestamp: Nanosecond resolution timestamps from the camera timer
event trigger: Trigger time in seconds since acquisition start
trigger nr: True trigger number as an unsigned integer. If a trigger doesn’t contain any events, the “trigger nr” is still increased by one.
triggers: May contain “trigger1” and “trigger2” subgroups, each with a “time” dataset. The number should correspond to “timing/timepix/event trigger” and can be used to align the two datasets. Rising edges carry a positive sign whereas the falling edges are denoted with a negative sign:
trigger1: Camera times for rising and falling edges for TDC1 in the camera time.
trigger2: Camera times for rising and falling edges for TDC2 in the camera time.
HDF5 file structure example:
<HDF5 file "ion_2595_20240130-1443.hdf5" (mode r)>
├── centroided
│ ├── clustersize
│ ├── tof
│ ├── tot avg
│ ├── tot max
│ ├── trigger nr
│ ├── x
│ └── y
├── raw
│ ├── tof
│ ├── tot
│ ├── trigger nr
│ ├── x
│ └── y
├── timing
│ └── timepix
│ ├── event trigger
│ ├── timestamp
│ └── trigger nr
└── triggers
├── trigger1
│ └── time
└── trigger2
└── time
To retrieve data from the HDF5 file into a Pandas DataFrame:
1import pathlib
2import pandas as pd
3import numpy as np
4import h5py
5
6def get_tpx_data(fname: pathlib.PosixPath) -> pd.DataFrame:
7 '''Retrieve Timepix data from HDF5 file'''
8 try:
9 with h5py.File(fname, "r") as f:
10 raw_data = pd.DataFrame(
11 np.column_stack((
12 f["raw/trigger nr"][:],
13 f["raw/tof"][:] * 1e6,
14 f["raw/tot"][:],
15 f["raw/x"][:],
16 f["raw/y"][:],
17 )),
18 columns=("nr", "tof", "tot", "x", "y"),
19 )
20
21 cent_data = pd.DataFrame(
22 np.column_stack((
23 f["centroided/trigger nr"][:],
24 f["centroided/tof"][:] * 1e6,
25 f["centroided/tot max"][:],
26 f["centroided/x"][:],
27 f["centroided/y"][:],
28 f['centroided/clustersize'][:]
29 )),
30 columns=("nr", "tof", "tot", "x", "y", "size"),
31 )
32
33 return raw_data, cent_data
34 except:
35 print(f'Error: Could not read data from "{fname}"')