Skip to content

Commit 9481cf4

Browse files
Update resolution to reample_period
Signed-off-by: Flora <[email protected]>
1 parent 426615e commit 9481cf4

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ client = ReportingApiClient(service_address=SERVICE_ADDRESS, key=API_KEY)
5151
If the component does not measure `Metric.AC_ACTIVE_ENERGY`, set `use_active_power=True`
5252
to utilize `Metric.AC_ACTIVE_POWER` instead.
5353

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

7070
print(energy_reading)

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
## Upgrading
88

99
* Upgraded reporting client to v0.9.0
10+
* Change from resolution to resampling_period
1011

1112
## New Features
1213

src/frequenz/reporting/_reporting.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""A highlevel interface for the reporting API."""
55

66
from collections import namedtuple
7-
from datetime import datetime
7+
from datetime import datetime, timedelta
88

99
from frequenz.client.common.metric import Metric
1010
from frequenz.client.reporting import ReportingApiClient
@@ -24,7 +24,7 @@ async def cumulative_energy(
2424
start_time: datetime,
2525
end_time: datetime,
2626
use_active_power: bool,
27-
resolution: int | None = None,
27+
resampling_period: timedelta | None,
2828
) -> CumulativeEnergy:
2929
"""
3030
Calculate the cumulative energy consumption and production over a specified time range.
@@ -37,8 +37,7 @@ async def cumulative_energy(
3737
end_time: The end date and time for the period.
3838
use_active_power: If True, use the 'AC_ACTIVE_POWER' metric.
3939
If False, use the 'AC_ACTIVE_ENERGY' metric.
40-
resolution: The resampling resolution for the data, represented in seconds.
41-
If None, no resampling is applied.
40+
resampling_period: The period for resampling the data.If None, no resampling is applied.
4241
Returns:
4342
EnergyMetric: A named tuple with start_time, end_time, consumption, and production
4443
in Wh. Consumption has a positive sign, production has a negative sign.
@@ -52,7 +51,7 @@ async def cumulative_energy(
5251
metrics=metric,
5352
start_dt=start_time,
5453
end_dt=end_time,
55-
resolution=resolution,
54+
resampling_period=resampling_period,
5655
)
5756
]
5857

0 commit comments

Comments
 (0)