KamzikConverter#

class pyrost.KamzikConverter(protocol=<factory>, fs_vec=array([-5.5e-05, 0.0e+00, 0.0e+00]), ss_vec=array([ 0.0e+00, -5.5e-05, 0.0e+00]), idxs=None, log_attr=<factory>, log_data=<factory>)#

A converter class, that generates CXI datasets aceeptable by pyrost.STData from Kamzik log files.

Parameters
  • protocol (LogProtocol) – Log file protocol.

  • fs_vec (ndarray) – Fast (horizontal) scan detector axis.

  • ss_vec (ndarray) – Slow (vertical) scan detector axis.

  • idxs (Optional[ndarray]) – Frame indices read from a log file.

  • log_attr (Optional[Dict[str, Any]]) – Dictionary of log attributes read from a log file.

  • log_data (Optional[Dict[str, Any]]) – Dictionary of log datasets read from a log file.

contents()#

Return a list of the attributes stored in the container that are initialised.

Return type

List[str]

Returns

List of the attributes stored in the container.

cxi_get(attrs)#

Convert Kamzik log files data into CXI attributes, that are accepted by pyrost.STData container. To see full list of available CXI attributes, use KamzikConverter.cxi_keys().

Parameters

attrs (Union[str, List[str]]) – List of CXI attributes to generate. The method will raise an error if any of the attributes is unavailable.

Raises

ValueError – If any of attributes in attrs in unavailable.

Return type

Dict[str, Any]

Returns

A dictionary of CXI attributes, that are accepted by pyrost.STData container.

cxi_keys()#

Return a list of available CXI attributes.

Return type

List[str]

Returns

List of available CXI attributes.

find_log_attribute(attr, part_key=None)#

Find a value in the log attributes corresponding to an attribute name attr.

Parameters
  • attr (str) – A name of the attribute to find.

  • part_key (Optional[str]) – Search in the given part of the log dictionary if provided.

Return type

Optional[Any]

Returns

Value of the log attribute. Returns None if nothing is found.

find_log_dataset(attr)#

Find a dataset in the log data corresponding to an attribute name attr.

Parameters

attr (str) – A name of the attribute to find.

Return type

Optional[ndarray]

Returns

Dataset for the given attribute. Returns None if nothing is found.

find_log_part_key(attr)#

Find a name of the log dictionary corresponding to an attribute name attr.

Parameters

attr (str) – A name of the attribute to find.

Return type

Optional[str]

Returns

A name of the log dictionary, corresponding to the given attribute name attr.

get(attr, value=None)#

Retrieve a dataset, return value if the attribute is not found.

Parameters
  • attr (str) – Data attribute.

  • value (Optional[Any]) – Data which is returned if the attribute is not found.

Return type

Any

Returns

Attribute’s data stored in the container, value if attr is not found.

items()#

Return (key, value) pairs of the datasets stored in the container.

Return type

ItemsView

Returns

(key, value) pairs of the datasets stored in the container.

keys()#

Return a list of the attributes available in the container.

Return type

List[str]

Returns

List of the attributes available in the container.

read_logs(log_path, idxs=None)#

Read a log file under the path log_path. Read out only the frame indices defined by idxs. If idxs is None, read the whole log file.

Parameters
  • log_path (str) – Path to the log file.

  • idxs (Optional[Iterable[int]]) – List of indices to read. Read the whole log file if None.

Return type

~K

Returns

A new log container with log_attr, log_data, and idxs updated.

replace(**kwargs)#

Return a new container object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~D

Returns

A new container object with updated attributes.

values()#

Return the attributes’ data stored in the container.

Return type

ValuesView

Returns

List of data stored in the container.