radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
96 stars 63 forks source link

Dask problem: no dispatch for Lazy Masks #909

Open keflavich opened 4 months ago

keflavich commented 4 months ago
Traceback (most recent call last):
  File "/orange/adamginsburg/ACES/reduction_ACES/aces/analysis/giantcube_cuts.py", line 123, in <module>
    signal_mask = ndmorph.binary_dilation(signal_mask, structure=np.ones([3, 3, 3]), iterations=1)
  File "/orange/adamginsburg/miniconda3/envs/python39/lib/python3.9/site-packages/dask_image/ndmorph/__init__.py", line 57, in binary_dilation
    dispatch_binary_dilation(image),
  File "/orange/adamginsburg/miniconda3/envs/python39/lib/python3.9/site-packages/dask_image/dispatch/_dispatcher.py", line 23, in __call__
    meth = self.dispatch(datatype)
  File "/orange/adamginsburg/miniconda3/envs/python39/lib/python3.9/site-packages/dask/utils.py", line 635, in dispatch
    raise TypeError(f"No dispatch for {cls}")
TypeError: No dispatch for <class 'spectral_cube.masks.LazyComparisonMask'>

Unfortunately, it looks like this means mask dilation/erosion can only be done on already-computed masks without some extra work. @astrofrog any ideas on what we need to add to mask objects to make them play nice with dask?

keflavich commented 4 months ago

signal_mask.include() is likely all that is needed here; I'll give this a day or two before I decide it's just user error on my part, though maybe we want to have dask utilities default to using the include result