LogProtocol#

class pyrost.LogProtocol(datatypes, log_keys, part_keys)#

Log file protocol class. Contains log file keys to retrieve and the data types of the corresponding values.

Parameters
  • datatypes (Dict[str, str]) – Dictionary with attributes’ datatypes. ‘float’, ‘int’, ‘bool’, or ‘str’ are allowed.

  • log_keys (Dict[str, List[str]]) – Dictionary with attributes’ log file keys.

  • part_keys (Dict[str, str]) – Dictionary with the part names inside the log file where the attributes are stored.

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.

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.

classmethod import_default()#

Return the default LogProtocol object.

Return type

LogProtocol

Returns

A LogProtocol object with the default parameters.

classmethod import_ini(ini_file)#

Initialize the container object with an INI file ini_file.

Parameters

ini_file (str) – Path to the ini file.

Return type

~I

Returns

A new container with all the attributes imported from the ini file.

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.

load_attributes(path)#

Return attributes’ values from a log file at the given path.

Parameters

path (str) – Path to the log file.

Return type

Dict[str, Dict[str, Any]]

Returns

Dictionary with the attributes retrieved from the log file.

load_data(path, idxs=None, return_idxs=False)#

Retrieve the main data array from the log file.

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

  • idxs (Optional[Iterable[int]]) – Array of data indices to load. Loads info for all the frames by default.

  • return_idxs – Return an array of indices of the scan steps read from the log file if True.

Returns

  • Dictionary with data fields and their names retrieved from the log file.

  • An array of indices of the scan steps read from the log file.

Return type

A tuple of two elements

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.

static str_to_list(strings)#

Convert strings to a list of strings.

Parameters

strings (Union[str, List[str]]) – String or a list of strings

Return type

List[str]

Returns

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

ValuesView

Returns

List of data stored in the container.