PL
unread,Oct 20, 2011, 2:48:30 PM10/20/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to astropy-dev
"""
Simpler version of `PSF_GAUSSIAN` in IDL.
:Authors: Pey Lian Lim (Python)
:Organization: Space Telescope Science Institute
:History:
* 2010/08/17 PLL converted from IDL to Python.
"""
# External modules
import numpy
#-----------
def GaussPsf2D(npix, fwhm, normalize=True):
"""
Parameters
----------
npix: int
Number of pixels for each dimension.
Just one number to make all sizes equal.
fwhm: float
FWHM (pixels) in each dimension.
Single number to make all the same.
normalize: bool, optional
Normalized so total PSF is 1.
Returns
-------
psf: array_like
Gaussian point spread function.
"""
# Initialize PSF params
cntrd = (npix - 1.0) * 0.5
st_dev = 0.5 * fwhm / numpy.sqrt( 2.0 * numpy.log(2) )
# Make PSF
i = range(npix)
psf = numpy.array( [numpy.exp(-(((cntrd-x)/st_dev)**2+((cntrd-y)/
st_dev)**2)/2) for x in i for y in i] )
psf = psf.reshape(npix, npix)
# Normalize
if normalize: psf /= psf.sum()
return psf