cluster_network: Add fast-path for when no clustering is necessary
This commit is contained in:
parent
77172f18dc
commit
8e7e3571bf
@ -14,6 +14,7 @@ import xarray as xr
|
|||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
import shapely
|
import shapely
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
|
from shutil import copyfile
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
from six.moves import reduce
|
from six.moves import reduce
|
||||||
@ -193,6 +194,13 @@ if __name__ == "__main__":
|
|||||||
n_clusters = int(snakemake.wildcards.clusters)
|
n_clusters = int(snakemake.wildcards.clusters)
|
||||||
aggregate_renewables = True
|
aggregate_renewables = True
|
||||||
|
|
||||||
|
if n_clusters == len(n.buses):
|
||||||
|
# Fast-path if no clustering is necessary
|
||||||
|
n.export_to_netcdf(snakemake.output.network)
|
||||||
|
for which in ('regions_onshore', 'regions_offshore'):
|
||||||
|
copyfile(getattr(snakemake.input, which),
|
||||||
|
getattr(snakemake.output, which))
|
||||||
|
else:
|
||||||
clustering = clustering_for_n_clusters(n, n_clusters, aggregate_renewables)
|
clustering = clustering_for_n_clusters(n, n_clusters, aggregate_renewables)
|
||||||
|
|
||||||
clustering.network.export_to_netcdf(snakemake.output.network)
|
clustering.network.export_to_netcdf(snakemake.output.network)
|
||||||
|
Loading…
Reference in New Issue
Block a user