Open cdeil opened 9 years ago
Yes - and I think this probably does not belong in imageutils. https://github.com/radio-astro-tools/spectral-cube
is the place for this, though perhaps we can factor out the spectral
part. See in particular https://github.com/radio-astro-tools/spectral-cube/blob/master/spectral_cube/spectral_cube.py#L223
I'd prefer if we put this somewhere in the Astropy core ... IMO this is general enough. (It has been (partly) re-implemented in an affiliated package for radio- and one for gamma-astronomy and none want to have the other as a dependency, right?)
I think it could go in astropy.image
or astropy.wcs
or astropy.nddata
, not sure which is best!?
OK, the very simple example you illustrated in cube_to_image
is basically already in astropy
; e.g. https://github.com/astropy/astropy/pull/2326/files#diff-d4c5b9e74c6c26000684075497033504R1879
slice = cube[:,:,0]
slicewcs = cubewcs.dropaxis(2)
projection = cube.sum(axis=0)
projwcs = cubewcs.dropaxis(0)
For more sophisticated reductions across axes, I think nddata
is the right place. But for now, since it's a 2-liner to get the WCS right for these simple operations, I'd say additional wrappers are probably not necessary.
p.s. wcs.sub
also does this. I only learned about it 2 months ago, but it is awesome.
We should add a function or functions to reduce the number of axes by slicing one plane or performing some reduction operation over some axis like
sum
ormean
.Just to illustrate what I mean, in Gammapy we have cube_to_image. @keflavich Do you have an existing function or suggestion how to implement this in a generic way?