You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to read the HI4PI data cube with spectral_cube. When I do so, the reported data ranges are nan. Subsequently, any attempt to extract a sub-cube fails. I presume these issues are related.
SpectralCube with shape=(945, 2163, 4323) and unit=K:
n_x: 4323 type_x: GLON-CAR unit_x: deg range: nan deg: nan deg
n_y: 2163 type_y: GLAT-CAR unit_y: deg range: nan deg: nan deg
n_s: 945 type_s: VRAD unit_s: m / s range: -606648.293 m / s: 609426.638 m / s
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/spectral_cube.py:329, in BaseSpectralCube.__repr__(self)
323 else:
324 s += " and unit={0}:\n".format(self.unit)
325 s += (" n_x: {0:6d} type_x: {1:8s} unit_x: {2:5s}"
326 " range: {3:12.6f}:{4:12.6f}\n".format(self.shape[2],
327 self.wcs.wcs.ctype[0],
328 self.wcs.wcs.cunit[0],
--> 329 self.longitude_extrema[0],
330 self.longitude_extrema[1],))
331 s += (" n_y: {0:6d} type_y: {1:8s} unit_y: {2:5s}"
332 " range: {3:12.6f}:{4:12.6f}\n".format(self.shape[1],
333 self.wcs.wcs.ctype[1],
(...)
336 self.latitude_extrema[1],
337 ))
338 s += (" n_s: {0:6d} type_s: {1:8s} unit_s: {2:5s}"
339 " range: {3:12.3f}:{4:12.3f}".format(self.shape[0],
340 self.wcs.wcs.ctype[2],
(...)
343 self.spectral_extrema[1],
344 ))
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/utils.py:18, in cached.<locals>.wrapper(self, *args)
14 @wraps(func)
15 def wrapper(self, *args):
16 # The cache lives in the instance so that it gets garbage collected
17 if (func, args) not in self._cache:
---> 18 self._cache[(func, args)] = func(self, *args)
19 return self._cache[(func, args)]
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/base_class.py:298, in SpatialCoordMixinClass.longitude_extrema(self)
295 @property
296 @cached
297 def longitude_extrema(self):
--> 298 return self.world_extrema[0]
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/utils.py:18, in cached.<locals>.wrapper(self, *args)
14 @wraps(func)
15 def wrapper(self, *args):
16 # The cache lives in the instance so that it gets garbage collected
17 if (func, args) not in self._cache:
---> 18 self._cache[(func, args)] = func(self, *args)
19 return self._cache[(func, args)]
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/base_class.py:281, in SpatialCoordMixinClass.world_extrema(self)
279 latlon_corners = [self.world[y, x] for y,x in corners]
280 else:
--> 281 latlon_corners = [self.world[0, y, x][1:] for y,x in corners]
283 lon = u.Quantity([x for y,x in latlon_corners])
284 lat = u.Quantity([y for y,x in latlon_corners])
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/base_class.py:281, in <listcomp>(.0)
279 latlon_corners = [self.world[y, x] for y,x in corners]
280 else:
--> 281 latlon_corners = [self.world[0, y, x][1:] for y,x in corners]
283 lon = u.Quantity([x for y,x in latlon_corners])
284 lat = u.Quantity([y for y,x in latlon_corners])
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/cube_utils.py:250, in SliceIndexer.__getitem__(self, view)
249 def __getitem__(self, view):
--> 250 result = self._func(self._other, view)
251 if isinstance(result, da.Array):
252 result = result.compute()
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/base_class.py:219, in SpatialCoordMixinClass.world(self, view)
217 inds = np.ogrid[[slice(0, s) for s in self.shape]]
218 inds = np.broadcast_arrays(*inds)
--> 219 inds = [i[view] for i in inds[::-1]] # numpy -> wcs order
221 shp = inds[0].shape
222 inds = np.column_stack([i.ravel() for i in inds])
File ~/miniconda3/envs/astro/lib/python3.11/site-packages/spectral_cube/base_class.py:219, in <listcomp>(.0)
217 inds = np.ogrid[[slice(0, s) for s in self.shape]]
218 inds = np.broadcast_arrays(*inds)
--> 219 inds = [i[view] for i in inds[::-1]] # numpy -> wcs order
221 shp = inds[0].shape
222 inds = np.column_stack([i.ravel() for i in inds])
IndexError: index -1 is out of bounds for axis 2 with size 0
Expected Behavior
I did not expect to see a nan in the above data ranges for this data cube, and I expected to be able to successfully extract a sub-cube.
Could you check whether cube[:, 1:-1, 1:-1] is any better behaved? I'll look more closely when I'm at my computer again, but one hypothesis is that we're hitting the edges of the sky in a rectangular WCS and that's breaking assumptions somewhere
Summary
I am attempting to read the HI4PI data cube with
spectral_cube
. When I do so, the reported data ranges arenan
. Subsequently, any attempt to extract a sub-cube fails. I presume these issues are related.Example
Outputs:
Attempting to extract a sub-cube:
Raises:
Expected Behavior
I did not expect to see a
nan
in the above data ranges for this data cube, and I expected to be able to successfully extract a sub-cube.Context
Inspecting the header with
astropy
:Outputs:
astropy.WCS
seems to parse the header ok:Outputs:
The text was updated successfully, but these errors were encountered: