data_fetch
frequenz.lib.notebooks.solar.maintenance.data_fetch ¤
Dedicated to data retrieval functionalities for the solar maintenance project.
This module provides functions that fetch and transform data from the weather and reporting APIs or csv files.
Classes¤
frequenz.lib.notebooks.solar.maintenance.data_fetch.BaseRetrievalConfig
dataclass
¤
Base configuration for data retrieval.
Source code in frequenz/lib/notebooks/solar/maintenance/data_fetch.py
frequenz.lib.notebooks.solar.maintenance.data_fetch.ReportingRetrievalConfig
dataclass
¤
Bases: BaseRetrievalConfig
Configuration for retrieving reporting data.
Source code in frequenz/lib/notebooks/solar/maintenance/data_fetch.py
frequenz.lib.notebooks.solar.maintenance.data_fetch.WeatherRetrievalConfig
dataclass
¤
Bases: BaseRetrievalConfig
Configuration for retrieving weather data.
Source code in frequenz/lib/notebooks/solar/maintenance/data_fetch.py
Functions¤
frequenz.lib.notebooks.solar.maintenance.data_fetch.retrieve_data
async
¤
retrieve_data(
config: (
WeatherRetrievalConfig | ReportingRetrievalConfig
),
) -> DataFrame
Retrieve data from the weather or reporting API or from a file.
PARAMETER | DESCRIPTION |
---|---|
config
|
The configuration object for data retrieval containing all necessary parameters. See WeatherRetrievalConfig and ReportingRetrievalConfig. |
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A pandas DataFrame containing the retrieved data. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
|
TypeError
|
If an unknown configuration type is provided. |
Source code in frequenz/lib/notebooks/solar/maintenance/data_fetch.py
frequenz.lib.notebooks.solar.maintenance.data_fetch.transform_reporting_data ¤
transform_reporting_data(
data: DataFrame,
microgrid_components: (
list[tuple[int, list[int]]] | None
) = None,
outlier_detection_params: (
dict[
str, str | tuple[float, float] | dict[str, Any]
]
| None
) = None,
time_zone: ZoneInfo = ZoneInfo("UTC"),
verbose: bool = False,
) -> DataFrame
Transform weather reporting data.
Note: This wrapper function expects the timestamps to be in UTC and converts them to the provided timezone.
PARAMETER | DESCRIPTION |
---|---|
data
|
The reporting data.
TYPE:
|
microgrid_components
|
List of microgrid-component ID pairs. If provided, the data is assumed to come from the reporting api and is subsequently pivoted and aggregated based on the microgrid components. |
outlier_detection_params
|
Dictionary of parameters for outlier detection.
TYPE:
|
time_zone
|
The timezone to convert the timestamps to. Should be a valid zoneinfo.ZoneInfo object. |
verbose
|
A boolean flag to print additional information.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
The transformed reporting data. |
Source code in frequenz/lib/notebooks/solar/maintenance/data_fetch.py
frequenz.lib.notebooks.solar.maintenance.data_fetch.transform_weather_data ¤
transform_weather_data(
data: DataFrame,
weather_feature_names_mapping: dict[str, str],
time_zone: ZoneInfo = ZoneInfo("UTC"),
verbose: bool = False,
) -> DataFrame
Transform weather forecast data.
PARAMETER | DESCRIPTION |
---|---|
data
|
The weather forecast data.
TYPE:
|
weather_feature_names_mapping
|
Mapping of weather API feature names to internal feature names. |
time_zone
|
The timezone to convert the timestamps to. Should be a valid zoneinfo.ZoneInfo object. |
verbose
|
A boolean flag to print additional information.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
The transformed weather forecast data. |
RAISES | DESCRIPTION |
---|---|
ValueError
|
If missing or invalid date entries are found in 'validity_ts'. |