Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wingechr/issue400 #433

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/context_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import streamlit as st


@st.cache_data()
@st.cache_data(show_spinner=False)
def load_context_data():
"""Import context data from excel file."""
filename = "data/context_data.xlsx"
Expand Down
2 changes: 1 addition & 1 deletion app/ptxboa_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ptxboa.utils import is_test


@st.cache_data
@st.cache_data(show_spinner=False)
def calculate_results_single(
_api: PtxboaAPI,
settings: dict,
Expand Down
89 changes: 45 additions & 44 deletions ptxboa_streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,47 +157,17 @@
"Deep-dive countries",
"Optimization",
]:
# calculate results over different data dimensions:
costs_per_region = calculate_results_list(
api, parameter_to_change="region", parameter_list=None
)
costs_per_scenario = calculate_results_list(
api,
parameter_to_change="scenario",
parameter_list=None,
)
costs_per_res_gen = calculate_results_list(
api,
parameter_to_change="res_gen",
# TODO: here we remove PV tracking manually, this needs to be fixed in data
parameter_list=[
x
for x in api.get_dimension("res_gen").index.to_list()
if x != "PV tracking"
],
)
costs_per_chain = calculate_results_list(
api,
parameter_to_change="chain",
parameter_list=None,
override_session_state={"output_unit": "USD/MWh"},
)

if st.session_state["user_changes_df"] is not None:
# calculate results over different data dimensions (without user changes):
costs_per_region_without_user_changes = calculate_results_list(
api,
parameter_to_change="region",
parameter_list=None,
apply_user_data=False,
with st.spinner("Please wait. Running optimization model..."):
joAschauer marked this conversation as resolved.
Show resolved Hide resolved
# calculate results over different data dimensions:
costs_per_region = calculate_results_list(
api, parameter_to_change="region", parameter_list=None
)
costs_per_scenario_without_user_changes = calculate_results_list(
costs_per_scenario = calculate_results_list(
api,
parameter_to_change="scenario",
parameter_list=None,
apply_user_data=False,
)
costs_per_res_gen_without_user_changes = calculate_results_list(
costs_per_res_gen = calculate_results_list(
api,
parameter_to_change="res_gen",
# TODO: here we remove PV tracking manually, this needs to be fixed in data
Expand All @@ -206,20 +176,51 @@
for x in api.get_dimension("res_gen").index.to_list()
if x != "PV tracking"
],
apply_user_data=False,
)
costs_per_chain_without_user_changes = calculate_results_list(
costs_per_chain = calculate_results_list(
api,
parameter_to_change="chain",
parameter_list=None,
override_session_state={"output_unit": "USD/MWh"},
apply_user_data=False,
)
else:
costs_per_region_without_user_changes = None
costs_per_scenario_without_user_changes = None
costs_per_res_gen_without_user_changes = None
costs_per_chain_without_user_changes = None

if st.session_state["user_changes_df"] is not None:
# calculate results over different data dimensions (without user changes):
costs_per_region_without_user_changes = calculate_results_list(
api,
parameter_to_change="region",
parameter_list=None,
apply_user_data=False,
)
costs_per_scenario_without_user_changes = calculate_results_list(
api,
parameter_to_change="scenario",
parameter_list=None,
apply_user_data=False,
)
costs_per_res_gen_without_user_changes = calculate_results_list(
api,
parameter_to_change="res_gen",
# TODO: here we remove PV tracking manually, needs to be fixed in data
parameter_list=[
x
for x in api.get_dimension("res_gen").index.to_list()
if x != "PV tracking"
],
apply_user_data=False,
)
costs_per_chain_without_user_changes = calculate_results_list(
api,
parameter_to_change="chain",
parameter_list=None,
override_session_state={"output_unit": "USD/MWh"},
apply_user_data=False,
)
else:
costs_per_region_without_user_changes = None
costs_per_scenario_without_user_changes = None
costs_per_res_gen_without_user_changes = None
costs_per_chain_without_user_changes = None

if st.session_state[st.session_state["tab_key"]] in [
"Market scanning",
Expand Down
Loading