eelib.utils.eval.evaluation_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. |
- _extract_datasets_from_group(group, parent_name='', pattern=None)
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=False, pattern=None)
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:
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=',', na_rep='', datetime_col=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) – String of length 1. Field delimiter for the output file. Defaults to ‘,’.
na_rep (str) – Missing data representation. Defaults to ‘’.
datetime_col (bool) – 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, zero_datetime: datetime.datetime, step_size: int)
Converts a (numpy list of) timestep(s) to a (numpy list of) actual date(s).
- Parameters:
timestep – a timestep or a numpy array of timesteps.
zero_datetime (datetime) – the datetime corresponding to timestep 0. Inclusion of zero in the list is not mandatory.
step_size (int) – size of each timestep in seconds.
- Returns:
calculated date(s) corresponding to timestep(s).
- Return type:
numpy.datetime64
- save_figure(fig, ax, filename, path, figsize=(15, 5), dpi=300, format='svg', rasterized=True)
Saves a Matplotlib figure with standardized sizing and format.
- Parameters:
fig (Figure) – Matplotlib figure to be saved.
ax (Axes) – Matplotlib ax.
filename (str) – Name of the output file.
path (str) – path of the output file.
figsize (tuple) – 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)
Return dictionary corresponding to Config grouping.
- Parameters:
hdf5_data – data read from an hdf5 file using h5py.
- Returns:
the Config as stored.
- Return type:
dict