scripts/ remove summary_dir and results_dir references

This commit is contained in:
Fabian 2023-03-06 16:52:25 +01:00
parent 3e9c07b5e9
commit bffb7cc17c
6 changed files with 19 additions and 21 deletions

View File

@ -1070,6 +1070,7 @@ rule build_transport_demand:
rule prepare_sector_network: rule prepare_sector_network:
params: RDIR = RDIR
input: input:
overrides="data/override_component_attrs", overrides="data/override_component_attrs",
network='resources/' + RDIR + 'networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc', network='resources/' + RDIR + 'networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc',
@ -1138,6 +1139,7 @@ rule plot_network:
rule copy_config: rule copy_config:
params: RDIR = RDIR
output: "results/" + RDIR + 'configs/config.yaml' output: "results/" + RDIR + 'configs/config.yaml'
threads: 1 threads: 1
resources: mem_mb=1000 resources: mem_mb=1000
@ -1154,6 +1156,7 @@ rule copy_conda_env:
rule make_summary: rule make_summary:
params: RDIR = RDIR
input: input:
overrides="data/override_component_attrs", overrides="data/override_component_attrs",
networks=expand( networks=expand(
@ -1188,6 +1191,7 @@ rule make_summary:
rule plot_summary: rule plot_summary:
params: RDIR = RDIR
input: input:
costs="results/" + RDIR + 'csvs/costs.csv', costs="results/" + RDIR + 'csvs/costs.csv',
energy="results/" + RDIR + 'csvs/energy.csv', energy="results/" + RDIR + 'csvs/energy.csv',

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from shutil import copy from shutil import copy
from pathlib import Path
import yaml import yaml
@ -9,7 +10,6 @@ files = {
"Snakefile": "Snakefile", "Snakefile": "Snakefile",
"scripts/solve_network.py": "solve_network.py", "scripts/solve_network.py": "solve_network.py",
"scripts/prepare_sector_network.py": "prepare_sector_network.py", "scripts/prepare_sector_network.py": "prepare_sector_network.py",
"../pypsa-eur/config.yaml": "config.pypsaeur.yaml",
} }
if __name__ == "__main__": if __name__ == "__main__":
@ -18,14 +18,12 @@ if __name__ == "__main__":
snakemake = mock_snakemake("copy_config") snakemake = mock_snakemake("copy_config")
basepath = ( basepath = Path(f"results/{snakemake.params.RDIR}configs/")
snakemake.config["summary_dir"] + "/" + snakemake.config["run"] + "/configs/"
)
for f, name in files.items(): for f, name in files.items():
copy(f, basepath + name) copy(f, basepath / name)
with open(basepath + "config.snakemake.yaml", "w") as yaml_file: with open(basepath / "config.snakemake.yaml", "w") as yaml_file:
yaml.dump( yaml.dump(
snakemake.config, snakemake.config,
yaml_file, yaml_file,

View File

@ -676,10 +676,9 @@ if __name__ == "__main__":
logging.basicConfig(level=snakemake.config["logging"]["level"]) logging.basicConfig(level=snakemake.config["logging"]["level"])
networks_dict = { networks_dict = {
(cluster, lv, opt + sector_opt, planning_horizon): snakemake.config[ (cluster, lv, opt + sector_opt, planning_horizon):
"results_dir" "results/"
] + snakemake.params.RDIR
+ snakemake.config["run"]
+ f"/postnetworks/elec_s{simpl}_{cluster}_lv{lv}_{opt}_{sector_opt}_{planning_horizon}.nc" + f"/postnetworks/elec_s{simpl}_{cluster}_lv{lv}_{opt}_{sector_opt}_{planning_horizon}.nc"
for simpl in snakemake.config["scenario"]["simpl"] for simpl in snakemake.config["scenario"]["simpl"]
for cluster in snakemake.config["scenario"]["clusters"] for cluster in snakemake.config["scenario"]["clusters"]
@ -706,8 +705,5 @@ if __name__ == "__main__":
if snakemake.config["foresight"] == "myopic": if snakemake.config["foresight"] == "myopic":
cumulative_cost = calculate_cumulative_cost() cumulative_cost = calculate_cumulative_cost()
cumulative_cost.to_csv( cumulative_cost.to_csv(
snakemake.config["summary_dir"] f"results" + snakemake.params.RDIR + "/csvs/cumulative_cost.csv"
+ "/"
+ snakemake.config["run"]
+ "/csvs/cumulative_cost.csv"
) )

View File

@ -892,9 +892,9 @@ def plot_series(network, carrier="AC", name="test"):
fig.tight_layout() fig.tight_layout()
fig.savefig( fig.savefig(
"{}{}/maps/series-{}-{}-{}-{}-{}.pdf".format( "{}/{RDIR}maps/series-{}-{}-{}-{}-{}.pdf".format(
snakemake.config["results_dir"], "results",
snakemake.config["run"], snakemake.params.RDIR,
snakemake.wildcards["lv"], snakemake.wildcards["lv"],
carrier, carrier,
start, start,

View File

@ -452,7 +452,7 @@ def plot_carbon_budget_distribution(input_eurostat):
ax1.set_ylim([0, 5]) ax1.set_ylim([0, 5])
ax1.set_xlim([1990, snakemake.config["scenario"]["planning_horizons"][-1] + 1]) ax1.set_xlim([1990, snakemake.config["scenario"]["planning_horizons"][-1] + 1])
path_cb = snakemake.config["results_dir"] + snakemake.config["run"] + "/csvs/" path_cb = "results/" + snakemake.params.RDIR + "/csvs/"
countries = pd.read_csv(snakemake.input.country_codes, index_col=1) countries = pd.read_csv(snakemake.input.country_codes, index_col=1)
cts = countries.index.to_list() cts = countries.index.to_list()
e_1990 = co2_emissions_year(cts, input_eurostat, opts, year=1990) e_1990 = co2_emissions_year(cts, input_eurostat, opts, year=1990)
@ -532,7 +532,7 @@ def plot_carbon_budget_distribution(input_eurostat):
) )
path_cb_plot = ( path_cb_plot = (
snakemake.config["results_dir"] + snakemake.config["run"] + "/graphs/" "results/" + snakemake.params.RDIR + "/graphs/"
) )
plt.savefig(path_cb_plot + "carbon_budget_plot.pdf", dpi=300) plt.savefig(path_cb_plot + "carbon_budget_plot.pdf", dpi=300)

View File

@ -3344,8 +3344,8 @@ if __name__ == "__main__":
continue continue
limit_type = "carbon budget" limit_type = "carbon budget"
fn = ( fn = (
snakemake.config["results_dir"] "results/"
+ snakemake.config["run"] + snakemake.params.RDIR
+ "/csvs/carbon_budget_distribution.csv" + "/csvs/carbon_budget_distribution.csv"
) )
if not os.path.exists(fn): if not os.path.exists(fn):