Simple smoothing of astronomical images in FITS format

There are quite a few large astronomical data analysis packages like IRAF and CASA which offer tools for filtering and smoothing of astronomical images. These programs are sometimes quite inconvenient to use for small jobs as they come with a huge number of different modules, have their own specific syntax and architecture and also have their own interpretation of FITS files. In particular I found that importing a FITS file into CASA, doing some smoothing and re-exporting to FITS introduced enough changes to the format of to the structure of the image that I could easily continue analysis of the image outside the CASA package.

Here is a very simple alternative, based on pyfits and scipy packages for the Python programming language:

import math

def smooth(fnamein, fnameout,
    Smooth the image in the first HDU of the input file. 
    kern_px: FWHM of kernel in pxiels
    f1[0].data=scipy.ndimage.gaussian_filter(f1[0].data, kern_px/(2*math.sqrt(2*math.log(2))))

The advantages of this approach are:

blog comments powered by Disqus