Read data from an EDF acquisition#
To create a ‘Scan’ object from EDF you have to use the :class:EDFTomoScan
class and provide the path to the acquisition
WARNING: Browsing EDF files is based on several convention at ESRF. The most important one is that the acquisition ‘identification’ - which is the folder name is repeated in the file names. For example if we have an acquisition names ‘acq_0005’ we expect edf file prefix to be ‘acq_0005’ too.
WARNING: The :class:EDFTomoScan
has been tested on EDF single frame files. It wouldn’t be surprising if it fails on EDF multiple frames files.
[1]:
# %pylab # to use imshow uncomment
Using matplotlib backend: Qt5Agg
Populating the interactive namespace from numpy and matplotlib
Get a simple dataset for test (this dataset is a pure noise)#
[2]:
from tomoscan.tests.datasets import GitlabDataset
import os
data_dir = GitlabDataset.get_dataset("edf_datasets/test10")
create an instance of EDFTomoScan
#
EDFTomoScan
implements the TomoScanBase interface. This allow you to have a common API for accessing data from EDF or HDF5 regardless of the type of acquisition.
[3]:
from tomoscan.esrf.scan.edfscan import EDFTomoScan
scan = EDFTomoScan(scan=data_dir)
Then from it you can access several information
projections#
[4]:
scan.projections
[4]:
{3: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100003.edf', data_path=None, data_slice=[0]),
27: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100027.edf', data_path=None, data_slice=[0]),
0: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100000.edf', data_path=None, data_slice=[0]),
31: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100031.edf', data_path=None, data_slice=[0]),
20: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100020.edf', data_path=None, data_slice=[0]),
25: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100025.edf', data_path=None, data_slice=[0]),
7: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100007.edf', data_path=None, data_slice=[0]),
19: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100019.edf', data_path=None, data_slice=[0]),
8: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100008.edf', data_path=None, data_slice=[0]),
5: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100005.edf', data_path=None, data_slice=[0]),
4: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100004.edf', data_path=None, data_slice=[0]),
22: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100022.edf', data_path=None, data_slice=[0]),
26: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100026.edf', data_path=None, data_slice=[0]),
32: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100032.edf', data_path=None, data_slice=[0]),
14: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100014.edf', data_path=None, data_slice=[0]),
18: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100018.edf', data_path=None, data_slice=[0]),
30: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100030.edf', data_path=None, data_slice=[0]),
2: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100002.edf', data_path=None, data_slice=[0]),
16: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100016.edf', data_path=None, data_slice=[0]),
15: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100015.edf', data_path=None, data_slice=[0]),
23: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100023.edf', data_path=None, data_slice=[0]),
11: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100011.edf', data_path=None, data_slice=[0]),
13: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100013.edf', data_path=None, data_slice=[0]),
1: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100001.edf', data_path=None, data_slice=[0]),
17: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100017.edf', data_path=None, data_slice=[0]),
24: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100024.edf', data_path=None, data_slice=[0]),
12: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100012.edf', data_path=None, data_slice=[0]),
9: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100009.edf', data_path=None, data_slice=[0]),
29: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100029.edf', data_path=None, data_slice=[0]),
21: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100021.edf', data_path=None, data_slice=[0]),
28: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100028.edf', data_path=None, data_slice=[0]),
10: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100010.edf', data_path=None, data_slice=[0]),
6: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/test100006.edf', data_path=None, data_slice=[0])}
This return a dictionary of projection index and DataUrl. You can access the data using silx.io.utils.get_data function
[5]:
from silx.io.utils import get_data
frame_18_data = get_data(scan.projections[18])
# imshow(frame_28_data)
[5]:
<matplotlib.image.AxesImage at 0x7f5ce5bbcc88>
flats#
[7]:
scan.flats
[7]:
{20: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/refHST0020.edf', data_path=None, data_slice=[0]),
10: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/refHST0010.edf', data_path=None, data_slice=[0]),
0: DataUrl(valid=True, scheme='fabio', file_path='/home/payno/dev/tomo/tomoscan/tomoscan/test/test10/refHST0000.edf', data_path=None, data_slice=[0])}
pixel size (in )#
[9]:
scan.get_pixel_size(unit='cm')
[9]:
0.00030199999999999997
There is more information that you can access, to get them all please have a look on the TomwerScanBase API and EDFTomoScan API.