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

why find_optimal_celestial_wcs() always return PC coefficients with 1.0, 0.0, 1.0, 0.0 #466

Open
Eririf opened this issue Aug 26, 2024 · 4 comments

Comments

@Eririf
Copy link

Eririf commented Aug 26, 2024

I tried several images but find_optimal_celestial_wcs() keeps returning PC1_1, PC2_2 = 1.0, PC1_2, PC2_1 = 0. I want to write it to the final coadd image.

files = glob.glob(path + '*.FITS')
hdus = [fits.open(file)[0] for file in files[:]]
from reproject.mosaicking import find_optimal_celestial_wcs
wcs_out, shape_out = find_optimal_celestial_wcs(hdus, auto_rotate=True,frame='icrs')
WCSAXES =                    2 / Number of coordinate axes                      
CRPIX1  =      4169.3332638275 / Pixel coordinate of reference point            
CRPIX2  =      4087.4118749305 / Pixel coordinate of reference point            
PC1_1   =     0.99925654189794 / Coordinate transformation matrix element       
PC1_2   =    0.038553384730345 / Coordinate transformation matrix element       
PC2_1   =   -0.038553384730345 / Coordinate transformation matrix element       
PC2_2   =     0.99925654189794 / Coordinate transformation matrix element       
CDELT1  = -0.00046184030975759 / [deg] Coordinate increment at reference point  
CDELT2  =  0.00046184030975759 / [deg] Coordinate increment at reference point  
CUNIT1  = 'deg'                / Units of coordinate increment and value        
CUNIT2  = 'deg'                / Units of coordinate increment and value        
CTYPE1  = 'RA---TAN'           / Right ascension, gnomonic projection           
CTYPE2  = 'DEC--TAN'           / Declination, gnomonic projection               
CRVAL1  =      134.94692177133 / [deg] Coordinate value at reference point      
CRVAL2  =      38.095156010732 / [deg] Coordinate value at reference point      
LONPOLE =                180.0 / [deg] Native longitude of celestial pole       
LATPOLE =      38.095156010732 / [deg] Native latitude of celestial pole        
MJDREF  =                  0.0 / [d] MJD of fiducial time                       
RADESYS = 'ICRS'               / Equatorial coordinate system     
@Eririf
Copy link
Author

Eririf commented Sep 20, 2024

I suggest to change from

        # Set rotation matrix (use PC instead of CROTA2 since PC is the
        # recommended approach)
        pc = np.array([[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]])
        wcs_final.wcs.pc = pc

to

       wcs_final.wcs.pc = pc * resolution

@astrofrog
Copy link
Member

Thanks for the report! What is wrong with the header produced? It is common to use the PC matrix to represent e.g. rotation and keeping CDELT? for the scaling part of the transformation. See e.g. the following paragraph in the WCS standard (Paper 1):

image

@Cadair
Copy link
Member

Cadair commented Sep 26, 2024

by convention if you want a matrix in the header to include affine transform and scaling you would use the CD matrix.

@astrofrog
Copy link
Member

Indeed - as a side note astropy doesn't support writing that from WCS.to_header but it would be simple enough to replace CDELT/PC by CD after the fact if you wanted.

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