Snakefile: Force configs to be copied before solving

This reinstates old behaviour for both myopic and overnight foresight
settings.

Also account for the fact that the planning_horizon is now integer in
config.yaml rather than a string.
This commit is contained in:
Tom Brown 2020-08-11 11:41:53 +02:00
parent 16b05a570d
commit 9012125585

View File

@ -227,9 +227,6 @@ rule plot_network:
rule copy_config:
input:
networks=expand(config['results_dir'] + config['run'] + "/prenetworks_brownfield/elec_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
**config['scenario'])
output:
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
threads: 1
@ -287,7 +284,7 @@ if config["foresight"] == "overnight":
input:
network=config['results_dir'] + config['run'] + "/prenetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
costs=config['costs_dir'] + "costs_{planning_horizons}.csv",
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
output: config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc"
shadow: "shallow"
log:
@ -320,8 +317,8 @@ if config["foresight"] == "myopic":
script: "scripts/add_existing_baseyear.py"
def process_input(wildcards):
i = config["scenario"]["planning_horizons"].index(wildcards.planning_horizons)
return config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_" + config["scenario"]["planning_horizons"][i-1] + ".nc"
i = config["scenario"]["planning_horizons"].index(int(wildcards.planning_horizons))
return config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_" + str(config["scenario"]["planning_horizons"][i-1]) + ".nc"
rule add_brownfield:
@ -343,7 +340,7 @@ if config["foresight"] == "myopic":
input:
network=config['results_dir'] + config['run'] + "/prenetworks_brownfield/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc",
costs=config['costs_dir'] + "costs_{planning_horizons}.csv",
config=config['summary_dir'] + '/' + config['run'] + '/configs/config.yaml'
output: config['results_dir'] + config['run'] + "/postnetworks/{network}_s{simpl}_{clusters}_lv{lv}_{opts}_{sector_opts}_{co2_budget_name}_{planning_horizons}.nc"
shadow: "shallow"
log: