Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ client = ReportingApiClient(service_address=SERVICE_ADDRESS, key=API_KEY)
If the component does not measure `Metric.AC_ACTIVE_ENERGY`, set `use_active_power=True`
to utilize `Metric.AC_ACTIVE_POWER` instead.

A resolution can be set that alters how NaNs are handled, resulting in varying
A resampling period can be set that alters how NaNs are handled, resulting in varying
results. NaN values are ignored in sums, which may lead to significant data loss
if many are present in the raw data. There is no universally correct method for
handling NaNs, as their causes can vary.
Expand All @@ -64,7 +64,7 @@ energy_reading = await cumulative_energy(
start_time=datetime.fromisoformat("2024-09-01T00:00:00"),
end_time=datetime.fromisoformat("2024-09-30T00:00:00"),
use_active_power=True,
resolution=10,
resampling_period=timedelta(seconds=10),
)

print(energy_reading)
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Upgrading

* Upgraded reporting client to v0.9.0
* Change from resolution to resampling_period

## New Features

Expand Down
9 changes: 4 additions & 5 deletions src/frequenz/reporting/_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""A highlevel interface for the reporting API."""

from collections import namedtuple
from datetime import datetime
from datetime import datetime, timedelta

from frequenz.client.common.metric import Metric
from frequenz.client.reporting import ReportingApiClient
Expand All @@ -24,7 +24,7 @@ async def cumulative_energy(
start_time: datetime,
end_time: datetime,
use_active_power: bool,
resolution: int | None = None,
resampling_period: timedelta | None,
) -> CumulativeEnergy:
"""
Calculate the cumulative energy consumption and production over a specified time range.
Expand All @@ -37,8 +37,7 @@ async def cumulative_energy(
end_time: The end date and time for the period.
use_active_power: If True, use the 'AC_ACTIVE_POWER' metric.
If False, use the 'AC_ACTIVE_ENERGY' metric.
resolution: The resampling resolution for the data, represented in seconds.
If None, no resampling is applied.
resampling_period: The period for resampling the data.If None, no resampling is applied.
Returns:
EnergyMetric: A named tuple with start_time, end_time, consumption, and production
in Wh. Consumption has a positive sign, production has a negative sign.
Expand All @@ -52,7 +51,7 @@ async def cumulative_energy(
metrics=metric,
start_dt=start_time,
end_dt=end_time,
resolution=resolution,
resampling_period=resampling_period,
)
]

Expand Down
Loading