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

How to use PaddedSpectrumWCS on 3D cube? #75

Open
pllim opened this issue Aug 16, 2022 · 2 comments
Open

How to use PaddedSpectrumWCS on 3D cube? #75

pllim opened this issue Aug 16, 2022 · 2 comments

Comments

@pllim
Copy link
Contributor

pllim commented Aug 16, 2022

I have a 3D WCS but all I care about is to translate the spatial WCS (i.e., given a SkyCoord, I want X and Y pixel positions). I don't care about the spectral axis. In Cubeviz, the translator encodes the WCS as PaddedSpectrumWCS but I cannot figure out how to use it to grab just the spatial WCS object. I want to pass this spatial WCS to the to_pixel method in a regions shape.

This is as far as I got:

from astropy.wcs import WCS
from specutils import Spectrum1D

from glue_astronomy.translators.spectrum1d import PaddedSpectrumWCS

flux = np.arange(16).reshape((2, 2, 4)) * u.Jy
wcs_dict = {"CTYPE1": "RA---TAN", "CTYPE2": "DEC--TAN", "CTYPE3": "WAVE",
            "CRVAL1": 205, "CRVAL2": 27, "CRVAL3": 1,
            "CDELT1": -0.0001, "CDELT2": 0.0001, "CDELT3": 8e-11,
            "CRPIX1": 0, "CRPIX2": 0, "CRPIX3": 0}
w = WCS(wcs_dict)

sp = Spectrum1D(flux=flux, wcs=w)

coords = PaddedSpectrumWCS(sp.wcs, sp.flux.ndim)

What should I do after this? Any ideas, @astrofrog or @dhomeier ?

@dhomeier
Copy link
Contributor

Is this issue still open? If I understand right, you'd need the original w.celestial or sp.wcs.celestial to pass to shape.to_pixel(wcs), but all you have is the coords after transformation to PaddedSpectrumWCS)?

@pllim
Copy link
Contributor Author

pllim commented Mar 28, 2023

I ended up storing the original WCS somewhere hacky and not use PaddedSpectrumWCS at all. So this is still a problem. Would be nice if we can get rid of this altogether and use something more conventional.

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

No branches or pull requests

2 participants