Skip to content

Commit

Permalink
Added Overview page
Browse files Browse the repository at this point in the history
  • Loading branch information
pclemow committed Aug 6, 2024
1 parent 0059fee commit 3c3f799
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 29 deletions.
2 changes: 1 addition & 1 deletion app/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def html(page: str) -> dict[str, str | dict[str, str | dict[str, str]]]:
"NMX Geographic Map": {"space": "PC02-Top", "app": webrtc},
"NMX 11kV Schematic": {"space": "PC02-Left", "app": webrtc},
"NMX Issues": {"space": "PC02-Right", "app": webrtc},
"Market": {"space": "Hub01", "app": html("supplydemand")},
"Overview": {"space": "Hub01", "app": html("overview")},
"Agent": {"space": "Hub02", "app": html("agent")},
}

Expand Down
121 changes: 93 additions & 28 deletions app/pages/overview.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Market view page in dash app.
"""Overview page in dash app.
Four plots (2x2):
Intended as a direct replacement for original visualisation as an interim measure:
- Energy deficit
- Intraday market bids and offers
- Demand side response
Expand All @@ -15,95 +15,160 @@

from .. import log
from ..figures import (
generate_agent_activity_breakdown_fig,
generate_balancing_market_fig,
generate_dsr_commands_fig,
generate_dsr_fig,
generate_energy_deficit_fig,
generate_intraday_market_bids_fig,
generate_ev_charging_breakdown_fig,
generate_intraday_market_sys_fig,
generate_total_dem_fig,
generate_total_gen_fig,
)
from ..layout import GridBuilder

dash.register_page(__name__)

df = pd.DataFrame({"Col": [0]})

total_gen_fig = generate_total_gen_fig(df)
total_dem_fig = generate_total_dem_fig(df)
energy_deficit_fig = generate_energy_deficit_fig(df)
intraday_market_bids_fig = generate_intraday_market_bids_fig(df)
dsr_fig = generate_dsr_fig(df)
balancing_market_fig = generate_balancing_market_fig(df)
intraday_market_sys_fig = generate_intraday_market_sys_fig(df)
dsr_commands_fig = generate_dsr_commands_fig(df)
agent_activity_breakdown_fig = generate_agent_activity_breakdown_fig(df)
ev_charging_breakdown_fig = generate_ev_charging_breakdown_fig(df)


grid = GridBuilder(rows=2, cols=2)
grid = GridBuilder(rows=4, cols=2)
grid.add_element(
dcc.Graph(
id="graph-energy-deficit",
figure=energy_deficit_fig,
id="ov-generation",
figure=total_gen_fig,
style={"height": "100%", "width": "100%"},
),
row=0,
col=0,
)
grid.add_element(
dcc.Graph(
id="table-intraday-market-bids",
figure=intraday_market_bids_fig,
id="ov-demand",
figure=total_dem_fig,
style={"height": "100%", "width": "100%"},
),
row=1,
col=0,
)
grid.add_element(
dcc.Graph(
id="ov-energy-deficit",
figure=energy_deficit_fig,
style={"height": "100%", "width": "100%"},
),
row=2,
col=0,
)
grid.add_element(
dcc.Graph(
id="ov-bm",
figure=balancing_market_fig,
style={"height": "100%", "width": "100%"},
),
row=0,
col=1,
)
grid.add_element(
dcc.Graph(
id="graph-dsr",
figure=dsr_fig,
id="ov-id",
figure=intraday_market_sys_fig,
style={"height": "100%", "width": "100%"},
),
row=1,
col=0,
col=1,
)
grid.add_element(
dcc.Graph(
id="graph-dsr-commands",
id="ov-dsr",
figure=dsr_commands_fig,
style={"height": "100%", "width": "100%"},
),
row=1,
row=2,
col=1,
)
grid.add_element(
dcc.Graph(
id="ov-agent-waffle",
figure=agent_activity_breakdown_fig,
style={"height": "100%", "width": "100%"},
),
row=3,
col=0,
)
grid.add_element(
dcc.Graph(
id="ov-ev-waffle",
figure=ev_charging_breakdown_fig,
style={"height": "100%", "width": "100%"},
),
row=3,
col=1,
)
layout = grid.layout


@callback(
[
Output("graph-energy-deficit", "figure"),
Output("table-intraday-market-bids", "figure"),
Output("graph-dsr", "figure"),
Output("graph-dsr-commands", "figure"),
Output("ov-generation", "figure"),
Output("ov-demand", "figure"),
Output("ov-energy-deficit", "figure"),
Output("ov-bm", "figure"),
Output("ov-id", "figure"),
Output("ov-dsr", "figure"),
Output("ov-agent-waffle", "figure"),
Output("ov-ev-waffle", "figure"),
],
[Input("figure_interval", "data")],
)
def update_figures(
n_intervals: int,
) -> tuple[px.line, go.Figure, go.Figure, px.line]:
) -> tuple[
px.line, px.line, px.line, go.Figure, go.Figure, px.line, go.Figure, go.Figure
]:
"""Function to update the plots in this page.
Args:
n_intervals (int): The number of times this page has updated.
indexes by 1 every interval.
Returns:
tuple[px.line, go.Figure, go.Figure, px.line]:
tuple[px.line,
px.line,
px.line,
go.Figure,
go.Figure,
px.line,
go.Figure,
go.Figure]:
The new figures.
"""
from ..data import DF_OPAL

total_gen_fig = generate_total_gen_fig(DF_OPAL)
total_dem_fig = generate_total_dem_fig(DF_OPAL)
energy_deficit_fig = generate_energy_deficit_fig(DF_OPAL)
intraday_market_bids_fig = generate_intraday_market_bids_fig(DF_OPAL)
dsr_fig = generate_dsr_fig(df) # TODO: replace with df_dsr when available
balancing_market_fig = generate_balancing_market_fig(DF_OPAL)
intraday_market_sys_fig = generate_intraday_market_sys_fig(DF_OPAL)
dsr_commands_fig = generate_dsr_commands_fig(DF_OPAL)
log.debug("Updating figures on Market page")
agent_activity_breakdown_fig = generate_agent_activity_breakdown_fig(DF_OPAL)
ev_charging_breakdown_fig = generate_ev_charging_breakdown_fig(DF_OPAL)

log.debug("Updating figures on Overview page")
return (
total_gen_fig,
total_dem_fig,
energy_deficit_fig,
intraday_market_bids_fig,
dsr_fig,
balancing_market_fig,
intraday_market_sys_fig,
dsr_commands_fig,
agent_activity_breakdown_fig,
ev_charging_breakdown_fig,
)

0 comments on commit 3c3f799

Please sign in to comment.