diff --git a/envs/environment.yaml b/envs/environment.yaml index 4aefcb9a..77c4db4c 100644 --- a/envs/environment.yaml +++ b/envs/environment.yaml @@ -10,7 +10,7 @@ dependencies: - python>=3.8 - pip - - pypsa>=0.19.1 + - pypsa>=0.20 - atlite>=0.2.6 - dask diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 342b12e9..6216e3f5 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -645,4 +645,5 @@ if __name__ == "__main__": add_nice_carrier_names(n, snakemake.config) + n.meta = snakemake.config n.export_to_netcdf(snakemake.output[0]) diff --git a/scripts/add_extra_components.py b/scripts/add_extra_components.py index 287dd66e..ff64d4b0 100644 --- a/scripts/add_extra_components.py +++ b/scripts/add_extra_components.py @@ -189,7 +189,7 @@ def attach_hydrogen_pipelines(n, costs, elec_opts): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('add_extra_components', network='elec', + snakemake = mock_snakemake('add_extra_components', simpl='', clusters=5) configure_logging(snakemake) @@ -205,4 +205,5 @@ if __name__ == "__main__": add_nice_carrier_names(n, snakemake.config) + n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) n.export_to_netcdf(snakemake.output[0]) diff --git a/scripts/base_network.py b/scripts/base_network.py index 1d105225..7d616f4a 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -596,4 +596,5 @@ if __name__ == "__main__": snakemake.input.links_p_nom, snakemake.input.links_tyndp, snakemake.input.europe_shape, snakemake.input.country_shapes, snakemake.input.offshore_shapes, snakemake.input.parameter_corrections, snakemake.config) + n.meta = snakemake.config n.export_to_netcdf(snakemake.output[0]) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index bd412b7f..7efd0356 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -393,7 +393,7 @@ def plot_busmap_for_n_clusters(n, n_clusters, fn=None): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('cluster_network', network='elec', simpl='', clusters='5') + snakemake = mock_snakemake('cluster_network', simpl='', clusters='5') configure_logging(snakemake) n = pypsa.Network(snakemake.input.network) @@ -455,6 +455,7 @@ if __name__ == "__main__": update_p_nom_max(clustering.network) + clustering.network.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) clustering.network.export_to_netcdf(snakemake.output.network) for attr in ('busmap', 'linemap'): #also available: linemap_positive, linemap_negative getattr(clustering, attr).to_csv(snakemake.output[attr]) diff --git a/scripts/make_summary.py b/scripts/make_summary.py index c070d33f..622cd610 100644 --- a/scripts/make_summary.py +++ b/scripts/make_summary.py @@ -426,7 +426,7 @@ def to_csv(dfs, dir): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('make_summary', network='elec', simpl='', + snakemake = mock_snakemake('make_summary', simpl='', clusters='5', ll='copt', opts='Co2L-24H', country='all') network_dir = os.path.join('..', 'results', 'networks') else: diff --git a/scripts/plot_network.py b/scripts/plot_network.py index 71a6e627..ee311b3d 100755 --- a/scripts/plot_network.py +++ b/scripts/plot_network.py @@ -251,7 +251,7 @@ def plot_total_cost_bar(n, opts, ax=None): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('plot_network', network='elec', simpl='', + snakemake = mock_snakemake('plot_network', simpl='', clusters='5', ll='copt', opts='Co2L-24H', attr='p_nom', ext="pdf") configure_logging(snakemake) diff --git a/scripts/plot_p_nom_max.py b/scripts/plot_p_nom_max.py index e79ad274..fede1063 100644 --- a/scripts/plot_p_nom_max.py +++ b/scripts/plot_p_nom_max.py @@ -48,7 +48,7 @@ def cum_p_nom_max(net, tech, country=None): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('plot_p_nom_max', network='elec', simpl='', + snakemake = mock_snakemake('plot_p_nom_max', simpl='', techs='solar,onwind,offwind-dc', ext='png', clusts= '5,full', country= 'all') configure_logging(snakemake) diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index bc2bd30c..bae85560 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -165,7 +165,7 @@ def plot_energy(infn, config, fn=None): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('plot_summary', summary='energy', network='elec', + snakemake = mock_snakemake('plot_summary', summary='energy', simpl='', clusters=5, ll='copt', opts='Co2L-24H', attr='', ext='png', country='all') configure_logging(snakemake) diff --git a/scripts/prepare_links_p_nom.py b/scripts/prepare_links_p_nom.py index b83089d6..db493220 100644 --- a/scripts/prepare_links_p_nom.py +++ b/scripts/prepare_links_p_nom.py @@ -60,7 +60,7 @@ def extract_coordinates(s): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake #rule must be enabled in config - snakemake = mock_snakemake('prepare_links_p_nom', simpl='', network='elec') + snakemake = mock_snakemake('prepare_links_p_nom', simpl='') configure_logging(snakemake) links_p_nom = pd.read_html('https://en.wikipedia.org/wiki/List_of_HVDC_projects', header=0, match="SwePol")[0] diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index 178c6bb3..e090276d 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -212,7 +212,7 @@ def set_line_nom_max(n, s_nom_max_set=np.inf, p_nom_max_set=np.inf): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('prepare_network', network='elec', simpl='', + snakemake = mock_snakemake('prepare_network', simpl='', clusters='40', ll='v0.3', opts='Co2L-24H') configure_logging(snakemake) @@ -300,4 +300,5 @@ if __name__ == "__main__": elif "ATKc" in opts: enforce_autarky(n, only_crossborder=True) + n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) n.export_to_netcdf(snakemake.output[0]) diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 24cfc016..55f5327d 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -390,7 +390,7 @@ def cluster(n, n_clusters, config, algorithm="hac", feature=None, aggregation_st if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('simplify_network', simpl='', network='elec') + snakemake = mock_snakemake('simplify_network', simpl='f') configure_logging(snakemake) n = pypsa.Network(snakemake.input.network) @@ -447,7 +447,8 @@ if __name__ == "__main__": n.buses = n.buses.drop(buses_c, axis=1) update_p_nom_max(n) - + + n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) n.export_to_netcdf(snakemake.output.network) busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0]) diff --git a/scripts/solve_network.py b/scripts/solve_network.py index b3280a94..ea488925 100755 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -349,7 +349,7 @@ def solve_network(n, config, opts='', **kwargs): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('solve_network', network='elec', simpl='', + snakemake = mock_snakemake('solve_network', simpl='', clusters='5', ll='copt', opts='Co2L-BAU-CCL-24H') configure_logging(snakemake) @@ -365,6 +365,7 @@ if __name__ == "__main__": n = prepare_network(n, solve_opts) n = solve_network(n, snakemake.config, opts, solver_dir=tmpdir, solver_logfile=snakemake.log.solver) + n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) n.export_to_netcdf(snakemake.output[0]) logger.info("Maximum memory usage: {}".format(mem.mem_usage)) diff --git a/scripts/solve_operations_network.py b/scripts/solve_operations_network.py index 47bb713f..91015d8d 100644 --- a/scripts/solve_operations_network.py +++ b/scripts/solve_operations_network.py @@ -96,7 +96,7 @@ def set_parameters_from_optimized(n, n_optim): if __name__ == "__main__": if 'snakemake' not in globals(): from _helpers import mock_snakemake - snakemake = mock_snakemake('solve_operations_network', network='elec', + snakemake = mock_snakemake('solve_operations_network', simpl='', clusters='5', ll='copt', opts='Co2L-BAU-24H') configure_logging(snakemake) @@ -117,6 +117,7 @@ if __name__ == "__main__": n = prepare_network(n, snakemake.config['solving']['options']) n = solve_network(n, snakemake.config, opts, solver_dir=tmpdir, solver_logfile=snakemake.log.solver) + n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards))) n.export_to_netcdf(snakemake.output[0]) logger.info("Maximum memory usage: {}".format(mem.mem_usage))