Merge pull request #689 from PyPSA/build-renewable-profiles-nprocesses
build_renewable_profile: fix execution for one thread + enable switching between tutorial and default config
This commit is contained in:
commit
134a05f6f1
@ -59,6 +59,9 @@ rule build_powerplants:
|
|||||||
|
|
||||||
|
|
||||||
rule base_network:
|
rule base_network:
|
||||||
|
params:
|
||||||
|
countries=config["countries"],
|
||||||
|
snapshots=config["snapshots"],
|
||||||
input:
|
input:
|
||||||
eg_buses="data/entsoegridkit/buses.csv",
|
eg_buses="data/entsoegridkit/buses.csv",
|
||||||
eg_lines="data/entsoegridkit/lines.csv",
|
eg_lines="data/entsoegridkit/lines.csv",
|
||||||
|
@ -19,8 +19,6 @@ if config["enable"].get("retrieve_databundle", True):
|
|||||||
datafiles.extend(["natura/Natura2000_end2015.shp", "GEBCO_2014_2D.nc"])
|
datafiles.extend(["natura/Natura2000_end2015.shp", "GEBCO_2014_2D.nc"])
|
||||||
|
|
||||||
rule retrieve_databundle:
|
rule retrieve_databundle:
|
||||||
params:
|
|
||||||
tutorial=config["tutorial"],
|
|
||||||
output:
|
output:
|
||||||
expand("data/bundle/{file}", file=datafiles),
|
expand("data/bundle/{file}", file=datafiles),
|
||||||
log:
|
log:
|
||||||
|
@ -188,7 +188,7 @@ import geopandas as gpd
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import xarray as xr
|
import xarray as xr
|
||||||
from _helpers import configure_logging
|
from _helpers import configure_logging
|
||||||
from dask.distributed import Client, LocalCluster
|
from dask.distributed import Client
|
||||||
from pypsa.geo import haversine
|
from pypsa.geo import haversine
|
||||||
from shapely.geometry import LineString
|
from shapely.geometry import LineString
|
||||||
|
|
||||||
@ -218,8 +218,7 @@ if __name__ == "__main__":
|
|||||||
logger.info(f"correction_factor is set as {correction_factor}")
|
logger.info(f"correction_factor is set as {correction_factor}")
|
||||||
|
|
||||||
if nprocesses > 1:
|
if nprocesses > 1:
|
||||||
# cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
client = Client(n_workers=nprocesses, threads_per_worker=1)
|
||||||
client = Client(n_workers=2, threads_per_worker=2, memory_limit="1GB")
|
|
||||||
else:
|
else:
|
||||||
client = None
|
client = None
|
||||||
|
|
||||||
@ -293,6 +292,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
potential = capacity_per_sqkm * availability.sum("bus") * area
|
potential = capacity_per_sqkm * availability.sum("bus") * area
|
||||||
func = getattr(cutout, resource.pop("method"))
|
func = getattr(cutout, resource.pop("method"))
|
||||||
|
if client is not None:
|
||||||
resource["dask_kwargs"] = {"scheduler": client}
|
resource["dask_kwargs"] = {"scheduler": client}
|
||||||
capacity_factor = correction_factor * func(capacity_factor=True, **resource)
|
capacity_factor = correction_factor * func(capacity_factor=True, **resource)
|
||||||
layout = capacity_factor * area * capacity_per_sqkm
|
layout = capacity_factor * area * capacity_per_sqkm
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
snakemake
|
snakemake
|
||||||
) # TODO Make logging compatible with progressbar (see PR #102)
|
) # 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"
|
url = "https://zenodo.org/record/3517921/files/pypsa-eur-tutorial-data-bundle.tar.xz"
|
||||||
else:
|
else:
|
||||||
url = "https://zenodo.org/record/3517935/files/pypsa-eur-data-bundle.tar.xz"
|
url = "https://zenodo.org/record/3517935/files/pypsa-eur-data-bundle.tar.xz"
|
||||||
|
Loading…
Reference in New Issue
Block a user