eelib.utils.eval.eval_utils
Useful helper methods for evaluating .hdf5 results in jupyter notebooks.
Module Contents
Functions
|
Recursively extract data from hdf5 file. |
|
Return a dataframe representation of the hdf5 file. |
|
Return scenario configuration of the hdf5 file. |
|
Converts an hdf5 file with the proper format into a csv file. Uses non-compact representation |
|
Converts a (numpy list of) timestep(s) to a (numpy list of) actual date(s). |
|
Saves a Matplotlib figure with standardized sizing and format. |
|
Return dictionary corresponding to Config grouping. |
|
Retrieves the grid stored within the eELib convention of an |
- _extract_datasets_from_group(group: h5py.Group, parent_name: str = '', pattern: str = None) dict
Recursively extract data from hdf5 file.
- Parameters:
group (Group) – The group where the search is currently occuring.
parent_name (str, optional) – The parent name of that group.
pattern (str) – regex pattern. If given, only the part matching the first grouping in the pattern remains as the name for each timeseries. Otherwise, the full path of the timeseries is used as its name.
- Raises:
ValueError – if pattern is given and at least one name does not match it
- Returns:
the fully formed subgroup for the current group.
- Return type:
dict
- hdf5_file_as_pandas(path: str, datetime_col: bool = False, pattern: str = None) pandas.DataFrame
Return a dataframe representation of the hdf5 file.
- Parameters:
path (str) – hdf5 file path.
datetime_col (bool, optional) – determines whether a datetime column is created using the Config section of the database.
pattern (str) – regex pattern. If given, only the part matching the first grouping in the pattern remains as the name for each timeseries. Otherwise, the full path of the timeseries is used as its name.
- Returns:
The resulting dataframe.
- Return type:
pd.DataFrame
- get_config(path: str) dict
Return scenario configuration of the hdf5 file.
- Parameters:
path (str) – path of the hdf5 file.
- Returns:
scenario configuration dict.
- Return type:
dict
- convert_hdf5_to_csv(input_path: str, output_path: str, sep: str = ',', na_rep: str = '', datetime_col: bool = False)
Converts an hdf5 file with the proper format into a csv file. Uses non-compact representation unless specified.
- Parameters:
input_path (str) – path for input hdf5 file.
output_path (str) – path for the output csv file.
sep (str, optional) – String as Field delimiter for the output file. Defaults to ‘,’.
na_rep (str, optional) – Missing data representation. Defaults to ‘’.
datetime_col (bool, optional) – Whether the function adds a column to dataframe to display the actual date and time in addition to timesteps. Only works if compact=True. Defaults to False.
- timestep_to_datetime(timestep: int, zero_datetime: datetime.datetime | str, step_size: int) numpy.datetime64
Converts a (numpy list of) timestep(s) to a (numpy list of) actual date(s).
- Parameters:
timestep (int) – a timestep or a numpy array of timesteps.
zero_datetime (datetime | str) – The datetime corresponding to timestep 0. Either as str in the format “YYYY-MM-DD HH:mm:ss” or as datetime64 right away.
step_size (int) – size of each timestep in seconds.
- Returns:
calculated date(s) corresponding to timestep(s).
- Return type:
np.datetime64
- save_figure(fig: matplotlib.figure.Figure, ax: matplotlib.axis.Axis, filename: str, path: str, figsize: tuple[int, int] = (15, 5), dpi: int = 300, format: str = 'svg', rasterized: bool = True)
Saves a Matplotlib figure with standardized sizing and format.
- Parameters:
fig (Figure) – Matplotlib figure to be saved.
ax (Axis) – Matplotlib ax.
filename (str) – Name of the output file.
path (str) – path of the output file.
figsize (tuple[int, int]) – Size of the figure in inches (width, height).
dpi (int) – Dots per inch for image resolution.
format (str) – Output file format (e.g., ‘svg’, ‘png’, ‘jpg’, etc.).
rasterized (bool) – Whether to rasterize vector elements (True) or not (False).
- _read_config(hdf5_data: dict) dict
Return dictionary corresponding to Config grouping.
- Parameters:
hdf5_data (dict) – data read from an hdf5 file using h5py.
- Returns:
the Config as stored.
- Return type:
dict
- grid_from_input_file(path: str) pandapower.auxiliary.pandapowerNet
Retrieves the grid stored within the eELib convention of an
input.json.- Params:
path (str): The path to the
input.json.
- Raises:
ValueError – When no grid data was found in
input.json.- Returns:
The grid described in the
input.json.- Return type:
pandapowerNet