state_analysis
frequenz.lib.notebooks.reporting.state_analysis ¤
Functions for analyzing microgrid component state transitions and extracting alerts.
Classes¤
Functions¤
frequenz.lib.notebooks.reporting.state_analysis.fetch_and_extract_state_durations
async
¤
fetch_and_extract_state_durations(
*,
client: ReportingApiClient,
microgrid_components: list[tuple[int, list[int]]],
metrics: list[Metric],
start_time: datetime,
end_time: datetime,
resampling_period: timedelta | None,
alert_states: list[ComponentStateCode],
include_warnings: bool = True
) -> tuple[list[StateRecord], list[StateRecord]]
Fetch data using the Reporting API and extract state durations and alert records.
PARAMETER | DESCRIPTION |
---|---|
client
|
The client used to fetch the metric samples from the Reporting API.
TYPE:
|
microgrid_components
|
List of tuples where each tuple contains microgrid ID and corresponding component IDs. |
metrics
|
List of metric names. NOTE: The service will support requesting states without metrics in the future and this argument will be removed.
TYPE:
|
start_time
|
The start date and time for the period.
TYPE:
|
end_time
|
The end date and time for the period.
TYPE:
|
resampling_period
|
The period for resampling the data. If None, data will be returned in its original resolution.
TYPE:
|
alert_states
|
List of ComponentStateCode names that should trigger an alert.
TYPE:
|
include_warnings
|
Whether to include warning states in the alert records.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
tuple[list[StateRecord], list[StateRecord]]
|
A tuple containing: - A list of StateRecord instances representing the state changes. - A list of StateRecord instances that match the alert criteria. |