Skip to content

Commit

Permalink
Merge pull request #352 from pz-max/improve_cutout_workflow
Browse files Browse the repository at this point in the history
Make cutout workflow simpler
  • Loading branch information
pz-max committed May 29, 2022
2 parents f676800 + 7493bbf commit e1859ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ if config["enable"].get("build_cutout", False):

rule build_cutout:
input:
regions_onshore="resources/regions_onshore.geojson",
regions_offshore="resources/regions_offshore.geojson",
onshore_shapes="resources/country_shapes.geojson",
offshore_shapes="resources/offshore_shapes.geojson",
output:
"cutouts/{cutout}.nc",
log:
Expand Down
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Upcoming Release

* Add renewable potential notebook `PR #351 <https://github.com/pypsa-meets-africa/pypsa-africa/pull/351>`

* Make cutout workflow simpler `PR #352 <https://github.com/pypsa-meets-africa/pypsa-africa/pull/352>`


PyPSA-Africa 0.0.2 (6th April 2022)
=====================================
Expand Down
7 changes: 4 additions & 3 deletions scripts/build_cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,17 @@
configure_logging(snakemake)

cutout_params = snakemake.config["atlite"]["cutouts"][snakemake.wildcards.cutout]

snapshots = pd.date_range(freq="h", **snakemake.config["snapshots"])
time = [snapshots[0], snapshots[-1]]
cutout_params["time"] = slice(*cutout_params.get("time", time))
onshore_shapes = snakemake.input.onshore_shapes
offshore_shapes = snakemake.input.offshore_shapes

# If one of the parameters is there
if {"x", "y", "bounds"}.isdisjoint(cutout_params):
# Determine the bounds from bus regions with a buffer of two grid cells
onshore = gpd.read_file(snakemake.input.regions_onshore)
offshore = gpd.read_file(snakemake.input.regions_offshore)
onshore = gpd.read_file(onshore_shapes)
offshore = gpd.read_file(offshore_shapes)
regions = onshore.append(offshore)
d = max(cutout_params.get("dx", 0.25), cutout_params.get("dy", 0.25)) * 2
cutout_params["bounds"] = regions.total_bounds + [-d, -d, d, d]
Expand Down

0 comments on commit e1859ce

Please sign in to comment.