cluster_network: Save maps from clustering as clustermaps
This commit is contained in:
parent
8e7e3571bf
commit
78ab018b60
@ -112,7 +112,8 @@ rule cluster_network:
|
||||
output:
|
||||
network='networks/{network}_s{simpl}_{clusters}.nc',
|
||||
regions_onshore="resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson",
|
||||
regions_offshore="resources/regions_offshore_{network}_s{simpl}_{clusters}.geojson"
|
||||
regions_offshore="resources/regions_offshore_{network}_s{simpl}_{clusters}.geojson",
|
||||
clustermaps='resources/clustermaps_{network}_s{simpl}_{clusters}.h5'
|
||||
benchmark: "benchmarks/cluster_network/{network}_s{simpl}_{clusters}"
|
||||
threads: 1
|
||||
resources: mem_mb=3000
|
||||
|
@ -196,13 +196,17 @@ if __name__ == "__main__":
|
||||
|
||||
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))
|
||||
busmap = n.buses.index.to_series()
|
||||
linemap = n.lines.index.to_series()
|
||||
clustering = pypsa.networkclustering.Clustering(n, busmap, linemap, linemap, pd.Series(dtype='O'))
|
||||
else:
|
||||
clustering = clustering_for_n_clusters(n, n_clusters, aggregate_renewables)
|
||||
|
||||
clustering.network.export_to_netcdf(snakemake.output.network)
|
||||
with pd.HDFStore(snakemake.output.clustermaps, model='w') as store:
|
||||
for attr in ('busmap', 'linemap', 'linemap_positive', 'linemap_negative'):
|
||||
store.put(attr, getattr(clustering, attr), format=Table, index=False)
|
||||
|
||||
cluster_regions((clustering.busmap,))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user