sir3stoolkit.mantle package

Submodules

sir3stoolkit.mantle.alternative_models module

sir3stoolkit.mantle.dataframes module

Created on Fri Aug 29 09:22:31 2025

@author: Jablonski

class sir3stoolkit.mantle.dataframes.Dataframes_SIR3S_Model[source]

Bases: SIR3S_Model

This class is supposed to extend the general SIR3S_Model class with the possibility of using pandas dataframes when working with SIR 3S. Getting dataframes, inserting elements via dataframes, running algorithms on dataframes should be made possible.

class DataFrames(df_node: 'pd.DataFrame' = <factory>, df_pipe: 'pd.DataFrame' = <factory>)[source]

Bases: object

df_node: DataFrame
df_pipe: DataFrame
apply_metadata_property_updates(element_type: str | Enum, updates_df: DataFrame, properties_new: List[str] | None = None, tag: str | None = '_new') DataFrame[source]

Apply metadata updates for a single property using a DataFrame with keys and new values.

Expects: - One key column (default: ‘tk’), and - Exactly one column named ‘<metadata_property>_new’ (or pass property_name to target one explicitly).

Parameters:
  • element_type (Union[str, Enum]) – The element type to update (e.g., self.ObjectTypes.Pipe).

  • updates_df (pd.DataFrame) – Input with at least: - key column (default ‘tk’), and - one ‘<property>_new’ column (e.g., ‘diameter_mm_new’).

  • property_name (Optional[str], default None) – If given, we will look for the column f”{property_name}_new”. If None, we auto-detect a single ‘*_new’ column.

  • on (str, default 'tk') – Name of the key column in updates_df. If it’s the index, it will be reset.

  • create_missing (bool, default False) – If True, allow creating metadata rows that don’t exist yet (your set-logic decides how).

  • dry_run (bool, default False) – If True, do NOT apply; just return a normalized summary of what would be changed.

  • allow_na (bool, default True) – If False, rows with NaN in the ‘<property>_new’ column will be dropped (skipped).

Returns:

A summary dataframe with columns: [‘tk’, ‘property’, ‘new_value’] (+ ‘status’ when dry_run) representing the intended updates.

Return type:

pd.DataFrame

generate_dataframes()[source]

Manually generate and populate all relevant dataframes.

Inlcude optional param with ElemenTypes to only create certain dataframes

generate_element_metadata_dataframe(element_type: str | Enum, properties: List[str] | None = None, geometry: bool | None = False, end_nodes: bool | None = False) DataFrame[source]

Generate a dataframe with metadata (static) properties for all devices of a given element type.

Parameters:
  • element_type (Enum or str) – The element type (e.g., self.ObjectTypes.Node).

  • properties (list[str], optional) – If properties=None => All available properties will be used If properties=[] => No properties will be used

  • geometry (bool, optional) – If True, includes geometric information for each element in the dataframe. Note that this is still a regular DataFrame no GeoDataFrame, to convert it you need a crs values. Adds a ‘geometry’ column containing spatial data (WKT represenation eg. POINT (x y)) Default is False.

  • end_nodes (bool, optional) – If True and supported by the element type, includes tks of end nodes as cols (fkKI, fkKK, fkKI2, fkKK2) in the dataframe. Default is False.

Returns:

Dataframe with one row per device (tk) and columns for requested metadata properties, geometry and end nodes. Columns: [“tk”, <metadata_props>]

Return type:

pd.DataFrame

generate_element_results_dataframe(element_type: str | Enum, properties: List[str] | None = None, timestamps: List[str] | None = None) DataFrame[source]

Generate a dataframe with RESULT (time-dependent) properties for all devices and timestamps.

Parameters:
  • element_type (Enum or str) – The element type (e.g., self.ObjectTypes.Node).

  • properties (list[str], optional) – List of RESULT property names (vectors) to include. If None, includes ALL available result properties.

  • timestamps (list[str], optional) – List of timestamps to include. If None, uses all simulation timestamps (or STAT if no sims).

Returns:

Dataframe with one row per (timestamp, tk) and columns for requested result properties. Columns: [“timestamp”, “tk”, <result_props>]

Return type:

pd.DataFrame

sir3stoolkit.mantle.dataframes_TB_integrated module

sir3stoolkit.mantle.logging_config module

sir3stoolkit.mantle.mantle module

sir3stoolkit.mantle.plotting module

Module contents