Skip to content

Commit

Permalink
restructure optimization tab
Browse files Browse the repository at this point in the history
  • Loading branch information
markushal committed May 15, 2024
1 parent eeb9927 commit 5587a06
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
22 changes: 9 additions & 13 deletions app/plot_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,8 @@ def transform_time_series(
return df_sel


def create_profile_figure_generation(df_sel: pd.DataFrame) -> None:
# generation:
st.subheader("Output")
def create_profile_figure_generation(df_sel: pd.DataFrame) -> go.Figure:
"""Create generation profile figure."""
fig = go.Figure()

add_trace_to_figure(
Expand Down Expand Up @@ -632,11 +631,11 @@ def create_profile_figure_generation(df_sel: pd.DataFrame) -> None:
yaxis={"title": "output (MW)"},
)

st.plotly_chart(fig, use_container_width=True)
return fig


def create_profile_figure_soc(df_sel: pd.DataFrame) -> None:
st.subheader("Storage state of charge")
def create_profile_figure_soc(df_sel: pd.DataFrame) -> go.Figure:
"""Create storage state of charge figure."""
include_final_product_storage = st.toggle("Show final product storage", value=False)
# storage figure:
fig = go.Figure()
Expand Down Expand Up @@ -672,12 +671,11 @@ def create_profile_figure_soc(df_sel: pd.DataFrame) -> None:
yaxis={"title": "state of charge (MWh)"},
)

st.plotly_chart(fig, use_container_width=True)

return fig

def create_profile_figure_capacity_factors(df_sel: pd.DataFrame) -> None:
st.subheader("Capacity factors")

def create_profile_figure_capacity_factors(df_sel: pd.DataFrame) -> go.Figure:
"""Create capacity factors profile figure."""
fig = go.Figure()
add_trace_to_figure(
df_sel, fig, component="PV tilted", parameter="cap. factor", color="yellow"
Expand All @@ -697,7 +695,5 @@ def create_profile_figure_capacity_factors(df_sel: pd.DataFrame) -> None:
color="blue",
)
add_vertical_lines(fig)
st.plotly_chart(fig, use_container_width=True)

st.subheader("Profile data")
st.dataframe(df_sel, use_container_width=True)
return fig
32 changes: 21 additions & 11 deletions app/tab_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@


def content_optimization(api: PtxboaAPI) -> None:
st.subheader("Optimization results")
st.warning("Warning: Preliminary debugging results. ")

with st.expander("What is this?"):
st.markdown(read_markdown_file("md/whatisthis_optimization.md"))
Expand Down Expand Up @@ -46,32 +44,45 @@ def content_optimization(api: PtxboaAPI) -> None:
res_debug = calc_aggregate_statistics(n, include_debugging_output=True)
df_sel = prepare_data_for_profile_figures(n)

create_profile_figure_generation(df_sel)
with st.container(border=True):
st.subheader("Generation profiles")
fig = create_profile_figure_generation(df_sel)
st.plotly_chart(fig, use_container_width=True)

with st.expander("Aggregate statistics"):
with st.container(border=True):
st.subheader("Capacities, full load hours and costs")
st.dataframe(res.round(2), use_container_width=True)

with st.container(border=True):
st.subheader("Download model")
download_network_as_netcdf(st.session_state["network"], "network.nc")

with st.expander("Debugging output"):
st.warning(
"This output is for debugging only. It will be hidden from end users by default." # noqa
)
st.markdown("### Aggregate statistics:")
st.markdown("#### Aggregate statistics:")
st.dataframe(res_debug)

create_profile_figure_soc(df_sel)
st.markdown("#### Storage state of charge")
fig = create_profile_figure_soc(df_sel)
st.plotly_chart(fig, use_container_width=True)

st.markdown("#### Capacity factors")
fig = create_profile_figure_capacity_factors(df_sel)
st.plotly_chart(fig, use_container_width=True)

create_profile_figure_capacity_factors(df_sel)
st.markdown("#### Profile data")
st.dataframe(df_sel, use_container_width=True)

st.markdown("### Input data:")
st.markdown("#### Input data")
show_input_data(n)

else:
st.error(
f"No optimal solution! -> model status is {st.session_state['model_status']}" # noqa
)

download_network_as_netcdf(st.session_state["network"], "network.nc")


# calculate aggregate statistics:
def calc_aggregate_statistics(
Expand Down Expand Up @@ -173,7 +184,6 @@ def calc_aggregate_statistics(
"Capacity (kW)",
"Output (kWh/a)",
"Curtailment (%)",
"Full load hours before curtailment (h)",
"Full load hours (h)",
"Cost (USD/MWh)",
]
Expand Down

0 comments on commit 5587a06

Please sign in to comment.