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

Where does one find rotation? #7

Open
alexw-im opened this issue Sep 27, 2023 · 3 comments
Open

Where does one find rotation? #7

alexw-im opened this issue Sep 27, 2023 · 3 comments

Comments

@alexw-im
Copy link

It looks like the Match object includes center RA and Dec but not rotation to north about the frame center. I guess that's probably provided in the attached WCS? If so, I can't find it. Any pointers where to go looking?

@aMarcireau
Copy link
Member

aMarcireau commented Sep 29, 2023

Hi @alexw-im,

The rotation is, in a sense, part of the WCS object. However, there is no simple way to extract it (to my knowledge) because Astrometry.net generates a CD matrix (details at https://docs.astropy.org/en/stable/wcs/index.html and https://arxiv.org/abs/astro-ph/0207407). In a nutshell, the CD matrix is a general linear transformation (not just scale + rotation but also shear), which makes the notion of field rotation ill-defined.

I can think of two workarounds:

  • Divide the cd matrix (which you can read with solution.best_match().astropy_wcs().wcs.cd) by the square root of its determinant, pretend that the result is roughly a rotation matrix, and calculate the rotation value with arcsin and/or arcos (https://en.wikipedia.org/wiki/Rotation_matrix).
  • Calculate the pixel coordinates of two points near the centre of the field. For a centre [ra0, dec0], the points could be [ra0 + 10 arcsec, dec0] and [ra0, dec0 + 10 arcsec]. The pixel positions of the transformed points can be used to calculate field rotation at the centre of the frame. Note that you will get a (slightly) different rotation value in other parts of the frame (unless your cd matrix has no shear).

@juanep97
Copy link

juanep97 commented Oct 2, 2023

Hi,
Once you have solved the WCS, you should be able to extract it using the wcs matrix. From https://danmoser.github.io/notes/gai_fits-imgs.html:

CD1_1 = CDELT1 * cos (CROTA2)
CD1_2 = -CDELT2 * sin (CROTA2)
CD2_1 = CDELT1 * sin (CROTA2)
CD2_2 = CDELT2 * cos (CROTA2)

The 1996 proposed FITS WCS standard used PC001001, PC001002, PC002001, and PC002002 to represent the rotation matrix but retained CDELT1 and CDELT2 for the scale. It is also read by this software, but should not be used for new WCS's.

I can confirm that the WCS produced has the PC_* keywords and you can obtain the angle with the arctan of the ratio of the values.

@juanep97
Copy link

Our you can use local_partial_pixel_derivatives to get the angle in any part of the image (probably better).

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

3 participants