build_renewable_profiles: use LocalCluster instance
This commit is contained in:
parent
743fdea874
commit
75f9719076
@ -189,7 +189,7 @@ import logging
|
||||
from pypsa.geo import haversine
|
||||
from shapely.geometry import LineString
|
||||
import time
|
||||
from dask.distributed import Client
|
||||
from dask.distributed import Client, LocalCluster
|
||||
|
||||
from _helpers import configure_logging
|
||||
|
||||
@ -217,8 +217,9 @@ if __name__ == '__main__':
|
||||
if correction_factor != 1.:
|
||||
logger.info(f'correction_factor is set as {correction_factor}')
|
||||
|
||||
client = Client(n_workers=nprocesses)
|
||||
|
||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||
client = Client(cluster, asynchronous=True)
|
||||
|
||||
cutout = atlite.Cutout(snakemake.input['cutout'])
|
||||
regions = gpd.read_file(snakemake.input.regions).set_index('name').rename_axis('bus')
|
||||
buses = regions.index
|
||||
@ -268,7 +269,7 @@ if __name__ == '__main__':
|
||||
|
||||
potential = capacity_per_sqkm * availability.sum('bus') * area
|
||||
func = getattr(cutout, resource.pop('method'))
|
||||
# resource['dask_kwargs'] = {'num_workers': nprocesses, "scheduler": "threading"}
|
||||
resource['dask_kwargs'] = {"scheduler": client}
|
||||
capacity_factor = correction_factor * func(capacity_factor=True, **resource)
|
||||
layout = capacity_factor * area * capacity_per_sqkm
|
||||
profile, capacities = func(matrix=availability.stack(spatial=['y','x']),
|
||||
|
Loading…
Reference in New Issue
Block a user