Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapsed shape from cube is very confusing #921

Open
pllim opened this issue Feb 9, 2022 · 0 comments
Open

Collapsed shape from cube is very confusing #921

pllim opened this issue Feb 9, 2022 · 0 comments

Comments

@pllim
Copy link
Member

pllim commented Feb 9, 2022

Consider this use case:

>>> import numpy as np
>>> from astropy import units as u
>>> from astropy.wcs import WCS
>>> from specutils import Spectrum1D
>>> wcs = WCS(naxis=3)
>>> wcs.wcs.ctype = 'RA---TAN', 'DEC--TAN', 'FREQ'
>>> wcs.wcs.set()
>>> sp = Spectrum1D(flux=np.ones((3, 4, 5)) * u.nJy, wcs=wcs)  # spectral, y, x
WARNING:specutils.spectra.spectrum1d:Input WCS indicates that the
spectral axis is not last. Reshaping arrays to put spectral axis last.
>>> sp.shape  # x, y, spectral
(5, 4, 3)
>>> collapsed_spec = sp.collapse('sum', axis=-1)
>>> collapsed_spec.shape
(5, 4)  # x, y
>>> collapsed_spec.T.shape  # y, x
(4, 5)

Expectation: Collapsed shape should be (y, x).

Reality: It becomes (x, y). As a result, I need to transpose the collapsed result to get the spatial image in the correct shape.

xref spacetelescope/jdaviz#1006

cc @rosteen @javerbukh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant