def psf(aperture, wavefront, overfill=1):
"""
Transform an aperture and the wavefront to a PSF
Args:
aperture (TYPE): aperture
wavefront (TYPE): wavefront
overfill (int, optional): number of extra pixels
Returns:
real: PSF
"""
npix = len(wavefront)
nbig = npix*overfill
wfbig = numpy.zeros((nbig,nbig),dtype='d')
half = (nbig - npix)/2
wfbig[half:half+npix,half:half+npix] = wavefront
illum = numpy.zeros((nbig,nbig),dtype='d')
illum[half:half+npix,half:half+npix] = aperture
phase = numpy.exp(wfbig*(0.+1.j))
input = illum*phase
ft = numpy.fft.fft2(input)
powft = numpy.real(numpy.conj(ft)*ft)
sorted = numpy.zeros((nbig,nbig),dtype='d')
sorted[:nbig/2,:nbig/2] = powft[nbig/2:,nbig/2:]
sorted[:nbig/2,nbig/2:] = powft[nbig/2:,:nbig/2]
sorted[nbig/2:,:nbig/2] = powft[:nbig/2,nbig/2:]
sorted[nbig/2:,nbig/2:] = powft[:nbig/2,:nbig/2]
crop = sorted[half:half+npix,half:half+npix]
fluxrat = numpy.sum(crop)/numpy.sum(sorted)
# print("Cropped PSF has %.2f%% of the flux" % (100*fluxrat))
return crop
评论列表
文章目录