Open gbrammer opened 2 years ago
This is implemented in jwst_utils.match_gwcs_to_sip, but isn't yet run in the pipeline.
You can also use the tweakwcs
package directly with the GWCS objects for the JWST data without using SIP FITS WCS approximations at all. I.e. tweak the GWCS objects directly to get alignment.
https://tweakwcs.readthedocs.io/en/latest/index.html
The tweakwcs
package is actually what is running under-the-hood in jwst.tweakreg
.
Thanks @jdavies-st. I agree, but the reason to implement things this way in grizli with the SIP headers is so that I can make consistent WCS between HST and JWST instruments and use the same (old) low-level drizzle
code with both of them. I can generate SIP headers with forward/reverse transformations that agree with the GWCS
objects to a small fraction of a pixel, though this required a bit of extra work beyond the existing gwcs
method to generate the SIP WCS.
Cool. This might be something you can outsource to jwst.tweakreg
, as it also (after tweaking), re-fits the SIP approximation so it resembles HST data.
Or if you don't like the SIP fitting or tweaking currently in jwst.tweakreg
, you could keep it internal in grizli
and use your own SIP approximation, i.e. in grizli
use tweakwcs
to do the JWST tweaking, then do your own SIP fitting afterwards.
Btw, if you find that your SIP fitting works better (or is more reliable) than that in the JWST pipeline, then you may want to push those changes or fixes upstream to jwst
package. Would be great to get the best versions of the algorithms used consistently across both packages. 👍
Agreed. I'll look into the jwst.tweakreg
version to see if it's better than what I was testing last summer. I'm sorry to admit I generally haven't updated my jwst
module for quite some time, trying to leave well enough alone, but some of these things might be fixed by now.
The alignment scripts in
prep
now appear to work for the SIP headers generated for JWST exposures, but the alignment updates (shifts, rotation, scale) aren't propagated to the keywords that are read when running theassignWCS
pipeline step. These seem to beRA_REF
,DEC_REF
andROLL_REF / PA_V3
in theSCI
extension of the FITS files. It's not necessarily true that theREF
position is the same as the SIPCRPIX
pixel, so the shifts and rotation derived to align the SIP headers may not necessarily be the same forgwcs
, depending on the order of operations.