simplify_ and cluster_network: clustermaps to csv (#198)

* simplify and clustering: output and input from HDF format to CSV

* add release notes

* simplify and clustering: output files from Snakefile
This commit is contained in:
Martha Maria 2020-10-02 12:53:56 +02:00 committed by GitHub
parent 4d0a860246
commit 2e76b88ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 12 deletions

View File

@ -226,7 +226,7 @@ rule simplify_network:
network='networks/{network}_s{simpl}.nc',
regions_onshore="resources/regions_onshore_{network}_s{simpl}.geojson",
regions_offshore="resources/regions_offshore_{network}_s{simpl}.geojson",
clustermaps='resources/clustermaps_{network}_s{simpl}.h5'
busmap='resources/busmap_{network}_s{simpl}.csv'
log: "logs/simplify_network/{network}_s{simpl}.log"
benchmark: "benchmarks/simplify_network/{network}_s{simpl}"
threads: 1
@ -239,13 +239,14 @@ rule cluster_network:
network='networks/{network}_s{simpl}.nc',
regions_onshore="resources/regions_onshore_{network}_s{simpl}.geojson",
regions_offshore="resources/regions_offshore_{network}_s{simpl}.geojson",
clustermaps=ancient('resources/clustermaps_{network}_s{simpl}.h5'),
busmap=ancient('resources/busmap_{network}_s{simpl}.csv'),
tech_costs=COSTS
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",
clustermaps='resources/clustermaps_{network}_s{simpl}_{clusters}.h5'
busmap="resources/busmap_{network}_s{simpl}_{clusters}.csv",
linemap="resources/linemap_{network}_s{simpl}_{clusters}.csv"
log: "logs/cluster_network/{network}_s{simpl}_{clusters}.log"
benchmark: "benchmarks/cluster_network/{network}_s{simpl}_{clusters}"
threads: 1

View File

@ -35,6 +35,8 @@ Upcoming Release
* Use `mamba` (https://github.com/mamba-org/mamba) for faster Travis CI builds (`#196 <https://github.com/PyPSA/pypsa-eur/pull/196>`_)
* The mappings for clustered lines and buses produced by the ``simplify_network`` and ``cluster_network`` rules changed from Hierarchical Data Format (.h5) to Comma-Separated Values format (.csv) (`#198 <https://github.com/PyPSA/pypsa-eur/pull/198>`_)
PyPSA-Eur 0.2.0 (8th June 2020)
==================================

View File

@ -371,11 +371,7 @@ if __name__ == "__main__":
focus_weights=focus_weights)
clustering.network.export_to_netcdf(snakemake.output.network)
with pd.HDFStore(snakemake.output.clustermaps, mode='w') as store:
with pd.HDFStore(snakemake.input.clustermaps, mode='r') as clustermaps:
for attr in clustermaps.keys():
store.put(attr, clustermaps[attr], format="table", index=False)
for attr in ('busmap', 'linemap', 'linemap_positive', 'linemap_negative'):
store.put(attr, getattr(clustering, attr), format="table", index=False)
for attr in ('busmap', 'linemap'): #also available: linemap_positive, linemap_negative
getattr(clustering, attr).to_csv(snakemake.output[attr])
cluster_regions((clustering.busmap,))

View File

@ -356,8 +356,7 @@ if __name__ == "__main__":
n.export_to_netcdf(snakemake.output.network)
busemap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0])
with pd.HDFStore(snakemake.output.clustermaps, mode='w') as store:
store.put('busmap_s', busemap_s, format="table", index=False)
busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0])
busmap_s.to_csv(snakemake.output.busmap)
cluster_regions(busmaps, snakemake.input, snakemake.output)