reproject icon indicating copy to clipboard operation
reproject copied to clipboard

Write simple function to rotate an image so it's aligned with north

Open astrofrog opened this issue 6 years ago • 5 comments

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.

astrofrog avatar Jun 18 '19 14:06 astrofrog

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

kxxdhdn avatar Jan 28 '20 14:01 kxxdhdn

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()

pllim avatar Nov 30 '21 22:11 pllim

Yes that's correct!

astrofrog avatar Dec 01 '21 08:12 astrofrog

Is it correct to say that find_optimal_celestial_wcs does not work with GWCS?

pllim avatar Dec 01 '21 22:12 pllim

So, this is already possible right, should we close this issue?

pllim avatar Jan 26 '23 19:01 pllim