From 1f687318078b17e76ecb4ec4ffa62e6b94afd84c Mon Sep 17 00:00:00 2001 From: Markus Haller Date: Tue, 12 Dec 2023 16:40:01 +0100 Subject: [PATCH 1/6] improve help texts for sidebar --- app/sidebar.py | 57 ++++++------------- md/helptext_sidebar_carbon_source.md | 1 + md/helptext_sidebar_cost_assumptions.md | 1 + md/helptext_sidebar_cost_unit.md | 1 + md/helptext_sidebar_data-year.md | 1 + md/helptext_sidebar_demand_country.md | 1 + md/helptext_sidebar_edit_input_data.md | 3 + md/helptext_sidebar_electrolyzer_type.md | 5 ++ ...text_sidebar_include_reconversion_to_h2.md | 1 + md/helptext_sidebar_include_subregions.md | 3 + md/helptext_sidebar_product.md | 1 + md/helptext_sidebar_re_source.md | 3 + md/helptext_sidebar_supply_region.md | 1 + md/helptext_sidebar_transport.md | 1 + md/helptext_sidebar_transport_use_own_fuel.md | 1 + md/helptext_sidebar_water_source.md | 1 + 16 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 md/helptext_sidebar_carbon_source.md create mode 100644 md/helptext_sidebar_cost_assumptions.md create mode 100644 md/helptext_sidebar_cost_unit.md create mode 100644 md/helptext_sidebar_data-year.md create mode 100644 md/helptext_sidebar_demand_country.md create mode 100644 md/helptext_sidebar_edit_input_data.md create mode 100644 md/helptext_sidebar_electrolyzer_type.md create mode 100644 md/helptext_sidebar_include_reconversion_to_h2.md create mode 100644 md/helptext_sidebar_include_subregions.md create mode 100644 md/helptext_sidebar_product.md create mode 100644 md/helptext_sidebar_re_source.md create mode 100644 md/helptext_sidebar_supply_region.md create mode 100644 md/helptext_sidebar_transport.md create mode 100644 md/helptext_sidebar_transport_use_own_fuel.md create mode 100644 md/helptext_sidebar_water_source.md diff --git a/app/sidebar.py b/app/sidebar.py index 780a8b5d..669985f9 100644 --- a/app/sidebar.py +++ b/app/sidebar.py @@ -2,7 +2,7 @@ """Sidebar creation.""" import streamlit as st -from app.ptxboa_functions import reset_user_changes +from app.ptxboa_functions import read_markdown_file, reset_user_changes from ptxboa.api import PtxboaAPI @@ -22,21 +22,12 @@ def make_sidebar(api: PtxboaAPI): st.session_state["region"] = st.sidebar.selectbox( "Supply country / region:", region_list, - help=( - "One supply country or region can be selected here, " - " and detailed settings can be selected for this region below " - "(RE source, mode of transportation). For other regions, " - "default settings will be used." - ), + help=(read_markdown_file("md/helptext_sidebar_supply_region.md")), index=region_list.get_loc("Morocco"), # Morocco as default ) st.sidebar.toggle( "Include subregions", - help=( - "For three deep-dive countries (Argentina, Morocco, and South Africa) " - "the app calculates costs for subregions as well. Activate this switch" - "if you want to chose one of these subregions as a supply region. " - ), + help=(read_markdown_file("md/helptext_sidebar_include_subregions.md")), key="include_subregions", ) @@ -44,10 +35,7 @@ def make_sidebar(api: PtxboaAPI): st.session_state["country"] = st.sidebar.selectbox( "Demand country:", countries, - help=( - "The country you aim to export to. Some key info on the demand country you " - "choose here are displayed in the info box." - ), + help=read_markdown_file("md/helptext_sidebar_demand_country.md"), index=countries.get_loc("Germany"), ) # get chain as combination of product, electrolyzer type and reconversion option: @@ -64,7 +52,7 @@ def make_sidebar(api: PtxboaAPI): "Methanol", "Ft e-fuels", ], - help="The product you want to export.", + help=read_markdown_file("md/helptext_sidebar_product.md"), index=4, # Methane as default ) with c2: @@ -75,15 +63,14 @@ def make_sidebar(api: PtxboaAPI): "PEM", "SEOC", ], - help="The electrolyzer type you wish to use.", + help=read_markdown_file("md/helptext_sidebar_electrolyzer_type.md"), index=0, # AEL as default ) if product in ["Ammonia", "Methane"]: use_reconversion = st.sidebar.toggle( "Include reconversion to H2", help=( - "If activated, account for costs of " - "reconverting product to H2 in demand country." + read_markdown_file("md/helptext_sidebar_include_reconversion_to_h2.md") ), ) else: @@ -96,11 +83,7 @@ def make_sidebar(api: PtxboaAPI): st.session_state["res_gen"] = st.sidebar.selectbox( "Renewable electricity source (for selected supply region):", api.get_dimension("res_gen").index, - help=( - "The source of electricity for the selected source country. For all " - "other countries Wind-PV hybrid systems will be used (an optimized mixture " - "of PV and wind onshore plants)" - ), + help=read_markdown_file("md/helptext_sidebar_re_source.md"), ) # get scenario as combination of year and cost assumption: @@ -110,10 +93,7 @@ def make_sidebar(api: PtxboaAPI): "Data year:", [2030, 2040], index=1, - help=( - "To cover parameter uncertainty and development over time, we provide " - "cost reduction pathways (high / medium / low) for 2030 and 2040." - ), + help=read_markdown_file("md/helptext_sidebar_data-year.md"), horizontal=True, ) with c2: @@ -121,10 +101,7 @@ def make_sidebar(api: PtxboaAPI): "Cost assumptions:", ["high", "medium", "low"], index=1, - help=( - "To cover parameter uncertainty and development over time, we provide " - "cost reduction pathways (high / medium / low) for 2030 and 2040." - ), + help=read_markdown_file("md/helptext_sidebar_cost_assumptions.md"), horizontal=True, ) st.session_state["scenario"] = f"{data_year} ({cost_scenario})" @@ -134,25 +111,25 @@ def make_sidebar(api: PtxboaAPI): "Carbon source:", api.get_dimension("secproc_co2").index, horizontal=True, - help="Help text", + help=read_markdown_file("md/helptext_sidebar_carbon_source.md"), ) st.session_state["secproc_water"] = st.sidebar.radio( "Water source:", api.get_dimension("secproc_water").index, horizontal=True, - help="Help text", + help=read_markdown_file("md/helptext_sidebar_water_source.md"), ) st.session_state["transport"] = st.sidebar.radio( "Mode of transportation (for selected supply country):", ["Ship", "Pipeline"], horizontal=True, - help="Help text", + help=read_markdown_file("md/helptext_sidebar_transport.md"), index=1, # 'Pipeline' as default ) if st.session_state["transport"] == "Ship": st.session_state["ship_own_fuel"] = st.sidebar.toggle( "For shipping option: Use the product as own fuel?", - help="Help text", + help=read_markdown_file("md/helptext_sidebar_transport_use_own_fuel.md"), ) else: st.session_state["ship_own_fuel"] = False @@ -161,15 +138,13 @@ def make_sidebar(api: PtxboaAPI): "Unit for delivered costs:", ["USD/MWh", "USD/t"], horizontal=True, - help="Help text", + help=read_markdown_file("md/helptext_sidebar_cost_unit.md"), index=1, # 'USD/t' as default ) st.sidebar.divider() st.sidebar.toggle( "Edit input data", - help="""Activate this to enable editing of input data. - -Disable this setting to reset user data to default values.""", + help=read_markdown_file("md/helptext_sidebar_edit_input_data.md"), value=False, key="edit_input_data", on_change=reset_user_changes, diff --git a/md/helptext_sidebar_carbon_source.md b/md/helptext_sidebar_carbon_source.md new file mode 100644 index 00000000..1316f7c0 --- /dev/null +++ b/md/helptext_sidebar_carbon_source.md @@ -0,0 +1 @@ +If your production process requires carbon, you can either provide it by using Direct Air Capture (DAC) or by using a carbon source with a fixed specific carbon price. diff --git a/md/helptext_sidebar_cost_assumptions.md b/md/helptext_sidebar_cost_assumptions.md new file mode 100644 index 00000000..2e1332c2 --- /dev/null +++ b/md/helptext_sidebar_cost_assumptions.md @@ -0,0 +1 @@ +To cover parameter uncertainty and development over time, we provide cost reduction pathways (high / medium / low) for 2030 and 2040. diff --git a/md/helptext_sidebar_cost_unit.md b/md/helptext_sidebar_cost_unit.md new file mode 100644 index 00000000..72933b73 --- /dev/null +++ b/md/helptext_sidebar_cost_unit.md @@ -0,0 +1 @@ +Costs are shown as USD per delivered product in target country. You can choose between energy (USD/MWh) or mass (USD/t). diff --git a/md/helptext_sidebar_data-year.md b/md/helptext_sidebar_data-year.md new file mode 100644 index 00000000..2e1332c2 --- /dev/null +++ b/md/helptext_sidebar_data-year.md @@ -0,0 +1 @@ +To cover parameter uncertainty and development over time, we provide cost reduction pathways (high / medium / low) for 2030 and 2040. diff --git a/md/helptext_sidebar_demand_country.md b/md/helptext_sidebar_demand_country.md new file mode 100644 index 00000000..2ca9d453 --- /dev/null +++ b/md/helptext_sidebar_demand_country.md @@ -0,0 +1 @@ +The country you aim to export to. You'll find a fact sheet for your chosen demand country in the **Country Fact Sheets** tab. diff --git a/md/helptext_sidebar_edit_input_data.md b/md/helptext_sidebar_edit_input_data.md new file mode 100644 index 00000000..969a4082 --- /dev/null +++ b/md/helptext_sidebar_edit_input_data.md @@ -0,0 +1,3 @@ +Activate this to enable editing of input data. If this setting is activated, you can edit the data that is shown in the **Input data** tab. + +Careful: If you disable this setting, input data will be reset to the default scenario. diff --git a/md/helptext_sidebar_electrolyzer_type.md b/md/helptext_sidebar_electrolyzer_type.md new file mode 100644 index 00000000..5bbd2782 --- /dev/null +++ b/md/helptext_sidebar_electrolyzer_type.md @@ -0,0 +1,5 @@ +Choose the electrolyzer type you want to use. There are three options: + +- AEL (Alkaline Water Electrolysis) +- PEM (Protone Exchange Membrane Electrolysis) +- SOEC (Solid Oxide Electrolysis) diff --git a/md/helptext_sidebar_include_reconversion_to_h2.md b/md/helptext_sidebar_include_reconversion_to_h2.md new file mode 100644 index 00000000..c5c2ac8f --- /dev/null +++ b/md/helptext_sidebar_include_reconversion_to_h2.md @@ -0,0 +1 @@ +If activated, the tool considers costs and conversion losses of reconverting the selected product to H2 in the demand country. diff --git a/md/helptext_sidebar_include_subregions.md b/md/helptext_sidebar_include_subregions.md new file mode 100644 index 00000000..0f616b51 --- /dev/null +++ b/md/helptext_sidebar_include_subregions.md @@ -0,0 +1,3 @@ +For three deep-dive countries (Argentina, Morocco, and South Africa) the app calculates costs for subregions as well. Activate this switch if you want to chose one of these subregions as a supply region. + +Results and input data for subregions of the deep-dive countries are displayed in the **Deep-Dive Countries** tab. diff --git a/md/helptext_sidebar_product.md b/md/helptext_sidebar_product.md new file mode 100644 index 00000000..451b90ae --- /dev/null +++ b/md/helptext_sidebar_product.md @@ -0,0 +1 @@ +The product you wnat to export. diff --git a/md/helptext_sidebar_re_source.md b/md/helptext_sidebar_re_source.md new file mode 100644 index 00000000..2a9c8524 --- /dev/null +++ b/md/helptext_sidebar_re_source.md @@ -0,0 +1,3 @@ +The source of electricity you want to use. + +This setting only applies to the **selected source region**! For all other supply regions Wind-PV hybrid systems will be used (an optimized mixture of PV and wind onshore plants). diff --git a/md/helptext_sidebar_supply_region.md b/md/helptext_sidebar_supply_region.md new file mode 100644 index 00000000..bf69d549 --- /dev/null +++ b/md/helptext_sidebar_supply_region.md @@ -0,0 +1 @@ +One supply country or region can be selected here, and detailed settings can be selected for this region below (Renewable electricity sourcea and mode of transportation). For other supply regions, default settings will be used. diff --git a/md/helptext_sidebar_transport.md b/md/helptext_sidebar_transport.md new file mode 100644 index 00000000..d5a9562d --- /dev/null +++ b/md/helptext_sidebar_transport.md @@ -0,0 +1 @@ +If the transportation distance is smaller than 6000km, you can choose pipeline transport. Ship transport is always considered possible. For other source countries than the selected one, pipeline is chosen by default if possible. diff --git a/md/helptext_sidebar_transport_use_own_fuel.md b/md/helptext_sidebar_transport_use_own_fuel.md new file mode 100644 index 00000000..961eccb9 --- /dev/null +++ b/md/helptext_sidebar_transport_use_own_fuel.md @@ -0,0 +1 @@ +Ships can either use bunker fuel (which causes fuel costs) or use the transported energy carrier as fuel (which results in efficiency losses). diff --git a/md/helptext_sidebar_water_source.md b/md/helptext_sidebar_water_source.md new file mode 100644 index 00000000..bd551cb1 --- /dev/null +++ b/md/helptext_sidebar_water_source.md @@ -0,0 +1 @@ +If your production process requires water, you can either provide it by using water desalination or by using a water source with a fixed specific water price. From 04a48caf745f3f5465efdb784e936a8484a9c5c6 Mon Sep 17 00:00:00 2001 From: Markus Haller Date: Tue, 12 Dec 2023 16:54:19 +0100 Subject: [PATCH 2/6] move column config for input parameters to dedicated function --- app/ptxboa_functions.py | 54 +++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/app/ptxboa_functions.py b/app/ptxboa_functions.py index d0799f4d..ba4c4360 100644 --- a/app/ptxboa_functions.py +++ b/app/ptxboa_functions.py @@ -540,38 +540,7 @@ def display_and_edit_input_data( columns = "parameter_code" missing_index_name = "source_region_code" missing_index_value = None - column_config = None - - if data_type in [ - "electricity_generation", - "conversion_processes", - "reconversion_processes", - ]: - column_config = { - "CAPEX": st.column_config.NumberColumn(format="%.0f USD/kW", min_value=0), - "OPEX (fix)": st.column_config.NumberColumn( - format="%.0f USD/kW", min_value=0 - ), - "efficiency": st.column_config.NumberColumn( - format="%.2f", min_value=0, max_value=1 - ), - "lifetime / amortization period": st.column_config.NumberColumn( - format="%.0f a", min_value=0 - ), - } - - if data_type == "transportation_processes": - column_config = { - "levelized costs": st.column_config.NumberColumn( - format="%.2e USD/(kW km)", min_value=0 - ), - "lifetime / amortization period": st.column_config.NumberColumn( - format="%.0f a", min_value=0 - ), - "losses (own fuel, transport)": st.column_config.NumberColumn( - format="%.2e fraction per km", min_value=0 - ), - } + column_config = get_column_config() if data_type == "interest rate": index = "source_region_code" @@ -673,3 +642,24 @@ def get_region_from_subregion(subregion: str) -> str: """ region = subregion.split(" (")[0] return region + + +def get_column_config() -> dict: + """Define column configuration for dataframe display.""" + column_config = { + "CAPEX": st.column_config.NumberColumn(format="%.0f USD/kW", min_value=0), + "OPEX (fix)": st.column_config.NumberColumn(format="%.0f USD/kW", min_value=0), + "efficiency": st.column_config.NumberColumn( + format="%.2f", min_value=0, max_value=1 + ), + "lifetime / amortization period": st.column_config.NumberColumn( + format="%.0f a", min_value=0 + ), + "levelized costs": st.column_config.NumberColumn( + format="%.2e USD/(kW km)", min_value=0 + ), + "losses (own fuel, transport)": st.column_config.NumberColumn( + format="%.2e fraction per km", min_value=0 + ), + } + return column_config From 02fee082f1ef11869ef15869c4338f76f9dfe3da Mon Sep 17 00:00:00 2001 From: Markus Haller Date: Tue, 12 Dec 2023 17:22:48 +0100 Subject: [PATCH 3/6] add specific costs to input data tab #182 --- app/ptxboa_functions.py | 29 +++++++++++++++++++++++++-- app/tab_input_data.py | 8 ++++++++ md/helptext_columns_specific_costs.md | 6 ++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 md/helptext_columns_specific_costs.md diff --git a/app/ptxboa_functions.py b/app/ptxboa_functions.py index ba4c4360..94ae115c 100644 --- a/app/ptxboa_functions.py +++ b/app/ptxboa_functions.py @@ -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: @@ -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 @@ -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", @@ -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, @@ -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 @@ -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"): @@ -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 diff --git a/app/tab_input_data.py b/app/tab_input_data.py index ab77f6bf..9482bd5a 100644 --- a/app/tab_input_data.py +++ b/app/tab_input_data.py @@ -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", + ) diff --git a/md/helptext_columns_specific_costs.md b/md/helptext_columns_specific_costs.md new file mode 100644 index 00000000..a52037ce --- /dev/null +++ b/md/helptext_columns_specific_costs.md @@ -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 From 2e0ecc326abb9878ab08e203cafcf0e52fbba4f6 Mon Sep 17 00:00:00 2001 From: Markus Haller Date: Tue, 12 Dec 2023 17:36:59 +0100 Subject: [PATCH 4/6] improve layout of input data tab --- app/tab_input_data.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/tab_input_data.py b/app/tab_input_data.py index 9482bd5a..c9c66729 100644 --- a/app/tab_input_data.py +++ b/app/tab_input_data.py @@ -76,40 +76,37 @@ def content_input_data(api: PtxboaAPI) -> None: with st.container(border=True): st.subheader("Global data") - st.markdown("**Electricity generation:**") - with st.expander("**Data**"): + with st.expander("**Electricity generation**"): display_and_edit_input_data( api, data_type="electricity_generation", scope=None, key="input_data_editor_electricity_generation", ) - st.markdown("**Electrolysis and derivate production:**") - with st.expander("**Data**"): + with st.expander("**Electrolysis and derivate production**"): display_and_edit_input_data( api, data_type="conversion_processes", scope=None, key="input_data_editor_conversion_processes", ) - st.markdown("**Transportation (ships and pipelines):**") - with st.expander("**Data**"): + with st.expander("**Transportation (ships and pipelines)**"): display_and_edit_input_data( api, data_type="transportation_processes", scope=None, key="input_data_editor_transportation_processes", ) - st.markdown("**Transportation (compression, liquefication and reconversion):**") - with st.expander("**Data**"): + with st.expander( + "**Transportation (compression, liquefication and reconversion)**" + ): display_and_edit_input_data( api, data_type="reconversion_processes", scope=None, key="input_data_editor_reconversion_processes", ) - st.markdown("**Specific costs for materials and energy carriers:**") - with st.expander("**Data**"): + with st.expander("**Specific costs for materials and energy carriers**"): display_and_edit_input_data( api, data_type="specific_costs", From 9ac33d5ffb0a43e477210d1bc279b27073cd1f48 Mon Sep 17 00:00:00 2001 From: Markus Haller Date: Tue, 12 Dec 2023 17:52:18 +0100 Subject: [PATCH 5/6] add some more help texts --- app/ptxboa_functions.py | 8 ++++++-- md/helptext_columns_lifetime.md | 3 +++ md/helptext_columns_losses.md | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 md/helptext_columns_lifetime.md create mode 100644 md/helptext_columns_losses.md diff --git a/app/ptxboa_functions.py b/app/ptxboa_functions.py index 94ae115c..40a74e68 100644 --- a/app/ptxboa_functions.py +++ b/app/ptxboa_functions.py @@ -673,13 +673,17 @@ def get_column_config() -> dict: format="%.2f", min_value=0, max_value=1 ), "lifetime / amortization period": st.column_config.NumberColumn( - format="%.0f a", min_value=0 + format="%.0f a", + min_value=0, + help=read_markdown_file("md/helptext_columns_lifetime.md"), ), "levelized costs": st.column_config.NumberColumn( format="%.2e USD/(kW km)", min_value=0 ), "losses (own fuel, transport)": st.column_config.NumberColumn( - format="%.2e fraction per km", min_value=0 + format="%.2e fraction per km", + min_value=0, + help=read_markdown_file("md/helptext_columns_losses.md"), ), "specific costs": st.column_config.NumberColumn( format="%.3f [various units]", diff --git a/md/helptext_columns_lifetime.md b/md/helptext_columns_lifetime.md new file mode 100644 index 00000000..e2d5b2ec --- /dev/null +++ b/md/helptext_columns_lifetime.md @@ -0,0 +1,3 @@ +The lifetime of a process is used (in combination with the WACC / interest rate) to distribute its capital costs across time. + +Longer lifetimes lead to lower costs per kWh delivered. diff --git a/md/helptext_columns_losses.md b/md/helptext_columns_losses.md new file mode 100644 index 00000000..c5a4a986 --- /dev/null +++ b/md/helptext_columns_losses.md @@ -0,0 +1,4 @@ +This parameter describes the share of transported energy that is lost per distance. It represents two types of losses: + +- For all transportation processes, energy is lost due to leakage. +- For ships that use the transported energy carrier as fuel, the resulting energy consumption also reduces the amount of energy that is delivered. From e0137e48a8e36a28fa5e28ae1190c3d2fefe7bc2 Mon Sep 17 00:00:00 2001 From: "j.aschauer" Date: Tue, 12 Dec 2023 18:44:36 +0100 Subject: [PATCH 6/6] add `flow_code` column to `user_data` dataframe --- app/ptxboa_functions.py | 13 +++++- app/user_data_from_file.py | 8 +++- ptxboa/api.py | 3 +- ptxboa/api_data.py | 10 ++--- tests/test_api_data.py | 22 +++++---- .../non_existent_index_user_data.csv | 45 ++++++++++--------- .../non_numeric_empty_user_data.csv | 45 ++++++++++--------- .../non_numeric_nan_user_data.csv | 45 ++++++++++--------- .../non_numeric_string_user_data.csv | 45 ++++++++++--------- .../param_above_range_user_data.csv | 45 ++++++++++--------- .../param_below_range_user_data.csv | 45 ++++++++++--------- .../too_many_columns_user_data.csv | 45 ++++++++++--------- tests/test_user_data/valid_user_data.csv | 45 ++++++++++--------- .../wrong_column_name_user_data.csv | 45 ++++++++++--------- tests/test_user_data_from_file.py | 6 +-- 15 files changed, 248 insertions(+), 219 deletions(-) diff --git a/app/ptxboa_functions.py b/app/ptxboa_functions.py index 40a74e68..4446f1b1 100644 --- a/app/ptxboa_functions.py +++ b/app/ptxboa_functions.py @@ -430,6 +430,7 @@ def display_user_changes(api): "source_region_code": "Source Region", "process_code": "Process", "parameter_code": "Parameter", + "flow_code": "Carrier/Material", "value": "Value", } ).style.format(precision=3), @@ -467,7 +468,8 @@ def register_user_changes( res = pd.DataFrame(data_list) # add missing key (the info that is not contained in the 2D table): - res[missing_index_name] = missing_index_value + if missing_index_name is not None or missing_index_value is not None: + res[missing_index_name] = missing_index_value # Replace the 'id' values with the corresponding index elements from df_tab res[index] = res[index].map(lambda x: df_tab.index[x]) @@ -478,6 +480,7 @@ def register_user_changes( "source_region_code", "process_code", "parameter_code", + "flow_code", "value", ] ) @@ -486,7 +489,13 @@ def register_user_changes( st.session_state["user_changes_df"] = pd.concat( [st.session_state["user_changes_df"], res] ).drop_duplicates( - subset=["source_region_code", "process_code", "parameter_code"], keep="last" + subset=[ + "source_region_code", + "process_code", + "parameter_code", + "flow_code", + ], + keep="last", ) diff --git a/app/user_data_from_file.py b/app/user_data_from_file.py index 39787836..4de862f3 100644 --- a/app/user_data_from_file.py +++ b/app/user_data_from_file.py @@ -132,14 +132,14 @@ def _validate_correct_index_combinations(api, scenario, result): selector = ( (input_data["parameter_code"] == row.parameter_code) & (input_data["process_code"] == row.process_code) - & (input_data["flow_code"] == "") + & (input_data["flow_code"] == row.flow_code) & (input_data["source_region_code"] == row.source_region_code) & (input_data["target_country_code"] == "") ) if len(input_data.loc[selector]) == 0: result = ( f"invalid index combination '{row.source_region_code} " - f"| {row.process_code} | {row.parameter_code}'" + f"| {row.process_code} | {row.parameter_code} | {row.flow_code}'" ) break return result @@ -150,6 +150,7 @@ def _validate_correct_column_names(result): "source_region_code", "process_code", "parameter_code", + "flow_code", "value", } if set(result.columns) != required_cols: @@ -181,6 +182,9 @@ def _validate_param_in_range(result): "lifetime / amortization period": (0, np.inf), "interest rate": (0, 1), "full load hours": (0, 8760), + "specific costs": (0, np.inf), + "losses (own fuel, transport)": (0, np.inf), + "levelized costs": (0, np.inf), } for row in result.itertuples(): p = row.parameter_code diff --git a/ptxboa/api.py b/ptxboa/api.py index 557d5932..bef674ab 100644 --- a/ptxboa/api.py +++ b/ptxboa/api.py @@ -97,7 +97,8 @@ def get_input_data( user data that overrides scenario data contains only rows of scenario_data that have been modified. ids are expected to come as long names. Needs to have the columns - ["source_region_code", "process_code", "parameter_code", "value"]. + "source_region_code", "process_code", "parameter_code", "flow_code", and + "value". Returns ------- diff --git a/ptxboa/api_data.py b/ptxboa/api_data.py index 4a819f87..2aea9e44 100644 --- a/ptxboa/api_data.py +++ b/ptxboa/api_data.py @@ -238,7 +238,8 @@ def get_input_data( used in the frontend. user_data : pd.DataFrame | None, optional user data that overrides scenario data. DataFrame needs the columns - ["source_region_code", "process_code", "parameter_code", "value"] + "source_region_code", "process_code", "parameter_code", "flow_code", and + "value". enforce_copy: bool Will always return a copy of the user data when true, when false, only returns a copy when user data is not None. When enforce_copy is False and @@ -378,10 +379,9 @@ def _update_scenario_data_with_user_data( user_data = user_data.copy().fillna("") scenario_data = scenario_data.copy() # user data from frontend only has columns - # "source_region_code", "process_code", "value" and "parameter_code", we need - # replace missing columns "flow_code" and "target_country_code" - for missing_dim in ["flow_code", "target_country_code"]: - user_data[missing_dim] = "" + # "source_region_code", "process_code", "value" and "parameter_code", and + # "flow_code" we need to replace missing column "target_country_code" + user_data["target_country_code"] = "" # user data comes with long names from frontend user_data = self._map_names_and_codes( diff --git a/tests/test_api_data.py b/tests/test_api_data.py index bbe4b8f6..093ef3c1 100644 --- a/tests/test_api_data.py +++ b/tests/test_api_data.py @@ -12,15 +12,21 @@ def user_data_01(): return pd.DataFrame( data=[ - ("Australia", "PV tilted", 800, "CAPEX"), - ("Chile", "PV tilted", 900, "CAPEX"), - ("Chile", "Wind Offshore", 5000, "full load hours"), - ("Argentina", "PV tilted", 2000, "full load hours"), - ("Costa Rica", "Wind-PV-Hybrid", 2000, "full load hours"), - ("Australia", "Wind Onshore", 4000, "full load hours"), - ("Costa Rica", None, 0.12, "interest rate"), + ("Australia", "PV tilted", 800, "CAPEX", None), + ("Chile", "PV tilted", 900, "CAPEX", None), + ("Chile", "Wind Offshore", 5000, "full load hours", None), + ("Argentina", "PV tilted", 2000, "full load hours", None), + ("Costa Rica", "Wind-PV-Hybrid", 2000, "full load hours", None), + ("Australia", "Wind Onshore", 4000, "full load hours", None), + ("Costa Rica", None, 0.12, "interest rate", None), + ], + columns=[ + "source_region_code", + "process_code", + "value", + "parameter_code", + "flow_code", ], - columns=["source_region_code", "process_code", "value", "parameter_code"], ) diff --git a/tests/test_user_data/non_existent_index_user_data.csv b/tests/test_user_data/non_existent_index_user_data.csv index 5f58b471..6494d70b 100644 --- a/tests/test_user_data/non_existent_index_user_data.csv +++ b/tests/test_user_data/non_existent_index_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -India,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +India,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/non_numeric_empty_user_data.csv b/tests/test_user_data/non_numeric_empty_user_data.csv index 800a389e..035a8834 100644 --- a/tests/test_user_data/non_numeric_empty_user_data.csv +++ b/tests/test_user_data/non_numeric_empty_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours, -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/non_numeric_nan_user_data.csv b/tests/test_user_data/non_numeric_nan_user_data.csv index cf4d5cb0..5381877d 100644 --- a/tests/test_user_data/non_numeric_nan_user_data.csv +++ b/tests/test_user_data/non_numeric_nan_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,NAN -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,NAN, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/non_numeric_string_user_data.csv b/tests/test_user_data/non_numeric_string_user_data.csv index 22b3147f..9db72d0d 100644 --- a/tests/test_user_data/non_numeric_string_user_data.csv +++ b/tests/test_user_data/non_numeric_string_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",string_entry -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",string_entry, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/param_above_range_user_data.csv b/tests/test_user_data/param_above_range_user_data.csv index c2a3b872..95b0e9fc 100644 --- a/tests/test_user_data/param_above_range_user_data.csv +++ b/tests/test_user_data/param_above_range_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,10000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,10000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/param_below_range_user_data.csv b/tests/test_user_data/param_below_range_user_data.csv index 10f6157c..081ff9b8 100644 --- a/tests/test_user_data/param_below_range_user_data.csv +++ b/tests/test_user_data/param_below_range_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),-100.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),-100.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/too_many_columns_user_data.csv b/tests/test_user_data/too_many_columns_user_data.csv index 66accd9b..fecc7e1e 100644 --- a/tests/test_user_data/too_many_columns_user_data.csv +++ b/tests/test_user_data/too_many_columns_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value,additional_column -Colombia,Wind-PV-Hybrid,CAPEX,3000.0,None -Costa Rica,PV tilted,CAPEX,2000.0,None -Spain,Wind Offshore,CAPEX,4000.0,None -Indonesia,Wind Onshore,CAPEX,100.0,None -Algeria,Wind Onshore,full load hours,4000.0,None -Egypt,PV tilted,full load hours,8760.0,None -India,Wind Offshore,full load hours,2000.0,None -Kenya,Wind-PV-Hybrid,full load hours,5000.0,None -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4,None -,Direct Air Capture,CAPEX,1000.0,None -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0,None -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0,None -,Methane Synthesis,CAPEX,300.0,None -,Methanol Synthesis,efficiency,1.0,None -,PV tilted,lifetime / amortization period,50.0,None -,Ammonia ship (own fuel consumption),levelized costs,100.0,None -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5,None -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0,None -United Arab Emirates,,interest rate,0.0001,None -Australia,,interest rate,0.9,None -Colombia,,interest rate,1.0,None +source_region_code,process_code,parameter_code,value,flow_code,additional_column +Colombia,Wind-PV-Hybrid,CAPEX,3000.0,,None +Costa Rica,PV tilted,CAPEX,2000.0,,None +Spain,Wind Offshore,CAPEX,4000.0,,None +Indonesia,Wind Onshore,CAPEX,100.0,,None +Algeria,Wind Onshore,full load hours,4000.0,,None +Egypt,PV tilted,full load hours,8760.0,,None +India,Wind Offshore,full load hours,2000.0,,None +Kenya,Wind-PV-Hybrid,full load hours,5000.0,,None +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4,,None +,Direct Air Capture,CAPEX,1000.0,,None +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0,,None +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0,,None +,Methane Synthesis,CAPEX,300.0,,None +,Methanol Synthesis,efficiency,1.0,,None +,PV tilted,lifetime / amortization period,50.0,,None +,Ammonia ship (own fuel consumption),levelized costs,100.0,,None +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5,,None +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0,,None +United Arab Emirates,,interest rate,0.0001,,None +Australia,,interest rate,0.9,,None +Colombia,,interest rate,1.0,,None +,,specific costs,0.3,heat diff --git a/tests/test_user_data/valid_user_data.csv b/tests/test_user_data/valid_user_data.csv index f44c8847..9b723a35 100644 --- a/tests/test_user_data/valid_user_data.csv +++ b/tests/test_user_data/valid_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,parameter_code,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,parameter_code,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data/wrong_column_name_user_data.csv b/tests/test_user_data/wrong_column_name_user_data.csv index 388a33f1..92b2c253 100644 --- a/tests/test_user_data/wrong_column_name_user_data.csv +++ b/tests/test_user_data/wrong_column_name_user_data.csv @@ -1,22 +1,23 @@ -source_region_code,process_code,bad_column_name,value -Colombia,Wind-PV-Hybrid,CAPEX,3000.0 -Costa Rica,PV tilted,CAPEX,2000.0 -Spain,Wind Offshore,CAPEX,4000.0 -Indonesia,Wind Onshore,CAPEX,100.0 -Algeria,Wind Onshore,full load hours,4000.0 -Egypt,PV tilted,full load hours,8760.0 -India,Wind Offshore,full load hours,2000.0 -Kenya,Wind-PV-Hybrid,full load hours,5000.0 -,Ammonia Synthesis (Haber-Bosch),efficiency,0.4 -,Direct Air Capture,CAPEX,1000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0 -,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0 -,Methane Synthesis,CAPEX,300.0 -,Methanol Synthesis,efficiency,1.0 -,PV tilted,lifetime / amortization period,50.0 -,Ammonia ship (own fuel consumption),levelized costs,100.0 -,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5 -,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0 -United Arab Emirates,,interest rate,0.0001 -Australia,,interest rate,0.9 -Colombia,,interest rate,1.0 +source_region_code,process_code,bad_column_name,value,flow_code +Colombia,Wind-PV-Hybrid,CAPEX,3000.0, +Costa Rica,PV tilted,CAPEX,2000.0, +Spain,Wind Offshore,CAPEX,4000.0, +Indonesia,Wind Onshore,CAPEX,100.0, +Algeria,Wind Onshore,full load hours,4000.0, +Egypt,PV tilted,full load hours,8760.0, +India,Wind Offshore,full load hours,2000.0, +Kenya,Wind-PV-Hybrid,full load hours,5000.0, +,Ammonia Synthesis (Haber-Bosch),efficiency,0.4, +,Direct Air Capture,CAPEX,1000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),OPEX (fix),5000.0, +,FT e-fuels Synthesis (Fischer-Tropsch),lifetime / amortization period,100.0, +,Methane Synthesis,CAPEX,300.0, +,Methanol Synthesis,efficiency,1.0, +,PV tilted,lifetime / amortization period,50.0, +,Ammonia ship (own fuel consumption),levelized costs,100.0, +,Ammonia ship (own fuel consumption),"losses (own fuel, transport)",0.5, +,Autothermal-Reactor (Blue Hydrogen),lifetime / amortization period,40.0, +United Arab Emirates,,interest rate,0.0001, +Australia,,interest rate,0.9, +Colombia,,interest rate,1.0, +,,specific costs,0.3,heat diff --git a/tests/test_user_data_from_file.py b/tests/test_user_data_from_file.py index ec5e94a4..1e6b44c2 100644 --- a/tests/test_user_data_from_file.py +++ b/tests/test_user_data_from_file.py @@ -63,15 +63,15 @@ def param_above_range_user_data() -> pd.DataFrame: ("valid_user_data", "valid_user_data"), ( "wrong_column_name_user_data", - "column names must be ['parameter_code', 'process_code', 'source_region_code', 'value']", # noqa + "column names must be ['flow_code', 'parameter_code', 'process_code', 'source_region_code', 'value']", # noqa ), ( "too_many_columns_user_data", - "column names must be ['parameter_code', 'process_code', 'source_region_code', 'value']", # noqa + "column names must be ['flow_code', 'parameter_code', 'process_code', 'source_region_code', 'value']", # noqa ), ( "non_existent_index_user_data", - "invalid index combination 'India | Ammonia Synthesis (Haber-Bosch) | efficiency'", # noqa + "invalid index combination 'India | Ammonia Synthesis (Haber-Bosch) | efficiency | '", # noqa ), ( "non_numeric_empty_user_data",