KPI Energy Measurement Points¶
KpiEnergyMeasurementPoints(perfdb)
¶
Class used for handling energy measurement points (where energy is measured).
Parameters:
Source code in echo_postgres/perfdb_root.py
Python
def __init__(self, perfdb: e_pg.PerfDB) -> None:
"""Base class that all subclasses should inherit from.
Parameters
----------
perfdb : PerfDB
Top level object carrying all functionality and the connection handler.
"""
self._perfdb: e_pg.PerfDB = perfdb
get(output_type='dict')
¶
Gets the possible energy measurement points.
Parameters:
-
(output_type¶Literal['dict', 'DataFrame', 'pl.DataFrame'], default:'dict') –Output type of the data. Can be one of ["dict", "DataFrame", "pl.DataFrame"] By default "dict"
Returns:
-
DataFrame–In case output_type is "DataFrame", returns a pandas DataFrame with the following format: index = name, columns = [description, id]
-
DataFrame–In case output_type is "pl.DataFrame", returns a Polars DataFrame
-
dict[str, dict[str, str]]–In case output_type is "dict", returns a dictionary in the format {name: {attribute: value, ...}, ...}
Source code in echo_postgres/kpi_energy_measurementpoints.py
Python
@validate_call
def get(
self,
output_type: Literal["dict", "DataFrame", "pl.DataFrame"] = "dict",
) -> pd.DataFrame | pl.DataFrame | dict[str, dict[str, str]]:
"""Gets the possible energy measurement points.
Parameters
----------
output_type : Literal["dict", "DataFrame", "pl.DataFrame"], optional
Output type of the data. Can be one of ["dict", "DataFrame", "pl.DataFrame"]
By default "dict"
Returns
-------
pd.DataFrame
In case output_type is "DataFrame", returns a pandas DataFrame with the following format: index = name, columns = [description, id]
pl.DataFrame
In case output_type is "pl.DataFrame", returns a Polars DataFrame
dict[str, dict[str, str]]
In case output_type is "dict", returns a dictionary in the format {name: {attribute: value, ...}, ...}
"""
# build the query
query = sql.SQL("SELECT * FROM performance.energy_measurement_points")
df = self._perfdb.conn.read_to_polars(query)
return convert_output(df, output_type)
get_ids()
¶
Gets the possible energy measurement points.
Returns:
-
dict[str, int]–A dictionary in the format {name: id, ...}
Source code in echo_postgres/kpi_energy_measurementpoints.py
Python
def get_ids(self) -> dict[str, int]:
"""Gets the possible energy measurement points.
Returns
-------
dict[str, int]
A dictionary in the format {name: id, ...}
"""
query = sql.SQL("SELECT name, id FROM performance.energy_measurement_points")
data = self._perfdb.conn.read_to_polars(query)
return dict(zip(data["name"].to_list(), data["id"].to_list(), strict=False))