Skip to content

Commit

Permalink
Merge pull request #332 from pypsa-meets-earth/Params_build_base_ener…
Browse files Browse the repository at this point in the history
…gy_totals

Add Params to Rule build_base_energy_totals
  • Loading branch information
energyLS authored Jun 12, 2024
2 parents 22f56ba + 20a2b46 commit e937d6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ rule prepare_heat_data:


rule build_base_energy_totals:
params:
space_heat_share=config["sector"]["space_heat_share"],
update_data=config["demand_data"]["update_data"],
base_year=config["demand_data"]["base_year"],
countries=config["countries"],
input:
unsd_paths="data/demand/unsd/paths/Energy_Statistics_Database.xlsx",
output:
Expand Down
14 changes: 7 additions & 7 deletions scripts/build_base_energy_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ def calc_sector(sector):
round(
df_sector[df_sector.Commodity.isin(heat)].Quantity_TWh.sum(), 4
)
* snakemake.config["sector"]["space_heat_share"]
* snakemake.params.space_heat_share
)
energy_totals_base.at[country, "total residential water"] = round(
df_sector[df_sector.Commodity.isin(heat)].Quantity_TWh.sum(), 4
) * (1 - snakemake.config["sector"]["space_heat_share"])
) * (1 - snakemake.params.space_heat_share)

elif sector == "services":
energy_totals_base.at[country, "services electricity"] = round(
Expand All @@ -166,11 +166,11 @@ def calc_sector(sector):
round(
df_sector[df_sector.Commodity.isin(heat)].Quantity_TWh.sum(), 4
)
* snakemake.config["sector"]["space_heat_share"]
* snakemake.params.space_heat_share
)
energy_totals_base.at[country, "total services water"] = round(
df_sector[df_sector.Commodity.isin(heat)].Quantity_TWh.sum(), 4
) * (1 - snakemake.config["sector"]["space_heat_share"])
) * (1 - snakemake.params.space_heat_share)

elif sector == "road":
energy_totals_base.at[country, "total road"] = round(
Expand Down Expand Up @@ -273,7 +273,7 @@ def calc_sector(sector):
df = df.to_dict("dict")
d = df["Link"]

if snakemake.config["demand_data"]["update_data"]:
if snakemake.params.update_data:
# Delete and existing files to avoid duplication and double counting

files = glob.glob("data/demand/unsd/data/*.txt")
Expand Down Expand Up @@ -363,8 +363,8 @@ def calc_sector(sector):
}

# Fetch country list and demand base year from the config file
year = snakemake.config["demand_data"]["base_year"]
countries = snakemake.config["countries"]
year = snakemake.params.base_year
countries = snakemake.params.countries
# countries = ["NG", "BJ"]

# Filter for the year and country
Expand Down

0 comments on commit e937d6c

Please sign in to comment.