mirror of
https://github.com/eddyem/BTA_utils.git
synced 2025-12-06 10:45:14 +03:00
Calculate camera rotation angle relative to BTA P2 angle
Rotation
Coordinates in FITS are relative to some reference pixel location. This doesn't need to be at the center or corner of the pixel or on the image; it's just a place where we tie a coordinate on the sky to a coordinate in pixel space.
In pixel space, this location is given by CRPIX1 and CRPIX2 (in horizontal "i" and vertical "j" directions). On the sky this location is at CRVAL1 and CRVAL2 coordinates in the native image coordinate system (e.g. RA, Dec).
This reference pixel also has size (i.e. the extent of the pixel on the sky) given by CDELT1 and CDELT2.
The first step in projecting a pixel location onto the sky is to convert the pixel (i,j) coordinate to an angular scale (i.e. psuedo-degrees still on the image plane surface).
If there were no rotation, this would be simply
x' = CDELT1 * (i - CRPIX1)
y' = CDELT2 * (j - CRPIX2)
The oldest approach to dealing with rotation used a simple rotation angle, CROTA2, to indicate how much the y' axis was rotated relative to North. Therefore the true (x,y) needed for input into projection formulae was
x = x' * cos(CROTA2) - y' * sin(CROTA2)
y = x' * sin(CROTA2) + y' * cos(CROTA2)
or
x = CDELT1*(i-CRPIX1)*cos(CROTA2) - CDELT2*(j-CRPIX2)*sin(CROTA2)
y = CDELT1*(i-CRPIX1)*sin(CROTA2) + CDELT2*(j-CRPIX2)*cos(CROTA2)
This approach doesn't allow for skewed pixels, etc. and no version of it based on, for instance, CROTA1 was ever widely used (if at all).
Instead, there are two alternative approaches which recognize that the above is essentially a matrix transform. One approach replaces the above with
x = (i-CRPIX1)*CD1_1 + (j-CRPIX2)*CD1_2
y = (i-CRPIX1)*CD2_1 + (j-CRPIX2)*CD2_2
The CD matrix elements here absorb both the CDELT values and the sin()/cos() of the rotation angle.
The second approach (which is the preferred one in the standard) keeps the CDELT values distinct:
x = CDELT1*(i-CRPIX1)*PC1_1 + CDELT2*(j-CRPIX2)*PC1_2
y = CDELT1*(i-CRPIX1)*PC2_1 + CDELT2*(j-CRPIX2)*PC2_2
RA = x + CRVAL1
DEC = y + CRVAL2
In the case where the CDELT values are equal, the PC matrix is a pure rotation.
Any of these three approaches are valid (two CDELTs and CROTA2, a CD matrix, or two CDELTs and a PC matrix) though the first relies on a parameter (CROTA2) which has been deprecated in the standard (and which cannot handle skewed pixels).
Montage relies on the WCS library from SAO (Doug Mink, incorporating the work of Calabretta) and this library carefully checks for all the possible historical variations above. However, this library (and therefore Montage) does not enforce any standards but instead does its best to interpret the intent of the data supplier. However, not all software is this conscientious and some confusion may arise if certain combinations of keywords are used. Therefore care should be taken in constructing headers for Montage use.