Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.mrao.cam.ac.uk/~bn204/blog/2012/04/29/simple-smoothing.html
Дата изменения: Mon Oct 5 13:04:45 2015 Дата индексирования: Sun Apr 10 12:58:33 2016 Кодировка: Поисковые слова: п п р р р р р р р р р р р р р р |
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,
kern_px):
"""
Smooth the image in the first HDU of the input file.
kern_px: FWHM of kernel in pxiels
"""
f1=pyfits.open(fnamein)
f1[0].data=scipy.ndimage.gaussian_filter(f1[0].data, kern_px/(2*math.sqrt(2*math.log(2))))
f1.writeto(fnameout)
The advantages of this approach are:
It preserves exactly the structure of the FITS file and the header
It is easy to understand exactly how the image has been processed
It integrates trivially with other Python-based processing steps