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

Read a GWCS object from a FITS file #136

Open
nden opened this issue Mar 12, 2018 · 13 comments
Open

Read a GWCS object from a FITS file #136

nden opened this issue Mar 12, 2018 · 13 comments

Comments

@nden
Copy link
Collaborator

nden commented Mar 12, 2018

Something like this (in a function or method):

from asdf.fits_embed import AsdfInFits

fa = AsdfInFits.open('miri_assign_wcs.fits')
wcsobj = fa.tree['meta']['wcs']
data = fa.tree['data']

@pllim

@pllim
Copy link
Contributor

pllim commented Mar 12, 2018

That would be useful, thanks! Is this a general standard or specific to JWST?

@nden
Copy link
Collaborator Author

nden commented Mar 12, 2018

This is JWST. We should link the WCS from the top object so you can do

wcsobj = fa.tree['wcs']

Also I thought @drdavella had a PR where it was possible to omit tree so fa.data would work but I may be misremembering as this does not work.

@drdavella
Copy link
Collaborator

@nden maybe you're thinking about doing fa['data'] instead of fa.tree['data']?

@nden
Copy link
Collaborator Author

nden commented Mar 12, 2018

@drdavella
Ah, you are right. I am confusing it with the JWST syntax where the dict can be accessed with ..

@pllim
Copy link
Contributor

pllim commented Mar 12, 2018

I wonder if it is worth the trouble to alias fa['WCS'] to fa['wcs']. WCS is an acronym, but in this case, it raises KeyError because the key is case-sensitive.

@nden
Copy link
Collaborator Author

nden commented Mar 12, 2018

I'm 👎 on aliasing. It's a key in a dictionary and it's defined to be lower case. An alias is too confusing. What about astropy where the WCS class has a wcs attribute - WCS.wcs.

@pllim
Copy link
Contributor

pllim commented Mar 12, 2018

So... fa['wcs'] (using ASDF 2.0.dev) gives me a TaggedDict. How do I convert this to GWCS object? Attempt to gwcs.WCS(fa['wcs']) gives me TypeError.

p.s. gwcs.WCS(fa['wcs']['steps']) gives me KeyError.

p.p.s. Using GWCS dev + ASDF dev + Astropy dev combo gives me AttributeError even at fa['wcs']). Dan said he'll look into it.

@nden
Copy link
Collaborator Author

nden commented Mar 13, 2018

Just for clarification, you don't need to convert to GWCS object.
This sounds to me like mismatched versions. Will investigate locally.

@pllim
Copy link
Contributor

pllim commented Mar 13, 2018

@drdavella says there is a small bug in Astropy (maybe he can link the PR when he has it).

@nden , don't I need a WCS object to do these things -- http://gwcs.readthedocs.io/en/latest/gwcs/using_wcs.html ? How am I supposed to do a "sky2pix" and "pix2sky" with TaggedDict?

@nden
Copy link
Collaborator Author

nden commented Mar 13, 2018

You are supposed to get a GWCS object back, not a TaggedDict. I can't reproduce this problem that's why I think it's a configuration issue.

@pllim
Copy link
Contributor

pllim commented Mar 13, 2018

For the record, here is a log of my attempt. And no, I don't have jwst installed.

https://gist.github.com/pllim/a1c0097daef479a5bec848aea9889d33

@nden
Copy link
Collaborator Author

nden commented Mar 14, 2018

Some of the transforms which define the JWST WCS are in the jwst package. Since you don't have it installed, asdf returns the raw data in a dict.
This will be a general problem with ginga, not limited to jwst, any package that defines its own transforms will run into this problem when using ginga.

@stscijgbot
Copy link

This ticket is now being tracked at AL-45

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

4 participants