CXIStore#
- class cbclib.CXIStore(names, mode='r', protocol=CXIProtocol(datatypes={'background': 'float', 'cor_data': 'float', 'data': 'uint', 'frames': 'uint', 'mask': 'bool', 'streak_data': 'float', 'tilts': 'float', 'translations': 'float', 'wavelength': 'float', 'whitefield': 'float', 'x_pixel_size': 'float', 'y_pixel_size': 'float'}, load_paths={'background': ['/entry/crystallography/background'], 'cor_data': ['/entry/data/cor_data'], 'data': ['/entry/data/data', '/entry_1/data/data', '/entry_1/data_1/data', '/data/data', '/entry_1/instrument_1/detector_1/data'], 'frames': ['/entry/crystallography/frames', '/frame_selector/frames', '/process_3/frames'], 'mask': ['/entry/instrument/detector/mask', '/entry_1/instrument_1/detector_1/mask', '/entry_1/instrument/detector/mask'], 'tilts': ['/entry/crystallography/tilts'], 'translations': ['/entry/crystallography/translations'], 'streak_data': ['/entry/crystallography/streak_data'], 'wavelength': ['/entry/instrument/beam/wavelength', '/entry/instrument/beam/incident_wavelength', '/entry_1/instrument_1/beam/wavelength'], 'whitefield': ['/entry/crystallography/whitefield'], 'x_pixel_size': ['/entry/instrument/detector/x_pixel_size'], 'y_pixel_size': ['/entry/instrument/detector/y_pixel_size']}, kinds={'background': 'stack', 'cor_data': 'stack', 'data': 'stack', 'frames': 'sequence', 'mask': 'stack', 'streak_data': 'stack', 'tilts': 'sequence', 'translations': 'sequence', 'wavelength': 'scalar', 'whitefield': 'frame', 'x_pixel_size': 'scalar', 'y_pixel_size': 'scalar'}))[source]#
File handler class for HDF5 and CXI files. Provides an interface to save and load data attributes to a file. Support multiple files. The handler saves data to the first file.
- Parameters
- file_dict#
Dictionary of paths to the files and their file objects.
- protocol#
cbclib.CXIProtocolprotocol object.
- mode#
File mode. Valid modes are:
‘r’ : Readonly, file must exist (default).
‘r+’ : Read/write, file must exist.
‘w’ : Create file, truncate if exists.
‘w-’ or ‘x’ : Create file, fail if exists.
‘a’ : Read/write if exists, create otherwise.
- files()[source]#
Return a list of file objects of the files.
- Return type
List[File]- Returns
List of file objects of the files.
- find_dataset(attr)[source]#
Return the path to the attribute from the first file. Return the default path if the attribute is not found inside the first file.
- indices()[source]#
Return a list of frame indices of the data contained in the files.
- Return type
- Returns
A list of frame indices of the data in the files.
- items()[source]#
Return a set of
(name, index)pairs.nameis the attribute’s name contained in the files, andindexit’s corresponding set of indices.- Return type
- Returns
A set of
(name, index)pairs of the data attributes in the files.
- keys()[source]#
Return a set of the attribute’s names contained in the files.
- Return type
- Returns
A set of the attribute’s names in the files.
- load_attribute(attr, idxs=None, processes=1, ss_idxs=slice(None, None, None), fs_idxs=slice(None, None, None), verbose=True)[source]#
Load a data attribute from the files.
- Parameters
- Raises
ValueError – If the attribute’s kind is invalid.
RuntimeError – If the files are not opened.
- Return type
- Returns
Attribute’s data array.
- read_shape()[source]#
Read the input files and return a shape of the frame type data attribute.
- Raises
RuntimeError – If the files are not opened.
- Return type
- Returns
The shape of the 2D frame-like data attribute.
- save_attribute(attr, data, mode='overwrite', idxs=None)[source]#
Save a data array pertained to the data attribute into the first file.
- Parameters
attr (
str) – Attribute’s name.data (
ndarray) – Data array.mode (
str) –Writing mode:
append : Append the data array to already existing dataset.
insert : Insert the data under the given indices
idxs.overwrite : Overwrite the existing dataset.
idxs (
Union[int,slice,ndarray,List[int],Tuple[int],None]) – Indices where the data is saved. Used only ifmodeis set to ‘insert’.
- Raises
ValueError – If the attribute’s kind is invalid.
ValueError – If the file is opened in read-only mode.
RuntimeError – If the file is not opened.
- Return type
- update_indices()[source]#
Read the files for the data attributes contained in the protocol.
- Return type