How to solve this error?…
- User
How to solve this error?
AttributeError Traceback (most recent call last) Cell In[7], line 56 53 cube = cube.with_beam(beam) 55 # Apply threshold masks ---> 56 lm = cube.with_mask(np.isfinite) 57 lm2 = cube.with_mask(lambda data: data > threshold_values[i]) 58 cube = cube.with_mask(lm).with_mask(lm2)
File ~/anaconda3/envs/phot/lib/python3.11/site-packages/spectral_cube/spectral_cube.py:1274, in BaseSpectralCube.with_mask(self, mask, inherit_mask, wcs_tolerance) 1271 else: 1272 new_mask = mask -> 1274 new_mask._validate_wcs(new_data=self._data, new_wcs=self._wcs, 1275 wcs_tolerance=wcs_tolerance or self._wcs_tolerance) 1277 return self._new_cube_with(mask=new_mask, wcs_tolerance=wcs_tolerance)
File ~/anaconda3/envs/phot/lib/python3.11/site-packages/spectral_cube/masks.py:412, in CompositeMask._validate_wcs(self, new_data, new_wcs, **kwargs) 410 def _validate_wcs(self, new_data=None, new_wcs=None, **kwargs): 411 self._mask1._validate_wcs(new_data=new_data, new_wcs=new_wcs, **kwargs) --> 412 self._mask2._validate_wcs(new_data=new_data, new_wcs=new_wcs, **kwargs)
AttributeError: 'numpy.ufunc' object has no attribute '_validate_wcs'
- Assistant
The error you're encountering occurs because you're passing
np.isfinite, which is a NumPy ufunc (universal function), directly tocube.with_mask(). The method expects a mask object that conforms to certain interface requirements, such as having a method. Since is a ufunc and doesn't have this method, it leads to the you're seeing.