remove copy_config rule and write config for each solved network
This commit is contained in:
parent
0a0a35e4a4
commit
06fa9c92da
@ -10,6 +10,9 @@ Release Notes
|
|||||||
Upcoming Release
|
Upcoming Release
|
||||||
================
|
================
|
||||||
|
|
||||||
|
* Removed rule ``copy_config``. Instead, a config file is created for each
|
||||||
|
network output of the ``solve_*`` rules, with the same content as ``n.meta``.
|
||||||
|
|
||||||
* Upgrade to Snakemake v8.5+. This version is the new minimum version required.
|
* Upgrade to Snakemake v8.5+. This version is the new minimum version required.
|
||||||
To upgrade an existing environment, run ``conda install -c bioconda
|
To upgrade an existing environment, run ``conda install -c bioconda
|
||||||
snakemake-minimal">=8.5"`` and ``pip install snakemake-storage-plugin-http``
|
snakemake-minimal">=8.5"`` and ``pip install snakemake-storage-plugin-http``
|
||||||
|
@ -171,11 +171,6 @@ Rule ``cluster_gas_network``
|
|||||||
|
|
||||||
.. automodule:: cluster_gas_network
|
.. automodule:: cluster_gas_network
|
||||||
|
|
||||||
Rule ``copy_config``
|
|
||||||
==============================================================================
|
|
||||||
|
|
||||||
.. automodule:: copy_config
|
|
||||||
|
|
||||||
Rule ``prepare_sector_network``
|
Rule ``prepare_sector_network``
|
||||||
==============================================================================
|
==============================================================================
|
||||||
|
|
||||||
|
@ -3,10 +3,6 @@
|
|||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
|
||||||
localrules:
|
|
||||||
copy_config,
|
|
||||||
|
|
||||||
|
|
||||||
if config["foresight"] != "perfect":
|
if config["foresight"] != "perfect":
|
||||||
|
|
||||||
rule plot_power_network_clustered:
|
rule plot_power_network_clustered:
|
||||||
@ -137,20 +133,6 @@ if config["foresight"] == "perfect":
|
|||||||
"../scripts/plot_power_network_perfect.py"
|
"../scripts/plot_power_network_perfect.py"
|
||||||
|
|
||||||
|
|
||||||
rule copy_config:
|
|
||||||
params:
|
|
||||||
RDIR=RDIR,
|
|
||||||
output:
|
|
||||||
RESULTS + "config.yaml",
|
|
||||||
threads: 1
|
|
||||||
resources:
|
|
||||||
mem_mb=1000,
|
|
||||||
conda:
|
|
||||||
"../envs/environment.yaml"
|
|
||||||
script:
|
|
||||||
"../scripts/copy_config.py"
|
|
||||||
|
|
||||||
|
|
||||||
rule make_summary:
|
rule make_summary:
|
||||||
params:
|
params:
|
||||||
foresight=config_provider("foresight"),
|
foresight=config_provider("foresight"),
|
||||||
|
@ -14,9 +14,9 @@ rule solve_network:
|
|||||||
custom_extra_functionality=input_custom_extra_functionality,
|
custom_extra_functionality=input_custom_extra_functionality,
|
||||||
input:
|
input:
|
||||||
network=resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"),
|
network=resources("networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc"),
|
||||||
config=RESULTS + "config.yaml",
|
|
||||||
output:
|
output:
|
||||||
network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||||
|
config=RESULTS + "configs/config.elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.yaml",
|
||||||
log:
|
log:
|
||||||
solver=normpath(
|
solver=normpath(
|
||||||
RESULTS
|
RESULTS
|
||||||
|
@ -117,10 +117,11 @@ rule solve_sector_network_myopic:
|
|||||||
network=RESULTS
|
network=RESULTS
|
||||||
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
||||||
costs=resources("costs_{planning_horizons}.csv"),
|
costs=resources("costs_{planning_horizons}.csv"),
|
||||||
config=RESULTS + "config.yaml",
|
|
||||||
output:
|
output:
|
||||||
RESULTS
|
network=RESULTS
|
||||||
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
||||||
|
config=RESULTS
|
||||||
|
+ "configs/config.elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.yaml",
|
||||||
shadow:
|
shadow:
|
||||||
"shallow"
|
"shallow"
|
||||||
log:
|
log:
|
||||||
|
@ -15,10 +15,11 @@ rule solve_sector_network:
|
|||||||
input:
|
input:
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
+ "prenetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
||||||
config=RESULTS + "config.yaml",
|
|
||||||
output:
|
output:
|
||||||
RESULTS
|
network=RESULTS
|
||||||
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
|
||||||
|
config=RESULTS
|
||||||
|
+ "configs/config.elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.yaml",
|
||||||
shadow:
|
shadow:
|
||||||
"shallow"
|
"shallow"
|
||||||
log:
|
log:
|
||||||
|
@ -107,10 +107,10 @@ rule solve_sector_network_perfect:
|
|||||||
network=RESULTS
|
network=RESULTS
|
||||||
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
|
+ "prenetworks-brownfield/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
|
||||||
costs=resources("costs_2030.csv"),
|
costs=resources("costs_2030.csv"),
|
||||||
config=RESULTS + "config.yaml",
|
|
||||||
output:
|
output:
|
||||||
RESULTS
|
network=RESULTS
|
||||||
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
|
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.nc",
|
||||||
|
config="configs/config.elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_brownfield_all_years.yaml",
|
||||||
threads: solver_threads
|
threads: solver_threads
|
||||||
resources:
|
resources:
|
||||||
mem_mb=config_provider("solving", "mem"),
|
mem_mb=config_provider("solving", "mem"),
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
"""
|
|
||||||
Copy used configuration files and important scripts for archiving.
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
import yaml
|
|
||||||
from _helpers import set_scenario_config
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
if "snakemake" not in globals():
|
|
||||||
from _helpers import mock_snakemake
|
|
||||||
|
|
||||||
snakemake = mock_snakemake("copy_config")
|
|
||||||
|
|
||||||
set_scenario_config(snakemake)
|
|
||||||
|
|
||||||
with open(snakemake.output[0], "w") as yaml_file:
|
|
||||||
yaml.dump(
|
|
||||||
snakemake.config,
|
|
||||||
yaml_file,
|
|
||||||
default_flow_style=False,
|
|
||||||
allow_unicode=True,
|
|
||||||
sort_keys=False,
|
|
||||||
)
|
|
@ -36,6 +36,7 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pypsa
|
import pypsa
|
||||||
import xarray as xr
|
import xarray as xr
|
||||||
|
import yaml
|
||||||
from _benchmark import memory_logger
|
from _benchmark import memory_logger
|
||||||
from _helpers import (
|
from _helpers import (
|
||||||
configure_logging,
|
configure_logging,
|
||||||
@ -968,4 +969,13 @@ if __name__ == "__main__":
|
|||||||
logger.info(f"Maximum memory usage: {mem.mem_usage}")
|
logger.info(f"Maximum memory usage: {mem.mem_usage}")
|
||||||
|
|
||||||
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
|
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
|
||||||
n.export_to_netcdf(snakemake.output[0])
|
n.export_to_netcdf(snakemake.output.network)
|
||||||
|
|
||||||
|
with open(snakemake.output.config, "w") as file:
|
||||||
|
yaml.dump(
|
||||||
|
n.meta,
|
||||||
|
file,
|
||||||
|
default_flow_style=False,
|
||||||
|
allow_unicode=True,
|
||||||
|
sort_keys=False,
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user