European-XFEL / karabo_data

Python tools to read and analyse data from European XFEL
https://karabo-data.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
13 stars 7 forks source link

reading train ids #77

Open hjkirkwood opened 6 years ago

hjkirkwood commented 6 years ago

When I request the train id's associated with a certain detector using karabo_data.Rundirectory, I see repeating trainIds and they increase by increments of ~4, but when I look at them with h5py they are unique (mostly) and ascending. Example:

hf = h5py.File('/pnfs/xfel.eu/exfel/archive/XFEL/raw/SPB/201701/p002046/r0082/RAW-R0082-DA03-S00000.h5','r')
print(hf.get('INSTRUMENT/SPB_EHC_PAM/CAM/SPEC12:daqOutput/data/trainId')[:][:10])

This returns:

[128462809 128462812 128462813 128462818 128462819 128462820 128462822
 128462824 128462825 128462827]

But using karabo_data:

topdir = '/pnfs/xfel.eu/exfel/archive/XFEL/raw/SPB/201701/p002046'
device = 'SPB_EHC_PAM/CAM/SPEC12:daqOutput'
# generater for run directory
run_pattern = lambda nRun: topdir + '/r{:04d}'.format(int(nRun))

run_sig = RunDirectory(run_pattern(82))
sig_trainIds = run_sig.get_array(device,'data.trainId')
print(sig_trainIds[:10])

I get:

array([128462808, 128462816, 128462816, 128462816, 128462816, 128462816,
       128462824, 128462824, 128462824, 128462824])
takluyver commented 6 years ago

That's bizarre. I can't reproduce this with either 0.1 (the version on PyPI) or master. In both cases the result looks correct:

<xarray.DataArray (trainId: 10)>
array([128462809, 128462812, 128462813, 128462818, 128462819, 128462820,
       128462822, 128462824, 128462825, 128462827], dtype=uint64)
Coordinates:
  * trainId  (trainId) uint64 128462809 128462812 128462813 128462818 ...

Do you know where the karabo_data version you're using came from? I also see that it seems to be returning a plain numpy array, whereas get_array() usually returns a labelled xarray object.

takluyver commented 6 years ago

I spoke to @hjkirkwood about this yesterday, and we couldn't quickly reproduce it. So nothing to do at the moment, but he'll let us know if he runs into this kind of problem again.