Skip to content

Commit

Permalink
Merge pull request #106 from ImperialCollegeLondon/rearrange
Browse files Browse the repository at this point in the history
Rearrange graphs
  • Loading branch information
tsmbland authored Dec 7, 2023
2 parents 283e3ed + 7070bb6 commit d143225
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 41 deletions.
4 changes: 2 additions & 2 deletions app/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def html(page: str) -> dict[str, str | dict[str, str | dict[str, str]]]:
INIT_SECTIONS = {
"Control": {"space": "Tablet", "app": html("control")},
"NMX": {"space": "PC01-Top", "app": webrtc},
"Balance of Supply and Demand": {"space": "PC01-Left", "app": html("supplydemand")},
"Balance of Supply and Demand": {"space": "PC01-Left", "app": html("market")},
"Markets and Reserve": {"space": "PC01-Right", "app": html("marketsreserve")},
"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("market")},
"Market": {"space": "Hub01", "app": html("supplydemand")},
"Agent": {"space": "Hub02", "app": html("agent")},
}

Expand Down
48 changes: 9 additions & 39 deletions app/pages/market.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Market view page in dash app.
Six plots (2x3):
- Intra-day market system
- Balancing market
Four plots (2x2):
- Energy deficit
- Intraday market bids and offers
- Demand side response
Expand All @@ -17,63 +15,41 @@
from plotly import graph_objects as go # type: ignore

from ..figures import (
generate_balancing_market_fig,
generate_dsr_commands_fig,
generate_dsr_fig,
generate_energy_deficit_fig,
generate_intraday_market_bids_fig,
generate_intraday_market_sys_fig,
)
from ..layout import GridBuilder

dash.register_page(__name__)

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

intraday_market_sys_fig = generate_intraday_market_sys_fig(df)
balancing_market_fig = generate_balancing_market_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)
dsr_commands_fig = generate_dsr_commands_fig(df)


grid = GridBuilder(rows=2, cols=3)
grid.add_element(
dcc.Graph(
id="graph-intraday-market-sys",
figure=intraday_market_sys_fig,
style={"height": "100%", "width": "100%"},
),
row=0,
col=0,
)
grid.add_element(
dcc.Graph(
id="graph-balancing-market",
figure=balancing_market_fig,
style={"height": "100%", "width": "100%"},
),
row=0,
col=1,
)
grid = GridBuilder(rows=2, cols=2)
grid.add_element(
dcc.Graph(
id="graph-energy-deficit",
figure=energy_deficit_fig,
style={"height": "100%", "width": "100%"},
),
row=0,
col=2,
col=0,
)
grid.add_element(
dcc.Graph(
id="table-intraday-market-bids",
figure=intraday_market_bids_fig,
style={"height": "100%", "width": "100%"},
),
row=1,
col=0,
row=0,
col=1,
)
grid.add_element(
dcc.Graph(
Expand All @@ -82,7 +58,7 @@
style={"height": "100%", "width": "100%"},
),
row=1,
col=1,
col=0,
)
grid.add_element(
dcc.Graph(
Expand All @@ -91,15 +67,13 @@
style={"height": "100%", "width": "100%"},
),
row=1,
col=2,
col=1,
)
layout = grid.layout


@callback(
[
Output("graph-intraday-market-sys", "figure"),
Output("graph-balancing-market", "figure"),
Output("graph-energy-deficit", "figure"),
Output("table-intraday-market-bids", "figure"),
Output("graph-dsr", "figure"),
Expand All @@ -109,28 +83,24 @@
)
def update_figures(
n_intervals: int,
) -> tuple[go.Figure, go.Figure, px.line, go.Figure, go.Figure, px.line]:
) -> tuple[px.line, go.Figure, go.Figure, px.line]:
"""Function to update the plots in this page.
Args:
n_intervals (int): The number of times this page has updated.
indexes by 1 every 7 seconds.
Returns:
tuple[go.Figure, go.Figure, px.line, go.Figure, go.Figure, px.line]:
tuple[px.line, go.Figure, go.Figure, px.line]:
The new figures.
"""
from ..data import DF_OPAL

intraday_market_sys_fig = generate_intraday_market_sys_fig(DF_OPAL)
balancing_market_fig = generate_balancing_market_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
dsr_commands_fig = generate_dsr_commands_fig(DF_OPAL)
return (
intraday_market_sys_fig,
balancing_market_fig,
energy_deficit_fig,
intraday_market_bids_fig,
dsr_fig,
Expand Down

0 comments on commit d143225

Please sign in to comment.