Write simple function to rotate an image so it's aligned with north
It's possible to use https://github.com/astropy/reproject/blob/master/reproject/mosaicking.py#L17 to find a WCS that is north-aligned, but we could probably have a simpler function that takes a single image and a reprojection function and figures out the optimal header behind the scenes.
It's possible to use https://github.com/astropy/reproject/blob/master/reproject/mosaicking.py#L17 to find a WCS that is north-aligned, but we could probably have a simpler function that takes a single image and a reprojection function and figures out the optimal header behind the scenes.
Hello, I found that the link is now https://github.com/astropy/reproject/blob/master/docs/mosaicking.rst
Was looking for this feature... Does this look about right?
>>> from astropy.io import fits
>>> from astropy.wcs import WCS
>>> from reproject.mosaicking import find_optimal_celestial_wcs
>>> filename = 'jb5g05ubq_flt.fits' # HST/ACS image, with distortion
>>> pf = fits.open(filename)
>>> wcs_in = WCS(pf[1].header)
>>> wcs_out, shape_out = find_optimal_celestial_wcs([pf[1]])
>>> wcs_in
WCS Keywords
Number of WCS axes: 2
CTYPE : 'RA---TAN' 'DEC--TAN'
CRVAL : 3.581704851882 -30.39197867265
CRPIX : 2100.0 1024.0
CD1_1 CD1_2 : -1.14852e-05 7.01477e-06
CD2_1 CD2_2 : 7.75765e-06 1.20927e-05
NAXIS : 4096 2048
>>> wcs_out
WCS Keywords
Number of WCS axes: 2
CTYPE : 'RA---TAN' 'DEC--TAN'
CRVAL : 3.581704851882 -30.391978672649998
CRPIX : 2258.8343272203947 2068.6608808615256
PC1_1 PC1_2 : 1.0 0.0
PC2_1 PC2_2 : 0.0 1.0
CDELT : -1.385968803986944e-05 1.385968803986944e-05
NAXIS : 0 0
>>> pf[1].data.shape
(2048, 4096)
>>> shape_out
(4080, 4431)
>>> pf.close()
Yes that's correct!
Is it correct to say that find_optimal_celestial_wcs does not work with GWCS?
So, this is already possible right, should we close this issue?