eelib.utils.simulation_setup.helper_model_overview

Helper functions for the generation of model overview for the eELib.

Author: elenia@TUBS
Copyright 2024 elenia
This file is part of eELib, which is free software under the terms of the GNU GPL Version 3.

Module Contents

Functions

gen_model_overview(→ dict)

Create overview of models in the eELib with search for all simulators.

find_specific_files(→ list)

Recursively search for files matching the pattern (in the filename) in the given directory.

get_sim_info(→ dict)

Load simulator and model module to retrieve data for both into a dict.

get_model_info(→ dict)

Retrieve data for a model class including valid input parameters.

model_info_to_valid_params_df(→ pandas.DataFrame)

From model information print valid input parameters to the console.

model_info_to_string(→ str)

Convert the collected information about models into a single string.

string_to_file(input[, file_path])

Saves a string in specified format to a file.

gen_model_overview(path_rst: str = 'model_overview.rst', path_txt: str = None) dict

Create overview of models in the eELib with search for all simulators.

Parameters:
  • path_rst (str) – Path to save model info in rst-format, if needed. Defaults to “model_overview.rst”.

  • path_txt (str) – Path to save model info in txt-format, if needed. Defaults to None.

Returns:

information about all eELib model, including class and valid parameters

Return type:

dict

find_specific_files(directory: str, pattern: str) list

Recursively search for files matching the pattern (in the filename) in the given directory.

Parameters:
  • directory (str) – The root directory to start searching from.

  • pattern (str) – The pattern to match files (e.g., ‘*.txt’ for all text files).

Returns:

paths to the matching files

Return type:

list

get_sim_info(full_file_path: str) dict

Load simulator and model module to retrieve data for both into a dict.

Parameters:

full_file_path (str) – path to the simulator file

Returns:

information about simulator and list of corresponding models

Return type:

dict

get_model_info(model_class: str, sim_dict: dict, eelib_dir: str) dict

Retrieve data for a model class including valid input parameters.

Parameters:
  • model_class (str) – name of the class for the model type

  • sim_dict (dict) – information collected from the simulator (file paths etc.)

  • eelib_dir (str) – path to eELib directory

Returns:

information about the model, including class and valid parameters

Return type:

dict

model_info_to_valid_params_df(model_info: dict) pandas.DataFrame

From model information print valid input parameters to the console.

Parameters:

model_info (dict) – information about the model, including class and valid parameters

Returns:

Dataframe of valid parameters

Return type:

pd.DataFrame

model_info_to_string(model_info: dict, title: str = 'Model Information') str

Convert the collected information about models into a single string.

Parameters:
  • model_info (dict) – information about models with class, path, and valid parameters

  • title (str) – Title for the string. Defaults to “Model Information”.

Returns:

the full string with all model information

Return type:

str

string_to_file(input: str, file_path: str = 'model_overview.rst')

Saves a string in specified format to a file.

Parameters:
  • input (str) – The text content to save.

  • file_path (str) – The full path of the file to save the content in.