pyiron_base.utils.parser.Logstatus#
- class pyiron_base.utils.parser.Logstatus(h5: Any | None = None, iter_levels: int = 1)[source]#
Bases:
objectGeneric Parser for parsing output files by searching for a specific pattern structure and extracting the data that follows the pattern into the status_dict dictionary.
- Parameters:
iter_levels (int) – Levels of iteration - default = 1
- __init__(h5: Any | None = None, iter_levels: int = 1) None[source]#
Initialize the Logstatus object.
- Parameters:
h5 (Optional[Any]) – HDF5 object to store the dictionary in. Defaults to None.
iter_levels (int) – Levels of iteration. Defaults to 1.
Methods
__init__([h5, iter_levels])Initialize the Logstatus object.
append(title, data_to_append[, vec])Append data to the LogStatus object status_dict dictionary
combine_mat(x_key, xy_key, xz_key, y_key, ...)Combine three lists representing the x,y,z coordinates, by accessing them from the status_dict dictionary, combining them, store them under the combined_key and remove the other three keys.
combine_xyz(x_key, y_key, z_key, combined_key)Combine three lists representing the x,y,z coordinates, by accessing them from the status_dict dictionary, combining them, store them under the combined_key and remove the other three keys.
convert_unit(key, factor)Convert the values of a specific key in the status_dict dictionary by multiplying them with a factor.
extract_file(file_name, tag_dict[, h5_dict, ...])Main function of the LogStatus class to extract data from an output file by searching for the tag dictionary
extract_from_list(list_of_lines, tag_dict[, ...])Main function of the LogStatus class to extract data from an output file by searching for the tag dictionary
extract_item(l_item)Method to extract information from a single line - currently very specific for the Lammps output
raise_iter([dim])Increase the iteration level
reset_iter([dim])Reset iteration level
to_hdf(hdf)Store the LogStatus object status_dict dictionary in an HDF5 file
- append(title: str, data_to_append: list | dict, vec: bool = False) None[source]#
Append data to the LogStatus object status_dict dictionary
- Parameters:
title (str) – Title of the data to append
data_to_append (Union[list, dict]) – the data can be of various types
vec (bool) – [True/False] if the data is a single vector instead of a matrix or a tensor
- combine_mat(x_key: str, xy_key: str, xz_key: str, y_key: str, yz_key: str, z_key: str, combined_key: str) None[source]#
Combine three lists representing the x,y,z coordinates, by accessing them from the status_dict dictionary, combining them, store them under the combined_key and remove the other three keys.
- Parameters:
x_key (str) – key of the x coordinates
xy_key (str) – key of the xy coordinates
xz_key (str) – key of the xz coordinates
y_key (str) – key of the y coordinates
yz_key (str) – key of the yz coordinates
z_key (str) – key of the z coordinates
combined_key (str) – name of the combined coordinates
- combine_xyz(x_key: str, y_key: str, z_key: str, combined_key: str, as_vector: bool = False) None[source]#
Combine three lists representing the x,y,z coordinates, by accessing them from the status_dict dictionary, combining them, store them under the combined_key and remove the other three keys.
- Parameters:
x_key (str) – key of the x coordinates
y_key (str) – key of the y coordinates
z_key (str) – key of the z coordinates
combined_key (str) – name of the combined coordinates
as_vector (bool) – [True/False] if the combined coordinates should be stored as a single vector instead of a matrix. Defaults to False.
- convert_unit(key: str, factor: float) None[source]#
Convert the values of a specific key in the status_dict dictionary by multiplying them with a factor.
- Parameters:
key (str) – The key of the values to be converted.
factor (float) – The factor to multiply the values with.
- extract_file(file_name: str, tag_dict: Dict[str, Any], h5_dict: Dict[str, str] | None = None, key_dict: Dict[str, str] | None = None) None[source]#
Main function of the LogStatus class to extract data from an output file by searching for the tag dictionary
- Parameters:
file_name (str) – absolute path to the output file
tag_dict (dict) – Dictionary with tags/patterns as key and an additional dictionary to describe the data structure. The data structure dictionary can contain the following keys: - “arg”: position of the argument - or dimension (“:”, “:,:”) - “type”: Python data type - “h5”: HDF5 key to store the information - “rows”: number of rows from the line where the tag was found - “splitTag”: split the tag - [True/False] - “splitArg”: split the argument - [True/False] - “lineSkip”: skip a line - “func”: function to convert the data
h5_dict (dict) – Translation dictionary of output tags as keys to the tags used on the HDF5 file as values.
key_dict (dict) – Translation dictionary of python internal tags as keys to the output tags as values.
- extract_from_list(list_of_lines: List[str], tag_dict: Dict[str, Any], h5_dict: Dict[str, str] | None = None, key_dict: Dict[str, str] | None = None) None[source]#
Main function of the LogStatus class to extract data from an output file by searching for the tag dictionary
- Parameters:
list_of_lines (List[str]) – List of lines from the output file
tag_dict (Dict[str, Any]) – Dictionary with tags/patterns as key and an additional dictionary to describe the data structure.
h5_dict (Optional[Dict[str, str]]) – Translation dictionary of output tags as keys to the tags used on the HDF5 file as values. Defaults to None.
key_dict (Optional[Dict[str, str]]) – Translation dictionary of python internal tags as keys to the output tags as values. Defaults to None.
- static extract_item(l_item: str) Tuple[str, List[str] | None][source]#
Method to extract information from a single line - currently very specific for the Lammps output
- Parameters:
l_item (str) – line to extract information from
- Returns:
the tag_string as string and the arguments as list
- Return type:
Tuple[str, Optional[List[str]]]
- raise_iter(dim: int = 0) None[source]#
Increase the iteration level
- Parameters:
dim (int) – position - default = 0
- reset_iter(dim: int = 0) None[source]#
Reset iteration level
- Parameters:
dim (int) – reset value - default = 0
- to_hdf(hdf: ProjectHDFio) None[source]#
Store the LogStatus object status_dict dictionary in an HDF5 file
- Parameters:
hdf (ProjectHDFio) – HDF5 object to store the dictionary in.