Skip to content

Commit

Permalink
Merge pull request #689 from PyPSA/build-renewable-profiles-nprocesses
Browse files Browse the repository at this point in the history
build_renewable_profile: fix execution for one thread + enable switching between tutorial and default config
  • Loading branch information
FabianHofmann committed Jun 30, 2023
2 parents f4847ba + 701231f commit 134a05f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
3 changes: 3 additions & 0 deletions rules/build_electricity.smk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ rule build_powerplants:


rule base_network:
params:
countries=config["countries"],
snapshots=config["snapshots"],
input:
eg_buses="data/entsoegridkit/buses.csv",
eg_lines="data/entsoegridkit/lines.csv",
Expand Down
2 changes: 0 additions & 2 deletions rules/retrieve.smk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ if config["enable"].get("retrieve_databundle", True):
datafiles.extend(["natura/Natura2000_end2015.shp", "GEBCO_2014_2D.nc"])

rule retrieve_databundle:
params:
tutorial=config["tutorial"],
output:
expand("data/bundle/{file}", file=datafiles),
log:
Expand Down
8 changes: 4 additions & 4 deletions scripts/build_renewable_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
import numpy as np
import xarray as xr
from _helpers import configure_logging
from dask.distributed import Client, LocalCluster
from dask.distributed import Client
from pypsa.geo import haversine
from shapely.geometry import LineString

Expand Down Expand Up @@ -218,8 +218,7 @@
logger.info(f"correction_factor is set as {correction_factor}")

if nprocesses > 1:
# cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
client = Client(n_workers=2, threads_per_worker=2, memory_limit="1GB")
client = Client(n_workers=nprocesses, threads_per_worker=1)
else:
client = None

Expand Down Expand Up @@ -293,7 +292,8 @@

potential = capacity_per_sqkm * availability.sum("bus") * area
func = getattr(cutout, resource.pop("method"))
resource["dask_kwargs"] = {"scheduler": client}
if client is not None:
resource["dask_kwargs"] = {"scheduler": client}
capacity_factor = correction_factor * func(capacity_factor=True, **resource)
layout = capacity_factor * area * capacity_per_sqkm
profile, capacities = func(
Expand Down
2 changes: 1 addition & 1 deletion scripts/retrieve_databundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
snakemake
) # TODO Make logging compatible with progressbar (see PR #102)

if snakemake.params.tutorial:
if snakemake.config["tutorial"]:
url = "https://zenodo.org/record/3517921/files/pypsa-eur-tutorial-data-bundle.tar.xz"
else:
url = "https://zenodo.org/record/3517935/files/pypsa-eur-data-bundle.tar.xz"
Expand Down

0 comments on commit 134a05f

Please sign in to comment.