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:
|
output:
|
||||||
network='networks/{network}_s{simpl}_{clusters}.nc',
|
network='networks/{network}_s{simpl}_{clusters}.nc',
|
||||||
regions_onshore="resources/regions_onshore_{network}_s{simpl}_{clusters}.geojson",
|
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}"
|
benchmark: "benchmarks/cluster_network/{network}_s{simpl}_{clusters}"
|
||||||
threads: 1
|
threads: 1
|
||||||
resources: mem_mb=3000
|
resources: mem_mb=3000
|
||||||
|
@ -196,13 +196,17 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
if n_clusters == len(n.buses):
|
if n_clusters == len(n.buses):
|
||||||
# Fast-path if no clustering is necessary
|
# Fast-path if no clustering is necessary
|
||||||
n.export_to_netcdf(snakemake.output.network)
|
busmap = n.buses.index.to_series()
|
||||||
for which in ('regions_onshore', 'regions_offshore'):
|
linemap = n.lines.index.to_series()
|
||||||
copyfile(getattr(snakemake.input, which),
|
clustering = pypsa.networkclustering.Clustering(n, busmap, linemap, linemap, pd.Series(dtype='O'))
|
||||||
getattr(snakemake.output, which))
|
|
||||||
else:
|
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)
|
||||||
|
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,))
|
cluster_regions((clustering.busmap,))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user