Skip to content

Commit 51ad897

Browse files
committed
Improve naming of grid per-phase metrics
Single 3-phase metrics like `power` have had no suffix, and those stay as they are. 3-phase metrics specified per-phase now use the `per_phase` suffix. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 69aad56 commit 51ad897

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

src/frequenz/sdk/timeseries/formula_engine/_formula_engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class FormulaEngine3Phase(
461461
462462
ev_charger_pool = microgrid.new_ev_charger_pool(priority=5)
463463
464-
async for sample in ev_charger_pool.current.new_receiver():
464+
async for sample in ev_charger_pool.current_per_phase.new_receiver():
465465
print(f"Current: {sample}")
466466
```
467467
@@ -478,7 +478,9 @@ class FormulaEngine3Phase(
478478
grid = microgrid.grid()
479479
480480
# Calculate grid consumption current that's not used by the EV chargers
481-
other_current = (grid.current - ev_charger_pool.current).build("other_current")
481+
other_current = (grid.current_per_phase - ev_charger_pool.current).build(
482+
"other_current"
483+
)
482484
483485
async for sample in other_current.new_receiver():
484486
print(f"Other current: {sample}")

src/frequenz/sdk/timeseries/grid.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def power(self) -> FormulaEngine[Power]:
9999
return engine
100100

101101
@property
102-
def _power_3_phase(self) -> FormulaEngine3Phase[Power]:
103-
"""Fetch the grid 3-phase power for the microgrid.
102+
def _power_per_phase(self) -> FormulaEngine3Phase[Power]:
103+
"""Fetch the per-phase grid power for the microgrid.
104104
105105
This formula produces values that are in the Passive Sign Convention (PSC).
106106
@@ -117,8 +117,8 @@ def _power_3_phase(self) -> FormulaEngine3Phase[Power]:
117117
return engine
118118

119119
@property
120-
def current(self) -> FormulaEngine3Phase[Current]:
121-
"""Fetch the grid current for the microgrid.
120+
def current_per_phase(self) -> FormulaEngine3Phase[Current]:
121+
"""Fetch the per-phase grid current for the microgrid.
122122
123123
This formula produces values that are in the Passive Sign Convention (PSC).
124124

tests/microgrid/test_grid.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ async def test_grid_power_3_phase_side_meter(mocker: MockerFixture) -> None:
200200
assert grid, "Grid is not initialized"
201201
stack.push_async_callback(grid.stop)
202202

203-
grid_power_3_phase_recv = (
204-
grid._power_3_phase.new_receiver() # pylint: disable=protected-access
203+
grid_power_per_phase_recv = (
204+
grid._power_per_phase.new_receiver() # pylint: disable=protected-access
205205
)
206206

207207
for count in range(10):
@@ -216,7 +216,7 @@ async def test_grid_power_3_phase_side_meter(mocker: MockerFixture) -> None:
216216
[watts_phases, watts_phases]
217217
)
218218

219-
val = await grid_power_3_phase_recv.receive()
219+
val = await grid_power_per_phase_recv.receive()
220220
assert val is not None
221221
assert val.value_p1 and val.value_p2 and val.value_p3
222222
assert val.value_p1.as_watts() == watts_phases[0]
@@ -234,8 +234,8 @@ async def test_grid_power_3_phase_none_values(mocker: MockerFixture) -> None:
234234
assert grid, "Grid is not initialized"
235235
stack.push_async_callback(grid.stop)
236236

237-
grid_power_3_phase_recv = (
238-
grid._power_3_phase.new_receiver() # pylint: disable=protected-access
237+
grid_power_per_phase_recv = (
238+
grid._power_per_phase.new_receiver() # pylint: disable=protected-access
239239
)
240240

241241
for count in range(10):
@@ -250,7 +250,7 @@ async def test_grid_power_3_phase_none_values(mocker: MockerFixture) -> None:
250250
[watts_phases, [None, None, None], [None, 219.8, 220.2]]
251251
)
252252

253-
val = await grid_power_3_phase_recv.receive()
253+
val = await grid_power_per_phase_recv.receive()
254254
assert val is not None
255255
assert val.value_p1 and val.value_p2 and val.value_p3
256256
assert val.value_p1.as_watts() == watts_phases[0]

tests/timeseries/_formula_engine/test_formula_composition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ async def test_3_phase_formulas(self, mocker: MockerFixture) -> None:
428428
grid = microgrid.grid()
429429
stack.push_async_callback(grid.stop)
430430

431-
grid_current_recv = grid.current.new_receiver()
431+
grid_current_recv = grid.current_per_phase.new_receiver()
432432
ev_current_recv = ev_pool.current.new_receiver()
433433

434-
engine = (grid.current - ev_pool.current).build("net_current")
434+
engine = (grid.current_per_phase - ev_pool.current).build("net_current")
435435
stack.push_async_callback(engine._stop) # pylint: disable=protected-access
436436
net_current_recv = engine.new_receiver()
437437

0 commit comments

Comments
 (0)