Skip to content

Commit

Permalink
Modifications to figure, and marking lines to change
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmbland committed Nov 7, 2023
1 parent 123ae05 commit ecc3b0c
Showing 1 changed file with 42 additions and 29 deletions.
71 changes: 42 additions & 29 deletions app/figures.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def generate_intraday_market_sys_fig(df: pd.DataFrame) -> go:
"Intra-Day Market Storage",
"Intra-Day Market Demand",
],
range_y=[0, 1],
range_y=[0, 1], # Check range XXX
).update_layout(yaxis_title="Power (MW)")

intraday_market_sys_fig_right = (
Expand All @@ -146,7 +146,7 @@ def generate_intraday_market_sys_fig(df: pd.DataFrame) -> go:
y=[
"Intra-Day Market Value",
],
range_y=[0, 1],
range_y=[0, 1], # Check range XXX
)
.update_layout(yaxis_title="Cost (£/MW)")
.update_traces(yaxis="y2")
Expand Down Expand Up @@ -181,7 +181,7 @@ def generate_balancing_market_fig(df: pd.DataFrame) -> go:
"Balancing Mechanism Storage",
"Balancing Mechanism Demand",
],
range_y=[0, 1],
range_y=[0, 1], # Check range XXX
).update_layout(yaxis_title="Power (MW)")

balancing_market_fig_right = (
Expand All @@ -191,7 +191,7 @@ def generate_balancing_market_fig(df: pd.DataFrame) -> go:
y=[
"Balancing Mechanism Value",
],
range_y=[0, 1],
range_y=[0, 1], # Check range XXX
)
.update_layout(yaxis_title="Cost (£/MW)")
.update_traces(yaxis="y2")
Expand Down Expand Up @@ -220,7 +220,7 @@ def generate_energy_deficit_fig(df: pd.DataFrame) -> px.line:
df,
x="Time",
y=df["Exp. Offshore Wind Generation"] - df["Real Offshore Wind Generation"],
range_y=[0, 1],
range_y=[0, 1], # Check range XXX
).update_layout(yaxis_title="MW")

return energy_deficit_fig
Expand All @@ -239,15 +239,13 @@ def generate_intraday_market_bids_fig(df: pd.DataFrame) -> go.Figure:
intraday_market_bids_fig = go.Figure()

else:
columns = ["Total Generation", "Total Demand"] # dummy data
columns = ["Power", "Cost"] # Units? XXX
data = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] # Dummy data XXX
intraday_market_bids_fig = go.Figure(
data=[
go.Table(
header=dict(values=columns, align="left"),
cells=dict(
values=[df[c] for c in columns],
align="left",
),
cells=dict(values=data, align="left"),
)
]
)
Expand All @@ -256,32 +254,47 @@ def generate_intraday_market_bids_fig(df: pd.DataFrame) -> go.Figure:


def generate_dsr_fig(df: pd.DataFrame) -> go.Figure:
"""Creates plotly Figure object for DSR Bids and Offers table.
"""Creates plotly figure for Demand Side Response graph.
Args:
df: DSR data DataFrame
df: DSR data DataFrame. Will this be DSR, Opal or both? XXX
Returns:
Plotly graph_objects figure
Plotly express figure
"""
dsr_fig = make_subplots(specs=[[{"secondary_y": True}]])

if len(df.columns) == 1:
dsr_bids_fig = go.Figure()
return dsr_fig

else:
columns = ["Amount", "Cost"] # dummy data
dsr_bids_fig = go.Figure(
data=[
go.Table(
header=dict(values=columns, align="left"),
cells=dict(
values=[df[c] for c in columns],
align="left",
),
)
]
dsr_fig_left = px.line(
df,
x="Time",
y=[
"Cost", # This will need to be changed when data is available XXX
"Cost", # As above XXX
],
range_y=[0, 1], # Check range XXX
).update_layout(yaxis_title="Power (kW)")

dsr_fig_right = (
px.line(
df,
x="Time",
y=[
"Cost",
],
range_y=[0, 1], # Check range XXX
)
.update_layout(yaxis_title="Cost (£)")
.update_traces(yaxis="y2")
)

return dsr_bids_fig
dsr_fig.add_traces(
dsr_fig_left.data + dsr_fig_right.data
)

return dsr_fig


def generate_dsr_commands_fig(df: pd.DataFrame) -> px.line:
Expand All @@ -304,8 +317,8 @@ def generate_dsr_commands_fig(df: pd.DataFrame) -> px.line:
- df["Expected Gridlington Demand"]
+ (df["Real Ev Charging Power"] - df["Expected Ev Charging Power"]),
df["Real Ev Charging Power"] - df["Expected Ev Charging Power"],
],
range_y=[0, 1],
], # Will need to give these lines a label for the legend XXX
range_y=[0, 1], # Check range XXX
).update_layout(yaxis_title="MW")

return dsr_commands_fig

0 comments on commit ecc3b0c

Please sign in to comment.