1. pypontem tpl parsing

tplParser: Class which holds the tpl parser functions

Functions:
  1. metadata: to extract metadata from a tpl file

  2. branch_names: to extract branch names from a tpl file

  3. branch_profiles: to extract branch profile information from a tpl file

  4. parse_number_of_variables: to extract the number of variables present in a tpl file

  5. extract_catalog: to extract the catalog information from a tpl file

  6. search_catalog: to extract the information from the catalog of the variable specified

  7. extract_trends: to extract trends in a tpl file

  8. calc_average: to compute the average of trends extracted in a tpl file

metadata:

metadata()

Extracts metadata from the content stored in the object and returns it as a pandas DataFrame.

Arguments:
  • None.

Returns:
  • metadata (pd.DataFrame): A DataFrame containing the extracted metadata with keys as column headers

branch_names:

branch_names(Args = None)

Extracts branch names from the content stored in the tpl file.

Arguments:
  • None.

Returns:
  • branch_names (list): A list of extracted branch names as strings.

branch_profiles:

branch_profiles(target_branch = None)

Extracts and displays elevation for a specific branch or all branches in the file.

Arguments:
  • target_branch (str, optional): The name of the branch you want to extract the profiles.

Returns:
  • branch_profiles (dictionary): A dictionary containing the profiles of the specified branch or all the branches if none specified.

n_vars:

n_vars(Args = None)

Parses the number of variables from a given file path.

Arguments:
  • None

Returns:
  • n_vars (int): The number of variables if found, else None.

catalog:

catalog(Args = None)

Extract variable information from the provided content using a regular expression pattern.

Arguments:
  • None.

Returns:
  • returned_catalog (pd.DataFrame): A DataFrame containing the extracted variable information.

search_catalog:

search_catalog(var_name=None, loc_name=None, pipe_name=None)

Searches for variables containing a keyword in their names within a DataFrame.

Arguments:
  • var_name (str): The variable name

  • loc_name (str): The location of the variable you want to search for

  • pipe_name (str): The pipe name of the variable name specified located at the location name provided.

Returns:
  • search_catalog (pd.DataFrame): A dataframe containing catalog information of the variables specified.

extract_trends:

extract_trend(input_matrix: pd.DataFrame)

Search for variables in the DataFrame based on variable names, branches, and pipe names, and display their information.

Arguments:
  • input_matrix (pd.DataFrame):A DataFrame containing variable names, branch names, and pipe names. Click to view the Input matrix template. This is a required argument.

Returns:
  • trends (pd.DataFrame): A DataFrame containing information for all specified variables.

calc_average:

calc_average(input_matrix: pd.DataFrame, start_index=None, end_index=None, n_rows=None, n_timeunits=None)

Calculate the average of values in the DataFrame between the specified start and end indices or for a specified number of rows or for a certain number of time units.

Arguments:
  • input_matrix (pd.DataFrame): The dataframe file containing variable names, branch names, and pipe names. Click to view the Input matrix template. This is a required argument.

  • start_index (int, optional): The starting index from which the average will be calculated. Defaults to None.

  • end_index (int, optional): The ending index up to which the average will be calculated. Defaults to None.

  • n_rows (int, optional): Number of rows to consider for calculating the average. If provided, start_index and end_index are ignored. Defaults to None.

  • n_timeunits (int, optional): All n time units to consider for averaging (n seconds or n hours or n days etc). Note : The unit used will be the same as specified in the input matrix

Returns:
  • averages (pd.DataFrame): DataFrame containing the calculated averages.

2. pypontem tpl batch parsing

tplBatchParser: A class to handle batches of tpl files

Note: tpl batch parsing functionality only works for files of the same batch of simulations with the same branch names and structure, otherwise this will raise an error.

Functions:
  1. extract_trends: To extract trends from a list of tpl files

  2. calc_averages: To compute averages of trends extracted from a list of tpl files

Function to extract trends from a batch of tpl files

Arguments:
  • Input_matrix (pd.DataFrame): The matrix containing variable names, branch names, and pipe names. Click to view the input matrix template. This is a required argument.

Returns
  • batch_trends (pd.DataFrame): DataFrame containing extracted trends from tpl files.

calc_averages:

calc_averages(input_matrix: pd.DataFrame, start_index=None, end_index=None, n_rows=None, n_timeunits=None)

Calculate the average of values in the DataFrame up to the specified index or of the last n values.

Arguments:
  • input_matrix (pd.DataFrame): The dataframe containing variable names, branch names, and pipe names. Click to view the input matrix template. This is a required argument.

  • start_index (int, optional): The starting index from which the average will be calculated. Defaults to None.

  • end_index (int, optional): The ending index up to which the average will be calculated. Defaults to None.

  • n_rows (int, optional): Number of rows to consider for calculating the average. If provided, start_index and end_index are ignored. Defaults to None.

  • n_timeunits (int, optional): All n time units to consider for averaging (n seconds or n hours or n days etc). Note : The unit used will be the same as specified in the input matrix

Returns:
  • batch_average (pd.DataFrame): DataFrame containing the calculated averages.