ogstools.logparser package#
functions used by logparser.
- ogstools.logparser.parse_file(file_name, maximum_lines=None, force_parallel=False, ogs_res=None)[source]#
Parses a log file from OGS, applying regex patterns to extract specific information,
The function supports processing files in serial or parallel mode. In parallel mode, a specific regex is used to match log entries from different processes.
- Parameters:
file_name (str | Path) – The path to the log file, as a string or Path object.
maximum_lines (int | None) – Optional maximum number of lines to read from the file. If not provided, the whole file is read.
force_parallel (bool) – Should only be set to True if OGS run with MPI with a single core
- Returns:
A list of extracted records based on the applied regex patterns. The exact type and structure of these records depend on the regex patterns and their associated processing functions.
- Return type:
list[Any]
- ogstools.logparser.analysis_convergence_newton_iteration(df)[source]#
Convergence metrics need to be interpreted as norm |x|,`|dx|`, |dx|/|x| and are specific to defined <convergence_criterion> in prj - file.
- Return type:
DataFrame
- ogstools.logparser.analysis_time_step(df)[source]#
Analysis with focus on computation time per time step. It combines time step specific measurements ‘output time’ and ‘time step solution time’ with iteration specific measurements ‘assembly time’, ‘linear solver time’, ‘Dirichlet time’. Time from iteration are accumulated.
- Return type:
DataFrame
- ogstools.logparser.fill_ogs_context(df_raw_log)[source]#
Fill missing values in OpenGeoSys (OGS) log DataFrame by context. This function fills missing values in an OpenGeoSys (OGS) log DataFrame by context.
- Parameters:
df_raw_log (DataFrame) – DataFrame containing the raw OGS log data. Usually, the result of pd.DataFrame(parse_file(file))
- Returns:
pd.DataFrame with missing values filled by context.
- Return type:
DataFrame
References: Pandas documentation : https://pandas.pydata.org/pandas-docs/stable/user_guide/
Notes: Some logs do not contain information about time_step and iteration. The information must be collected by context (by surrounding log lines from same mpi_process). Logs are grouped by mpi_process to get only surrounding log lines from same mpi_process. There are log lines that give the current time step (when time step starts). It can be assumed that in all following lines belong to this time steps, until next collected value of time step. Some columns that contain actual integer values are converted to float. See https://pandas.pydata.org/pandas-docs/stable/user_guide/integer_na.html ToDo list of columns with integer values are known from regular expression
- ogstools.logparser.ogs_regexes()[source]#
Defines regular expressions for parsing OpenGeoSys log messages.
- Returns:
A list of tuples, each containing a regular expression pattern and the corresponding message class.
- Return type:
list[tuple[str, type[Log]]]
Submodules#
- ogstools.logparser.common_ogs_analyses module
- ogstools.logparser.log_parser module
- ogstools.logparser.regexes module
Log
Info
WarningType
ErrorType
CriticalType
MPIProcess
AssemblyTime
TimeStep
Iteration
IterationTime
TimeStepStartTime
TimeStepOutputTime
TimeStepSolutionTime
TimeStepSolutionTimeCoupledScheme
TimeStepFinishedTime
DirichletTime
LinearSolverTime
MeshReadTime
SimulationExecutionTime
ComponentConvergenceCriterion
TimeStepConvergenceCriterion
CouplingIterationConvergence
GenericCodePoint
PhaseFieldEnergyVar
ErrorMessage
CriticalMessage
WarningMessage
ogs_regexes()