On 29 November 2012 18:44, Tim Jenness <
tim.j...@gmail.com> wrote:
> AST can do it with astRebin so long as the input and output framesets are
> constructed (input just comes from the FITS header and you stack on a
> rotation). David can send you example code.
Ouch - I didn't realise it was an "age-old problem" ! This is exactly
the sort of thing AST was written for, and all Starlink apps use it in
this way. E.g. the kappa:rotate command
(
http://docs.jach.hawaii.edu/star/sun95.htx/node394.html). But you
probably don't want to to download the whole starlink software just to
rotate a FITS file.
Tim is correct that the Ast.rebin function could be used to rotate the
actual pixel values, and then you would need to correct the WCS.
Writing a complete rotation app would need an hour or two which I
don't have just at the moment. But I've written a small script that
will just correct the WCS after the rotation has been performed by
some other means:
https://gist.github.com/4171277
For example:
% rotate_wcs.py fred.fits 100 120 35
will rotate the WCS in the primary header of image "fred.fits" by 35
degrees about pixel (100,120) without changing the pixel values
themselves.
Sadly, whilst putting this together I came across a small bug in the
way pyast interacts with pyfits. I've fixed it, so to run the script
you need pyast V2.2 (available from github or pypi).
David