You can do this crop with help astropy.io.fits, although this is not trivial yet. Since it astropy.io.fitsuses memory mapping by default , it should be able to process arbitrarily large files (within some practical limits). If you want solutions other than python, look here for details on creating postage stamps.
from astropy.io import fits
from astropy import wcs
f = fits.open('file.fits')
w = wcs.WCS(f[0].header)
newf = fits.PrimaryHDU()
newf.data = f[0].data[100:-100,100:-100]
newf.header = f[0].header
newf.header.update(w[100:-100,100:-100].to_header())
See also this pull request , which implements a convenient function Cutout2D, although it is not yet available in the released version of astrometry. Its use can be seen in the documentation modified to enable WCS:
from astropy.nddata import Cutout2D
position = (49.7, 100.1)
shape = (40, 50)
cutout = Cutout2D(f[0].data, position, shape, wcs=w)
Examples here
source
share