-
Notifications
You must be signed in to change notification settings - Fork 75
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
BUG: Cubeviz parser gives wrong sky coordinates for non-flux cube under certain condition #1991
Comments
For GWCS, Mihai suggested I look at https://gwcs.readthedocs.io/en/latest/api/gwcs.wcs.WCS.html#gwcs.wcs.WCS.available_frames though I am not optimistic those lower level attributes follow APE 14. |
>>> wcs0 = cubeviz_helper.app.data_collection[0].meta['_orig_wcs']
>>> wcs0.celestial.pixel_to_world(1, 0)
<SkyCoord (ICRS): (ra, dec) in deg
(205.43985907, 27.00341788)>
>>> wcs1 = cubeviz_helper.app.data_collection[1].coords
>>> wcs1.celestial.pixel_to_world(1, 0)
<SkyCoord (ICRS): (ra, dec) in deg
(205.4398996, 27.00345399)>
>>> wcs1.celestial.pixel_to_world(0, 1)
<SkyCoord (ICRS): (ra, dec) in deg
(205.43985907, 27.00341788)> Maybe the proper fix is to propagate |
When I change the Sky coordinates agree more or less with flux cube coordinates display, but is a bit off for uncert. |
This is what I don't understand... If you read that file made in #1991 (comment) back in: from astropy import units as u
from astropy.io import fits
from astropy.wcs import WCS
from specutils import Spectrum1D
filename = "image_cube_hdu_obj_microns.fits"
pf = fits.open(filename)
w = WCS(pf[1].header, pf)
flux = pf[1].data * u.Unit(pf[1].header['BUNIT'])
# UserWarning: Input WCS indicates that the spectral axis is not last.
# Reshaping arrays to put spectral axis last.
sp = Spectrum1D(flux=flux, wcs=w) This is the original WCS (
This is the WCS from
So when >>> w.pixel_to_world(0, 0, 1)[0].to_string('hmsdms')
'13h41m45.57590354s +27d00m12.3043716s'
>>> sp.wcs.pixel_to_world(0, 0, 1)[-1].to_string('hmsdms')
'13h41m45.56617642s +27d00m12.30437312s' |
I think I understand now, the |
This issue is tracked on JIRA as JDAT-3070. |
Comment by Pey-Lian Lim on JIRA: I have a proposed solution at #2009 |
Should probably wait till after this PR is merged before attempting to fix:
Previous failed attempt to address this problem:
Related to this headache:
Might cause more headache later:
Consider this test case:
jdaviz/jdaviz/configs/cubeviz/plugins/tests/test_parsers.py
Line 26 in 3fc9a92
jdaviz/jdaviz/conftest.py
Line 95 in 3fc9a92
Once loaded, you will see that "flux" cube has PaddedSpectrumWCS from glue-astronomy but not the "uncert" cube.
I forgot exactly what are the series of decisions but I think this was originally added in #1480 .
jdaviz/jdaviz/configs/cubeviz/plugins/parsers.py
Line 153 in 3fc9a92
In Cubeviz coordinates info display,
_orig_wcs
is favored (or moment map and also maybe because thePaddedSpectrumWCS
does not have a functioningpixel_to_world
method (as required by APE 14).Unfortunately, somewhere in the parsing (possibly by
specutils
), the WCS axes are swapped. So now we have this:As a result, assuming
(x, y, z)
input is now wrong for "uncert" (and by similar logic, "mask") cube:Proposed fix: Use
coords.celestial
component to dopixel_to_world
translation though one needs to figure out if it is always(x, y)
by definition. Also does GWCS have this component?If proposed fix does not work, will astropy/specutils#999 naturally solve this upstream?
🐱
The text was updated successfully, but these errors were encountered: