From 9481cf4447d6a6f5d006d3d3f089ddb800c8c56d Mon Sep 17 00:00:00 2001 From: Flora Date: Thu, 28 Nov 2024 15:05:45 +0200 Subject: [PATCH] Update resolution to reample_period Signed-off-by: Flora --- README.md | 4 ++-- RELEASE_NOTES.md | 1 + src/frequenz/reporting/_reporting.py | 9 ++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 948a79b..30d02a4 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b197c64..f8281f2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -7,6 +7,7 @@ ## Upgrading * Upgraded reporting client to v0.9.0 +* Change from resolution to resampling_period ## New Features diff --git a/src/frequenz/reporting/_reporting.py b/src/frequenz/reporting/_reporting.py index 137c112..bd52bcb 100644 --- a/src/frequenz/reporting/_reporting.py +++ b/src/frequenz/reporting/_reporting.py @@ -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 @@ -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. @@ -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. @@ -52,7 +51,7 @@ async def cumulative_energy( metrics=metric, start_dt=start_time, end_dt=end_time, - resolution=resolution, + resampling_period=resampling_period, ) ]