Protocol¶
-
class
pyrost.Protocol(datatypes=None, default_paths=None, float_precision='float64')¶ CXI protocol class. Contains a CXI file tree path with the paths written to all the data attributes necessary for the Speckle Tracking algorithm, corresponding attributes’ data types, and floating point precision.
- Parameters
- Variables
See also
protocolFull list of data attributes and configuration parameters.
-
export_dict()¶ Return a
dictobject with all the attributes.- Returns
Dictionary with all the attributes conntained in the object.
- Return type
-
classmethod
export_ini(**kwargs)¶ Return a
configparser.ConfigParserobject with all the attributes exported the class.- Parameters
**kwargs (dict) – Extra parameters to export to the
configparser.ConfigParserobject.- Returns
A parser object with all the attributes contained in attr_dict.
- Return type
-
get_default_path(attr, value=None)¶ Return the atrribute’s default path in the CXI file. Return value if attr is not found.
-
get_dtype(attr, value=None)¶ Return the attribute’s data type. Return value if attr is not found.
-
parser_from_template(path)¶ Return a
configparser.ConfigParserobject using an ini file template.- Parameters
path (str) – Path to the ini file template.
- Returns
Parser object with the attributes populated according to the protocol.
- Return type
-
read_cxi(attr, cxi_file, cxi_path=None, dtype=None)¶ Read attr from the CXI file cxi_file at the path defined by the protocol. If cxi_path or dtype argument are provided, it will override the protocol.
- Parameters
attr (str) – Data attribute.
cxi_file (h5py.File) – h5py File object of the CXI file.
cxi_path (str, optional) – Path to the data attribute. If cxi_path is None, the path will be inferred according to the protocol.
dtype (type, optional) – Data type of the attribute. If dtype is None, the type will be inferred according to the protocol.
- Returns
The value of the attribute extracted from the CXI file.
- Return type
-
write_cxi(attr, data, cxi_file, overwrite=True, cxi_path=None, dtype=None)¶ Write data to the CXI file cxi_file under the path specified by the protocol. If cxi_path or dtype argument are provided, it will override the protocol.
- Parameters
attr (str) – Data attribute.
data (numpy.ndarray) – Data which is bound to be saved.
overwrite (bool, optional) – Overwrite the content of cxi_file if it’s True.
cxi_path (str, optional) – Path to the data attribute. If cxi_path is None, the path will be inferred according to the protocol.
dtype (type, optional) – Data type of the attribute. If dtype is None, the type will be inferred according to the protocol.
- Raises
ValueError – If overwrite is False and the data is already present at the given location in cxi_file.