Skip to content

Commit

Permalink
Allow passing specific dask distributed clients as a kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
e-koch committed Jan 5, 2024
1 parent 3faa94f commit 9acfecd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion spectral_cube/cube_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ def mosaic_cubes(cubes, spectral_block_size=100, combine_header_kwargs={},
fail_if_cube_dropped=False,
fail_if_channel_empty=True,
return_footprint=False,
client=Client(),
**kwargs):
'''
This function reprojects cubes onto a common grid and combines them to a single field.
Expand Down Expand Up @@ -963,6 +964,9 @@ def mosaic_cubes(cubes, spectral_block_size=100, combine_header_kwargs={},
If True, will raise an exception if any channels in the mosaic are empty.
return_footprint : bool
If True, will return the footprint of the mosaic. Default is False.
client : Client, optional
Pass a `dask.distributed.Client <https://distributed.dask.org/en/latest/client.html>`_ to use
Dask to parallelize operations. Default is to create the local client.
Outputs
-------
Expand Down Expand Up @@ -1108,6 +1112,11 @@ def update(self, n=1):
hdul.flush() # write to disk on each iteration
super().update(n)

# Apply a small edge taper to the weights to ensure a smooth
# transition between cubes with adjacent spatial coverage.
if taper_weight_edge and weightcubes is not None:
pass

if method == 'cube':
log_("Using Cube method")
# Cube method: Regrid the whole cube in one operation.
Expand Down Expand Up @@ -1259,7 +1268,7 @@ def two_closest_channels(cube, channel):
# theory; the previous would treat each cube in serial)
datas = [cube._get_filled_data() for cube in scubes]
wcses = [cube.wcs for cube in scubes]
with Client() as client:
with client:
datas = client.gather(datas)
hdus = list(zip(datas, wcses))

Expand Down

0 comments on commit 9acfecd

Please sign in to comment.