diff --git a/app/core_api.py b/app/core_api.py index 3d3676e..fb20575 100644 --- a/app/core_api.py +++ b/app/core_api.py @@ -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")}, } diff --git a/app/pages/overview.py b/app/pages/overview.py index f09ab57..f0120ec 100644 --- a/app/pages/overview.py +++ b/app/pages/overview.py @@ -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 @@ -15,10 +15,14 @@ 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 @@ -26,17 +30,20 @@ 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, @@ -44,8 +51,26 @@ ) 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, @@ -53,20 +78,38 @@ ) 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 @@ -74,16 +117,22 @@ @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: @@ -91,19 +140,35 @@ def update_figures( 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, )