Skip to content

Commit

Permalink
Daskify reprojection
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Sep 12, 2023
1 parent 90c8fd7 commit 939bac6
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions spectral_cube/dask_spectral_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,16 +1495,11 @@ def reproject(self, header, order='bilinear', use_memmap=False,
raise ImportError("Requires the reproject package to be"
" installed.")

reproj_kwargs = kwargs
# Need version > 0.2 to work with cubes, >= 0.5 for memmap
# Need version > 0.12 to work with dask
from distutils.version import LooseVersion
if LooseVersion(version) < "0.5":
raise Warning("Requires version >=0.5 of reproject. The current "
if LooseVersion(version) < "0.12":
raise Warning("Requires version >=0.12 of reproject. The current "
"version is: {}".format(version))
elif LooseVersion(version) >= "0.6":
pass # no additional kwargs, no warning either
else:
reproj_kwargs['independent_celestial_slices'] = True

from reproject import reproject_interp

Expand All @@ -1515,10 +1510,8 @@ def reproject(self, header, order='bilinear', use_memmap=False,
shape_out = tuple([header['NAXIS{0}'.format(i + 1)] for i in
range(header['NAXIS'])][::-1])

print(self._get_filled_data())

newcube, newcube_valid = reproject_interp((self._get_filled_data() if filled else self._data, self.header),
newwcs, shape_out=shape_out, block_size=(256, 256, 256), **kwargs
newwcs, shape_out=shape_out, block_size=(256, 256, 256), return_type='dask',
)

return self._new_cube_with(data=newcube,
Expand All @@ -1529,7 +1522,6 @@ def reproject(self, header, order='bilinear', use_memmap=False,
)



class DaskVaryingResolutionSpectralCube(DaskSpectralCubeMixin, VaryingResolutionSpectralCube):

def __init__(self, data, *args, **kwargs):
Expand Down

0 comments on commit 939bac6

Please sign in to comment.