Skip to content

Commit 939dad5

Browse files
Merge pull request #214 from Mohammad-Tayyab-Frequenz/update-wind-component
Update wind component
2 parents 018bd1d + a85ef35 commit 939dad5

3 files changed

Lines changed: 45 additions & 31 deletions

File tree

RELEASE_NOTES.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22

33
## Summary
44

5-
This release syncs the reporting helpers with the latest schema and dependency requirements so that asset columns, component analyses, and timestamp handling all stay consistent with the data sources we consume.
65

76
## Upgrading
87

9-
- The pyproject lock now requires `pyyaml>=6.0.3` and `pytz>=2025.2`, so reinstall the dependencies to pick up the tighter YAML and timezone support.
10-
- Column names in exported energy reports have shifted: `grid_consumption` is now computed via the `grid` helper column before renaming, and battery data should be referenced as `battery_power_flow` rather than `battery_throughput`.
118

129
## New Features
1310

14-
- Wind asset production is now fleshed out in the schema mapping (including localized display names) and is available to the overview builder and component analysis flows, alongside the existing PV and CHP columns.
15-
- Component analyses now apply the mapper renaming step after totals are summed, preventing columns from being renamed prematurely and ensuring the display names defined in `schema_mapping.yaml` are always respected.
1611

1712
## Bug Fixes
18-
19-
- Notification deserialization now relies on `isinstance()` to guard against optional dataclass arguments, eliminating the brittle `type()` checks that occasionally crashed the signal service.
20-
- Peak-date computation now pulls the timestamp directly from the aggregated dataframe, coerces it to UTC, and formats it safely, so peak dates no longer break when indexes are strings or timezone-naive.
21-
- The grid column is only populated when it is missing to avoid re-creating `grid_consumption`, preventing duplicate columns during the energy-flow aggregation.
22-
- Schema mappings for CHP and wind outputs have been aligned with the latest raw column tags, and all production display names now use the new hyphenated nomenclature (`PV-Production`, `CHP-Production`, `Wind-Production`).
13+
- Fixed wind components in the energy_report_df and aggregating metrics.

src/frequenz/lib/notebooks/reporting/data_processing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def create_energy_report_df(
7676
# Add Energy flow columns
7777
energy_report_df = add_energy_flows(
7878
energy_report_df,
79-
production_cols=["pv", "chp"],
79+
production_cols=["pv", "chp", "wind"],
8080
consumption_cols=["consumption"],
8181
grid_cols=["grid"],
8282
battery_cols=["battery"],
@@ -107,6 +107,7 @@ def create_energy_report_df(
107107
column_pv="pv",
108108
column_chp="chp",
109109
column_ev="ev",
110+
column_wind="wind",
110111
)
111112

112113
# Determine relevant columns based on component types

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

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,15 @@ def convert_timezone(
191191
return ts.dt.tz_convert(target_tz)
192192

193193

194-
# pylint: disable=too-many-arguments, too-many-positional-arguments
194+
# pylint: disable=too-many-arguments, too-many-positional-arguments, too-many-locals
195195
def label_component_columns(
196196
df: pd.DataFrame,
197197
mcfg: MicrogridConfig,
198198
column_battery: str = "battery",
199199
column_pv: str = "pv",
200200
column_chp: str = "chp",
201201
column_ev: str = "ev",
202+
column_wind: str = "wind",
202203
) -> tuple[pd.DataFrame, list[str]]:
203204
"""Rename numeric single-component columns to labeled names.
204205
@@ -213,7 +214,9 @@ def label_component_columns(
213214
column_battery: Key name for battery component type.
214215
column_pv: Key name for PV component type.
215216
column_chp: Key name for CHP component type.
216-
column_ev: Key name for EV component type
217+
column_ev: Key name for EV component type.
218+
column_wind: Key name for wind component type.
219+
217220
Returns:
218221
Tuple containing the renamed DataFrame and the list of applied labels
219222
"""
@@ -233,6 +236,7 @@ def ids_if_available(t: str) -> set[str]:
233236
pv_ids = ids_if_available(column_pv)
234237
chp_ids = ids_if_available(column_chp)
235238
ev_ids = ids_if_available(column_ev)
239+
wind_ids = ids_if_available(column_wind)
236240

237241
rename: dict[str, str] = {}
238242
rename.update(
@@ -251,6 +255,13 @@ def ids_if_available(t: str) -> set[str]:
251255
rename.update(
252256
{c: f"{column_chp.upper()} #{c}" for c in single_components if c in chp_ids}
253257
)
258+
rename.update(
259+
{
260+
c: f"{column_wind.capitalize()} #{c}"
261+
for c in single_components
262+
if c in wind_ids
263+
}
264+
)
254265

255266
return df.rename(columns=rename), list(rename.values())
256267

@@ -279,31 +290,42 @@ def get_energy_report_columns(
279290
# Map component types to the columns they enable
280291
component_column_map = {
281292
"battery": ["battery_power_flow"],
282-
"pv": [
283-
"pv_asset_production",
284-
"production_self_use",
285-
"grid_feed_in",
286-
],
293+
"pv": ["pv_asset_production"],
287294
"chp": ["chp_asset_production"],
295+
"ev": ["ev_asset_production"],
296+
"wind": ["wind_asset_production"],
288297
}
289298

290-
# Define columns that require both PV and Battery
291-
pv_battery_cols = [
292-
"production_excess_in_bat",
299+
production_components = set(component_column_map.keys()) - {"battery"}
300+
301+
# Columns that should be included if ANY production component exists
302+
universal_production_cols = [
303+
"production_self_use",
304+
"grid_feed_in",
293305
"production_self_share",
294306
]
295307

308+
# Columns available ONLY when battery exists
309+
battery_dependent_cols = [
310+
"production_excess_in_bat",
311+
]
312+
313+
# Check if any production component is present
314+
has_production = any(comp in production_components for comp in component_types)
315+
has_battery = "battery" in component_types
316+
317+
# Add the universal production columns ONLY if production exists
318+
if has_production:
319+
energy_report_df_cols.extend(universal_production_cols)
320+
321+
# Add battery-dependent production columns
322+
if has_battery:
323+
energy_report_df_cols.extend(battery_dependent_cols)
324+
296325
# Add component-specific columns
297-
for component, columns in component_column_map.items():
298-
if component in component_types:
299-
energy_report_df_cols.extend(columns)
300-
301-
# Add combined PV + Battery columns
302-
if (
303-
any(c in component_types for c in ["pv", "chp", "wind", "ev"])
304-
and "battery" in component_types
305-
):
306-
energy_report_df_cols.extend(pv_battery_cols)
326+
for comp in component_types:
327+
if comp in component_column_map:
328+
energy_report_df_cols.extend(component_column_map[comp])
307329

308330
return energy_report_df_cols
309331

0 commit comments

Comments
 (0)