add rule that allows cost data to be modified

This commit is contained in:
Tom Brown 2023-12-15 09:50:47 +01:00
parent 326ed63329
commit 830019a6e5
3 changed files with 28 additions and 2 deletions

View File

@ -743,9 +743,9 @@ rule prepare_sector_network:
else RESOURCES else RESOURCES
+ "biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv", + "biomass_potentials_s{simpl}_{clusters}_{planning_horizons}.csv",
heat_profile="data/heat_load_profile_BDEW.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" 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_ac=RESOURCES + "profile_offwind-ac.nc",
profile_offwind_dc=RESOURCES + "profile_offwind-dc.nc", profile_offwind_dc=RESOURCES + "profile_offwind-dc.nc",
h2_cavern=RESOURCES + "salt_cavern_potentials_s{simpl}_{clusters}.csv", h2_cavern=RESOURCES + "salt_cavern_potentials_s{simpl}_{clusters}.csv",

View File

@ -259,3 +259,17 @@ if config["enable"]["retrieve"]:
"../envs/environment.yaml" "../envs/environment.yaml"
script: script:
"../scripts/retrieve_monthly_fuel_prices.py" "../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"

View File

@ -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])