-
Notifications
You must be signed in to change notification settings - Fork 11
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
Incorrect transform from FITS with N image axes and N+1 World axes #11
Comments
If a FITS-WCS header defines more WCS axes than pixel axes (i.e. the header does NOT use the usual trick of defining a degenerate pixel axis that spans only one pixel) then, internally, the FitsChan class invents extra degenerate pixel axes itself and feeds them a value of 1.0 when doing the forward (pixel->sky) transformation. However, the default value for CRPIX specified in the FITS-WCS papers is 0.0, not 1.0. So it is more appropriate for FitsChan to feed missing pixel axes a value of 0.0 rather than 1.0. This commit fixes this (see issue "Incorrect transform from FITS with N image axes and N+1 World axes #11" on GitHub).
Hi @jehturner. Thanks for pointing this out. I think the problem has two parts - one in AST and one in your FITS headers.
So I think the answer is a) use AST V9.1.2 and b) set CD2_2 = 1 in your header. David |
Thanks, @dsberry; those comments have helped us understand the problem a bit better (sorry for overlooking some key details from the WCS papers). In addition to your change of default for CRPIX, I see that you have changed how the number of axes is determined, based on CRVAL rather than CRPIX. Without that change, the CD matrix was not getting included in the above AST transformation, until I added CRPIX explicitly, thus the second World co-ordinate was not just off by 1 at (the implicit) CRPIX2 -- it also was not varying with the pixel co-ordinate as it should have. Now my above example works with 9.1.2, but I think we should have defined CRPIX2 as well as CD2_2 in our header, to go with the implicit degenerate axis and define a reversible transformation fully. Since the degenerate axis has a single pixel co-ordinate of 1 and CD2_2 is now 1.0, we'll need CRPIX2=1 to avoid affecting the second World co-ordinate. This is all fine and can be made to work, but with CRPIX2 present, James. |
The change to the way the number of axes is determined only affects the code that normalises the input headers into the form expected by the rest of the FitsChan class - specifically the bit that converts a CD matrix into an equivalent PC matrix. The previous version was failing to find and convert all elements of the CD matrix. The primary determination of the number of pixel axes is still based on the presence of CRPIX headers (done at the end of function FitsToStore). If you choose to include CRPIX2 in the header then you get a 2-input Mapping. So it's then up to you to assign a suitable value to both inputs when calling astTranN. If you omit CRPIX2, then the FitsChan class effectively does what you suggest - it automatically adds an extra pixel axis internally and assigns it the constant value zero. I'm not sure this answers your question though. The point about breaking assumptions based on NAXIS was why the WCSAXES keyword was introduced. I'm trying to think of an explicit situation where the current behaviour would be problematic. |
Hi @dsberry & co.,
Our pipeline at Gemini is writing out a WCS for long-slit spectra that has axes for wavelength, RA & Dec -- ie. one more axis than the 2D image array. Obviously both RA & Dec may vary along the slit (or not), depending on its position angle, so we have both
CD2_2
&CD3_2
terms (in addition toCD1_1
for wavelength). When trying to display such an image with DS9 v8.0.1 or later (which was refactored to use AST), @chris-simpson and I have discovered that (in addition to a problem in DS9 itself) AST seems to implement the transforms described by the FITS header incorrectly, such that the 3rd World axis gets assigned a constant* value.Here is a simplified example that illustrates the same behaviour using 1 pixel axis mapping to 2 World axes, rather than 2 to 3:
The output is as follows:
It appears that the
PermMap
is assigningOut2
to a constant rather than input coordinate 1 for some reason, though I'm not very familiar with all the AST structures, which seem quite complicated.This happens with both AST 8.6.3 (used in DS9) and the latest 9.1.1. I haven't tested the latest master branch because it seems to require some Starlink versions of autotools stuff, which I'm no expert with generally, so it's not trivial to build.
*In our real-world example, I do actually see a small amount of variation in the 3rd World co-ordinate for very large pixel offsets from
CRPIX2
, but it remains almost constant for valid offsets, with thePermMap
assigning that axis to a constant in the same way as above.Am I right in thinking this is a bug / limitation, or are we doing something wrong here? Our FITS header seems valid to me.
Thanks!
James.
The text was updated successfully, but these errors were encountered: