diff --git a/config.bright.yaml b/config.bright.yaml index 45db307f..786d0577 100644 --- a/config.bright.yaml +++ b/config.bright.yaml @@ -89,6 +89,7 @@ custom_data: custom_sectors: false gas_network: false # If "True" then a custom .csv file must be placed in "resources/custom_data/pipelines.csv" , If "False" the user can choose btw "greenfield" or Model built-in datasets. Please refer to ["sector"] below. + rename_industry_carriers: {"Electricity": "electricity", "Biofuels": "solid biomass", "Heat": "low-temperature heat", "Natural Gas": "gas", "Coal": "coal", "Hydrogen": "hydrogen", "Oil": "oil"} costs: # Costs used in PyPSA-Earth-Sec. Year depends on the wildcard planning_horizon in the scenario section version: v0.6.2 diff --git a/config.default.yaml b/config.default.yaml index 304b52d8..be87a8c5 100644 --- a/config.default.yaml +++ b/config.default.yaml @@ -88,6 +88,7 @@ custom_data: custom_sectors: false gas_network: false # If "True" then a custom .csv file must be placed in "resources/custom_data/pipelines.csv" , If "False" the user can choose btw "greenfield" or Model built-in datasets. Please refer to ["sector"] below. + rename_industry_carriers: {"Electricity": "electricity", "Biofuels": "solid biomass", "Heat": "low-temperature heat", "Natural Gas": "gas", "Coal": "coal", "Hydrogen": "hydrogen", "Oil": "oil"} costs: # Costs used in PyPSA-Earth-Sec. Year depends on the wildcard planning_horizon in the scenario section version: v0.6.2 diff --git a/scripts/build_industry_demand.py b/scripts/build_industry_demand.py index 9a4e865b..d4f444f4 100644 --- a/scripts/build_industry_demand.py +++ b/scripts/build_industry_demand.py @@ -54,15 +54,25 @@ def country_to_nodal(industrial_production, keys): snakemake = mock_snakemake( "build_industry_demand", simpl="", - clusters=10, + clusters=11, planning_horizons=2030, - demand="AB", + demand="GH", ) sets_path_to_root("pypsa-earth-sec") countries = snakemake.params.countries + all_carriers = [ + "electricity", + "gas", + "coal", + "oil", + "hydrogen", + "biomass", + "heat", + ] + if snakemake.params.industry_demand: _logger.info( "Fetching custom industry demand data.. expecting file at 'data_custom/industry_demand_{0}_{1}.csv'".format( @@ -76,6 +86,9 @@ def country_to_nodal(industrial_production, keys): ), index_col=[0, 1], ) + + industry_demand = industry_demand * 1e6 # TWh -> MWh and MtCO2 to tCO2 + keys_path = snakemake.input.industrial_distribution_key dist_keys = pd.read_csv( @@ -97,6 +110,23 @@ def country_to_nodal(industrial_production, keys): nodal_df_co = nodal_production_tom_co.dot(industry_base_totals_co.T) nodal_df = pd.concat([nodal_df, nodal_df_co]) + if snakemake.config["custom_data"]["rename_industry_carriers"]: + nodal_df.rename( + columns=snakemake.config["custom_data"]["rename_industry_carriers"], + inplace=True, + ) + + missing_carriers = set(all_carriers) - set(nodal_df.columns) + if missing_carriers: + _logger.warning( + "The following carriers are missing in the industy custom data {}".format( + missing_carriers + ) + ) + + if "process emissions" not in nodal_df.columns: + _logger.warning("No process emissions added to the custom industry data") + else: no_years = int(snakemake.wildcards.planning_horizons) - int( snakemake.params.base_year @@ -277,7 +307,7 @@ def match_technology(df): "oil", "hydrogen", "biomass", - "low-temperature heat", + "heat", ] # Fill missing carriers with 0s diff --git a/test/config.test1.yaml b/test/config.test1.yaml index 388f8a44..aaf263a1 100644 --- a/test/config.test1.yaml +++ b/test/config.test1.yaml @@ -88,6 +88,7 @@ custom_data: custom_sectors: false gas_network: false # If "True" then a custom .csv file must be placed in "resources/custom_data/pipelines.csv" , If "False" the user can choose btw "greenfield" or Model built-in datasets. Please refer to ["sector"] below. + rename_industry_carriers: {"Electricity": "electricity", "Biofuels": "solid biomass", "Heat": "low-temperature heat", "Natural Gas": "gas", "Coal": "coal", "Hydrogen": "hydrogen", "Oil": "oil"} costs: # Costs used in PyPSA-Earth-Sec. Year depends on the wildcard planning_horizon in the scenario section version: v0.6.2 lifetime: 25 #default lifetime