/* File : jitter.c * * Contents : * Compute_jitter : Convolve PSF with a jitter function * * Author : John Krist (STScI) * Date : January 1992 */ #include #include #include "tinytim.h" /*--------------------------------------------------------------------- * Compute_jitter : * Convolve the PSF with a jitter function. * * Inputs : * Crit_psf : Complex array containing critically sampled PSF. * dim : dimension of Crit_psf (dim x dim). * wavelength : wavelength of PSF in microns. * jitter : RMS jitter in milliarceconds. * *----------------------------------------------------------------------*/ void Compute_jitter( complex **crit_psf, int dim, float wavelength, float jitter ) { float c, v, radius, dist, dist_sqr[4096], y_sqr; int x, y; /* Create a lookup table of distances. The table is shifted * * to account for the shifting of the OTF. This essentially * * creates a jitter function shifted to (0,0). */ radius = dim / 2; for ( x = 0; x < dim/2; ++x ) { dist = x / radius; dist_sqr[x] = dist * dist; } for ( x = dim / 2; x < dim; ++x ) { dist = (dim - x) / radius; dist_sqr[x] = dist * dist; } /* Multiply the OTF (FFT of PSF) by the jitter function */ c = M_PI * jitter * 4.848e-9 * DIAM_HST_MICRONS / wavelength; for ( y = 0; y < dim; ++y ) { y_sqr = dist_sqr[y]; for ( x = 0; x < dim; ++x ) { v = sqrt(dist_sqr[x] + y_sqr) * c; v = exp( -2.0 * v * v ); crit_psf[y][x].r *= v; crit_psf[y][x].i *= 0.0; } } } /* Compute_jitter */