CXIProtocol#
- class pyrost.CXIProtocol(datatypes, load_paths, kinds)#
CXI protocol class. Contains a CXI file tree path with the paths written to all the data attributes necessary for the
pyrost.STData
detector data container, their corresponding attributes’ data types, and data structure.- Parameters
datatypes (
Dict
[str
,str
]) – Dictionary with attributes’ datatypes. ‘float’, ‘int’, ‘uint’, or ‘bool’ are allowed.load_paths (
Dict
[str
,List
[str
]]) – Dictionary with attributes’ CXI default file paths.The attribute’s kind, that specifies data dimensionality. The following keywords are allowed:
scalar : Data is either 0D, 1D, or 2D. The data is saved and loaded plainly without any transforms or indexing.
sequence : A time sequence array. Data is either 1D, 2D, or 3D. The data is indexed, so the first dimension of the data array must be a time dimension. The data points for the given index are not transformed.
frame : Frame array. Data must be 2D, it may be transformed with any of
pyrost.Transform
objects. The data shape is identical to the detector pixel grid.stack : A time sequnce of frame arrays. The data must be 3D. It’s indexed in the same way as sequence attributes. Each frame array may be transformed with any of
pyrost.Transform
objects.
- cast(attr, array)#
Cast the attribute’s data to the right data type.
- contents()#
Return a list of the attributes stored in the container that are initialised.
- find_path(attr, cxi_file)#
Find attribute’s path in a CXI file cxi_file.
- get(attr, value=None)#
Retrieve a dataset, return
value
if the attribute is not found.
- get_dtype(attr, dtype=None)#
Return the attribute’s data type. Return
dtype
if the attribute’s data type is not found.
- get_kind(attr, value='scalar')#
Return the attribute’s kind, that specifies data dimensionality. Return
value
if the attribute is not found.- Parameters
- Return type
- Returns
The attribute’s kind, that specifies data dimensionality. The following keywords are allowed:
scalar : Data is either 0D, 1D, or 2D. The data is saved and loaded plainly without any transforms or indexing.
sequence : A time sequence array. Data is either 1D, 2D, or 3D. The data is indexed, so the first dimension of the data array must be a time dimension. The data points for the given index are not transformed.
frame : Frame array. Data must be 2D, it may be transformed with any of
pyrost.Transform
objects. The data shape is identical to the detector pixel grid.stack : A time sequnce of frame arrays. The data must be 3D. It’s indexed in the same way as sequence attributes. Each frame array may be transformed with any of
pyrost.Transform
objects.
- get_load_paths(attr, value=None)#
Return the attribute’s default path in the CXI file. Return
value
ifattr
is not found.
- get_ndim(attr, value=0)#
Return the acceptable number of dimensions that the attribute’s data may have.
- classmethod import_default()#
Return the default
CXIProtocol
object.- Return type
- Returns
A
CXIProtocol
object with the default parameters.
- classmethod import_ini(ini_file)#
Initialize the container object with an INI file
ini_file
.
- items()#
Return (key, value) pairs of the datasets stored in the container.
- Return type
- Returns
(key, value) pairs of the datasets stored in the container.
- keys()#
Return a list of the attributes available in the container.
- read_attribute_indices(attr, cxi_files)#
Return a set of indices of the dataset containing the attribute’s data inside a set of files.
- read_attribute_shapes(attr, cxi_file)#
Return a shape of the dataset containing the attribute’s data inside a file.
- static read_dataset_shapes(cxi_path, cxi_file)#
Visit recursively all the underlying datasets and return their names and shapes.
- replace(**kwargs)#
Return a new container object with a set of attributes replaced.
- static str_to_list(strings)#
Convert strings to a list of strings.
- to_ini(ini_file)#
Save all the attributes stored in the container to an INI file
ini_file
.- Parameters
ini_file (
str
) – Path to the ini file.
- values()#
Return the attributes’ data stored in the container.
- Return type
- Returns
List of data stored in the container.