spacetelescope / stdatamodels

https://stdatamodels.readthedocs.io
Other
5 stars 25 forks source link

DOC: "Writing AsdfInFits files" does not describe where to store a GWCS object #158

Closed pllim closed 1 year ago

pllim commented 1 year ago

https://stdatamodels.readthedocs.io/en/latest/asdf_in_fits.html#writing-asdfinfits-files

This section currently does not tell me how to write out a ASDF-in-FITS file that is what I would expect JWST would use. I have a legit ImageHDU and a GWCS to go with it. I don't know how to write that out to a "ASDF in FITS" format even after reading this doc.

pllim commented 1 year ago

Particularly, I cannot find where I am supposed to stick the GWCS object in the tree in a way that an existing ASDF in FITS parser that I know works for JWST data, would work here.

braingram commented 1 year ago

For writing JWST-like files you will likely want to use an appropriate DataModel like the ImageModel https://stdatamodels.readthedocs.io/en/latest/api/jwst.datamodels.ImageModel.html#jwst.datamodels.ImageModel

pllim commented 1 year ago

Are you saying that, if I have some image HDU (that is not really JWST data) and GWCS, there is no way I can put it into ASDF in FITS? Your example does not mention where I should put the GWCS in the tree. And I thought GWCS is the whole reason why we use this?

braingram commented 1 year ago

The file format places no restriction on where the GWCS is located in the tree. If you'd like the file to be compatible with JWST tools you're better off using a DataModel.

There is no requirement to use AsdfInFits for GWCS: https://gwcs.readthedocs.io/en/latest/#save-a-wcs-object-as-a-pure-asdf-file

pllim commented 1 year ago

It's okay. I don't need the distortion, so I found an easier way to do what I wanted without GWCS, so I don't have to use this.

https://github.com/musevlt/mpdaf/blob/321cec4e95dc70c3e7eaf7402a2e3a24ebfb5b8e/lib/mpdaf/obj/coords.py#L1550