Ran into an issue when trying to work with a primary beam file in spectral-cube. File was imported as follows:
import glob
from spectral_cube import SpectralCube
pb_fn = glob.glob(f"primary_beam.pb") # any .pb file
pb = SpectralCube.read(pb_fn[0], format = 'casa_image')
Running pb.unit gives a blank cell, confirming that that cube is unitless. However, trying to mask above a certain primary beam level yields an error.
mask = pb > 0.8
ValueError Traceback (most recent call last)
<ipython-input-26-6ec680c9e817> in <module>()
----> 1 mask = pb > 0.8
/blue/adamginsburg/abulatek/spectral-cube/spectral_cube/spectral_cube.py in __gt__(self, value)
2235 The threshold
2236 """
-> 2237 value = self._val_to_own_unit(value)
2238 return LazyComparisonMask(operator.gt, value, data=self._data, wcs=self._wcs)
2239
/blue/adamginsburg/abulatek/spectral-cube/spectral_cube/spectral_cube.py in _val_to_own_unit(self, value, operation, tofrom, keepunit)
2224 " SpectralCubes or Quantities with "
2225 "a unit attribute."
-> 2226 .format(operation=operation, tofrom=tofrom))
2227
2228 def __gt__(self, value):
ValueError: Can only compare cube objects to SpectralCubes or Quantities with a unit attribute.
Since pb.unit is dimensionless, this should work. What we have to do instead is:
Ran into an issue when trying to work with a primary beam file in
spectral-cube
. File was imported as follows:Running
pb.unit
gives a blank cell, confirming that that cube is unitless. However, trying to mask above a certain primary beam level yields an error.Since
pb.unit
is dimensionless, this should work. What we have to do instead is: