datasets module
Reader class for HDF5 files from BLISS.
- class datasets.BlissDataset(fname, detector='auto', counters=None)[source]
Class to handle ‘datasets’ created by BLISS.
This is intended to handle simultaneously the HDF5 file in a ‘Dataset’ folder and the associated HDF5 files of the corresponding scans.
Metadata are gathered mainly from the dataset HDF5 file, while images are loaded directly from the scans HDF5 files.
- Parameters:
fname (str) – Name of the HDF5 file corresponding to the dataset.
detector (str) – The name of the detector in the HDF5 file.
counters ('all', list of str or None, optional) – Additional counters to be read along with the images.
- classmethod from_scan_folder(folder, detector='auto', counters=None)[source]
Returns a BlissDataset instance and an iterator on the scan.
- Parameters:
folder (str) – The folder containing the data of the BLISS scan.
detector (str, optional) – The detector to be used. (default, ‘auto’)
counters (list of str) – Additional counters to be read with the images.
- metadata(scan_number=1, subscan=1)[source]
Return useful metadata for data reduction and analysis.
If multiple files are present, the idx argument allows access to the corresponding file metadata (default is 0).
- Parameters:
scan_number (str or int) – If string, should be in the format “<scan>.<subscan>”.
subscan (int) – Used only if scan_number is an integer.
- class datasets.ImageIteratorEDF(fnames, verbose=True)[source]
Class to handle the loading of EDF images and metadata from the SPEC macro ‘waxscollect’.
The class provides iterator and slicing capabilities to access images.
- Parameters:
fnames (list) – List of EDF filenames.
- class datasets.ImageIteratorHDF5(folder, scan='', detector='rayonix', counters=None, exclude=None, dataset_file=None, verbose=False)[source]
A class to handle HDF5 files corresponding to a single BLISS scan.
This does not provide live monitoring yet (retry from silx for instance). That is, if a file is still being written by BLISS, the images and c unters will not be available and the iterator will stop at the frame of the last closed file. #20221120
However, the list of available images is updated each time the iterator is called or each time a slice is requested such that the class does not need to be re-instanciated.
- datasets.get_info_from_id09_log_file(lines)[source]
Get parameters values from ID09 log file comment section.
Paramters
- lineslist
List of comment lines extracted with readlines.
- returns:
pars – Retrieved parameters (info).
- rtype:
dict
- datasets.load_EDF_images(folder, exclude=None, verbose=True)[source]
Load EDF images in folder.
- Parameters:
folder (str) – Folder where images are located.
exclude (list or None, optional) – List of filenames (basenames) that will not be loaded. Default is None.
- Returns:
imgs – Images as returned as a list of numpy arrays.
- Return type:
list
- datasets.load_images(folder, extension='h5', exclude=None, return_fnames=False, verbose=True)[source]
Load images in folder.
- Parameters:
folder (str) – Folder where images are located.
extension (str, optional) – File extension of images. Default is ‘edf’.
exclude (list or None, optional) – List of filenames (basenames) that will not be loaded. Default is None.
return_fnames (bool, optional) – If True, a list of images filenames (basenames) is also returned. Default is False.
- Returns:
imgs – Images as returned as a list of numpy arrays.
- Return type:
list
- datasets.read_id09_log_file(fname, skip=None, format='auto', out_format='datastorage', get_info=False)[source]
Read ID09 log file associated to a tr-waxs dataset.
- Parameters:
fname (str) – Name of log file or folder. If ‘fname’ is a folder, the file name will be guessed automatically.
skip (int or tuple or None, optional) – First/last lines to be skipped. Default is None.
format (str {'waxscollect', 'bliss', 'auto'}, optional) – Log file format. Default is ‘waxscollect’.
out_format (str, optional) – Can be ‘ndarray’, ‘dict’ or ‘datastorage’. Default is ‘datastorage’.
get_info (boot, optional) – If True, extra info (parameters value) is also returned. Default is False.
- Returns:
data (ndarray or dict or DataStorage) – Retrieved data from id09 log file. Use ‘out_format’ to choose between np.genfromtxt() ndarray or dict.
info (dict) – Retrieved info from id09 log file comment section. Returned only if ‘get_info’ is True.