Skip to content

Commit 8cd939f

Browse files
Merge pull request #226 from Mohammad-Tayyab-Frequenz/add-missing-consumption
Add missing consumption
2 parents 3030feb + b3c07b8 commit 8cd939f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
## Bug Fixes
1717

1818
- Fix nox formatting/type warnings by casting timezone conversions, enforcing literal aggregation functions, and keeping area/line plotting parameters typed in the solar maintenance views.
19+
- Calculate consumption in scenarios where consumption is missing from the data.

src/frequenz/lib/notebooks/reporting/utils/helpers.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
from frequenz.lib.notebooks.reporting.metrics.reporting_metrics import (
5252
asset_production,
53+
consumption,
5354
grid_consumption,
5455
grid_feed_in,
5556
production_excess,
@@ -411,7 +412,20 @@ def add_energy_flows(
411412
df_flows[col] = _get_numeric_series(df_flows, col)
412413
consumption_series_cols.append(col)
413414

414-
df_flows["consumption_total"] = _sum_cols(df_flows, consumption_series_cols)
415+
if resolved_consumption_cols:
416+
df_flows["consumption_total"] = _sum_cols(df_flows, consumption_series_cols)
417+
else:
418+
# When no explicit consumption columns exist, infer it from grid info.
419+
df_flows["consumption_total"] = consumption(
420+
grid_power_series,
421+
production=_sum_cols(
422+
df_flows, resolved_production_cols
423+
), # raw production to have the negative production values
424+
battery=battery_power_series,
425+
)
426+
427+
# Set consumption to total consumption if no explicit consumption columns exist
428+
df_flows["consumption"] = df_flows["consumption_total"].copy()
415429

416430
# Surplus vs. consumption (production is already positive because of the above cleaning)
417431
df_flows["production_excess"] = production_excess(

0 commit comments

Comments
 (0)