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

Small fix in custom industry data #372

Merged
merged 5 commits into from
Sep 17, 2024
Merged
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
1 change: 1 addition & 0 deletions config.bright.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
@@ -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
36 changes: 33 additions & 3 deletions scripts/build_industry_demand.py
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/config.test1.yaml
Original file line number Diff line number Diff line change
@@ -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