Skip to content

Commit

Permalink
Merge pull request #712 from PyPSA/harmonize-result-stucture
Browse files Browse the repository at this point in the history
harmonize output of solving rules
  • Loading branch information
fneum authored Aug 3, 2023
2 parents 9687fef + 1bf6ea1 commit 8ae568d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 34 deletions.
18 changes: 1 addition & 17 deletions rules/postprocess.smk
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ rule copy_config:
params:
RDIR=RDIR,
output:
RESULTS + "config/config.yaml",
RESULTS + "config.yaml",
threads: 1
resources:
mem_mb=1000,
Expand All @@ -51,22 +51,6 @@ rule copy_config:
"../scripts/copy_config.py"


rule copy_conda_env:
output:
RESULTS + "config/environment.yaml",
threads: 1
resources:
mem_mb=500,
log:
LOGS + "copy_conda_env.log",
benchmark:
BENCHMARKS + "copy_conda_env"
conda:
"../envs/environment.yaml"
shell:
"conda env export -f {output} --no-builds"


rule make_summary:
params:
foresight=config["foresight"],
Expand Down
1 change: 1 addition & 0 deletions rules/solve_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rule solve_network:
),
input:
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
config=RESULTS + "config.yaml",
output:
network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
log:
Expand Down
2 changes: 1 addition & 1 deletion rules/solve_myopic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ rule solve_sector_network_myopic:
network=RESULTS
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
costs="data/costs_{planning_horizons}.csv",
config=RESULTS + "config/config.yaml",
config=RESULTS + "config.yaml",
output:
RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
Expand Down
4 changes: 1 addition & 3 deletions rules/solve_overnight.smk
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ rule solve_sector_network:
input:
network=RESULTS
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
costs="data/costs_{}.csv".format(config["costs"]["year"]),
config=RESULTS + "config/config.yaml",
#env=RDIR + 'config/environment.yaml',
config=RESULTS + "config.yaml",
output:
RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
Expand Down
14 changes: 1 addition & 13 deletions scripts/copy_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,13 @@

import yaml

files = {
"config/config.yaml": "config.yaml",
"Snakefile": "Snakefile",
"scripts/solve_network.py": "solve_network.py",
"scripts/prepare_sector_network.py": "prepare_sector_network.py",
}

if __name__ == "__main__":
if "snakemake" not in globals():
from _helpers import mock_snakemake

snakemake = mock_snakemake("copy_config")

basepath = Path(f"results/{snakemake.params.RDIR}config/")

for f, name in files.items():
copy(f, basepath / name)

with open(basepath / "config.snakemake.yaml", "w") as yaml_file:
with open(snakemake.output[0], "w") as yaml_file:
yaml.dump(
snakemake.config,
yaml_file,
Expand Down

0 comments on commit 8ae568d

Please sign in to comment.