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

View File

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

View File

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

View File

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

View File

@ -452,7 +452,7 @@ def plot_carbon_budget_distribution(input_eurostat):
ax1.set_ylim([0, 5])
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)
cts = countries.index.to_list()
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 = (
snakemake.config["results_dir"] + snakemake.config["run"] + "/graphs/"
"results/" + snakemake.params.RDIR + "/graphs/"
)
plt.savefig(path_cb_plot + "carbon_budget_plot.pdf", dpi=300)

View File

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