Skip to content

Commit

Permalink
add rule that allows cost data to be modified
Browse files Browse the repository at this point in the history
  • Loading branch information
nworbmot committed Dec 15, 2023
1 parent 326ed63 commit 830019a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rules/build_sector.smk
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,9 @@ rule prepare_sector_network:
else RESOURCES
+ "biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv",
heat_profile="data/heat_load_profile_BDEW.csv",
costs="data/costs_{}.csv".format(config["costs"]["year"])
costs="data/costs_{}-modified.csv".format(config["costs"]["year"])
if config["foresight"] == "overnight"
else "data/costs_{planning_horizons}.csv",
else "data/costs_{planning_horizons}-modified.csv",
profile_offwind_ac=RESOURCES + "profile_offwind-ac.nc",
profile_offwind_dc=RESOURCES + "profile_offwind-dc.nc",
h2_cavern=RESOURCES + "salt_cavern_potentials_s{simpl}_{clusters}.csv",
Expand Down
14 changes: 14 additions & 0 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,17 @@ if config["enable"]["retrieve"]:
"../envs/environment.yaml"
script:
"../scripts/retrieve_monthly_fuel_prices.py"


rule modify_cost_data:
input:
costs="data/costs_{year}.csv",
output:
"data/costs_{year}-modified.csv"
log:
LOGS + "modify_cost_data_{year}.log",
resources:
mem_mb=1000,
retries: 2
script:
"../scripts/modify_cost_data.py"
12 changes: 12 additions & 0 deletions scripts/modify_cost_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import pandas as pd

costs = pd.read_csv(snakemake.input.costs, index_col=[0, 1]).sort_index()

if "modifications" in snakemake.input.keys():
modifications = pd.read_csv(snakemake.input.modifications, index_col=[0, 1]).sort_index()
costs.loc[modifications.index] = modifications
print(modifications)
print( costs.loc[modifications.index])

costs.to_csv(snakemake.output[0])

0 comments on commit 830019a

Please sign in to comment.