Skip to content

Commit

Permalink
add specific costs to input data tab #182
Browse files Browse the repository at this point in the history
  • Loading branch information
markushal committed Dec 12, 2023
1 parent 04a48ca commit 02fee08
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
29 changes: 27 additions & 2 deletions app/ptxboa_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def get_data_type_from_input_data(
"CAPEX",
"full load hours",
"interest rate",
"specific_costs",
],
scope: Literal[None, "world", "Argentina", "Morocco", "South Africa"],
) -> pd.DataFrame:
Expand All @@ -234,7 +235,8 @@ def get_data_type_from_input_data(
data_type : str
the data type which should be selected. Needs to be one of
"electricity_generation", "conversion_processes", "transportation_processes",
"reconversion_processes", "CAPEX", "full load hours", and "interest rate".
"reconversion_processes", "CAPEX", "full load hours", "interest rate",
and "specific costs".
scope : Literal[None, "world", "Argentina", "Morocco", "South Africa"]
The regional scope. Is automatically set to None for data of
data type "conversion_processes" and "transportation_processes" which is not
Expand All @@ -261,6 +263,15 @@ def get_data_type_from_input_data(
columns = "parameter_code"
processes = api.get_dimension("process")

if data_type == "specific_costs":
scope = None
source_region_code = [""]
index = "flow_code"
columns = "parameter_code"
processes = [""]
parameter_code = ["specific costs"]
process_code = [""]

if data_type == "electricity_generation":
parameter_code = [
"CAPEX",
Expand Down Expand Up @@ -499,6 +510,7 @@ def display_and_edit_input_data(
"reconversion_processes" "CAPEX",
"full load hours",
"interest rate",
"specific_costs",
],
scope: Literal["world", "Argentina", "Morocco", "South Africa"],
key: str,
Expand All @@ -516,7 +528,8 @@ def display_and_edit_input_data(
data_type : str
the data type which should be selected. Needs to be one of
"electricity_generation", "conversion_processes", "transportation_processes",
"reconversion_processes", "CAPEX", "full load hours", and "interest rate".
"reconversion_processes", "CAPEX", "full load hours", "interest rate",
and "specific costs".
scope : Literal[None, "world", "Argentina", "Morocco", "South Africa"]
The regional scope. Is automatically set to None for data of
data type "conversion_processes" and "transportation_processes" which is not
Expand Down Expand Up @@ -574,6 +587,13 @@ def display_and_edit_input_data(
for c in df.columns
}

if data_type == "specific_costs":
index = "flow_code"
columns = "parameter_code"
missing_index_name = None
missing_index_value = None
column_config = get_column_config()

# if editing is enabled, store modifications in session_state:
if st.session_state["edit_input_data"]:
with st.form(key=f"{key}_form"):
Expand Down Expand Up @@ -661,5 +681,10 @@ def get_column_config() -> dict:
"losses (own fuel, transport)": st.column_config.NumberColumn(
format="%.2e fraction per km", min_value=0
),
"specific costs": st.column_config.NumberColumn(
format="%.3f [various units]",
min_value=0,
help=read_markdown_file("md/helptext_columns_specific_costs.md"),
),
}
return column_config
8 changes: 8 additions & 0 deletions app/tab_input_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,11 @@ def content_input_data(api: PtxboaAPI) -> None:
scope=None,
key="input_data_editor_reconversion_processes",
)
st.markdown("**Specific costs for materials and energy carriers:**")
with st.expander("**Data**"):
display_and_edit_input_data(
api,
data_type="specific_costs",
scope=None,
key="input_data_editor_specific_costs",
)
6 changes: 6 additions & 0 deletions md/helptext_columns_specific_costs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Specific costs of CO2, water, heat and bunker fuel. The following units are used:

- CO2: USD/kgCO2
- Water: USD/kg
- Heat: USD/kWh
- Bunker fuel: USD/kWh

0 comments on commit 02fee08

Please sign in to comment.