def psf(array_shape=(256, 256), dx=1., lam_over_diam=2., defocus=0., astig1=0., astig2=0., coma1=0., coma2=0., trefoil1=0., trefoil2=0., spher=0., circular_pupil=True, obscuration=0., nstruts=0, strut_thick=0.05, strut_angle=0.*galsim.degrees, flux=1.): """Return NumPy array containing circular (default) or square pupil PSF with low-order aberrations. The PSF is centred on the array[array_shape[0] / 2, array_shape[1] / 2] pixel by default, and uses surface brightness rather than flux units for pixel values, matching SBProfile. To ensure properly Nyquist sampled output any user should set lam_over_diam >= 2. * dx. Ouput NumPy array is C-contiguous. @param array_shape the NumPy array shape desired for the output array. @param dx grid spacing of PSF in real space units @param lam_over_diam lambda / telescope diameter in the physical units adopted for dx (user responsible for consistency). @param defocus defocus in units of incident light wavelength. @param astig1 astigmatism (like e2) in units of incident light wavelength. @param astig2 astigmatism (like e1) in units of incident light wavelength. @param coma1 coma along y in units of incident light wavelength. @param coma2 coma along x in units of incident light wavelength. @param trefoil1 trefoil (one of the arrows along y) in units of incident light wavelength. @param trefoil2 trefoil (one of the arrows along x) in units of incident light wavelength. @param spher spherical aberration in units of incident light wavelength. @param circular_pupil adopt a circular pupil? @param obscuration linear dimension of central obscuration as fraction of pupil linear dimension, [0., 1.). @param nstruts Number of radial support struts to add to the central obscuration [default `nstruts = 0`]. @param strut_thick Thickness of support struts as a fraction of pupil diameter [default `strut_thick = 0.05`]. @param strut_angle Angle made between the vertical and the strut starting closest to it, defined to be positive in the counter-clockwise direction; must be a galsim.Angle instance [default `strut_angle = 0. * galsim.degrees`]. @param flux total flux of the profile [default flux=1.]. """ wf = wavefront( array_shape=array_shape, dx=dx, lam_over_diam=lam_over_diam, defocus=defocus, astig1=astig1, astig2=astig2, coma1=coma1, coma2=coma2, trefoil1=trefoil1, trefoil2=trefoil2, spher=spher, circular_pupil=circular_pupil, obscuration=obscuration, nstruts=nstruts, strut_thick=strut_thick, strut_angle=strut_angle) ftwf = np.fft.fft2(wf) # I think this (and the below) is quicker than np.abs(ftwf)**2 # The roll operation below restores the c_contiguous flag, so no need for a direct action im = utilities.roll2d((ftwf * ftwf.conj()).real, (array_shape[0] / 2, array_shape[1] / 2)) return im * (flux / (im.sum() * dx**2))
def psf(array_shape=(256, 256), dx=1., lam_over_diam=2., defocus=0., astig1=0., astig2=0., coma1=0., coma2=0., spher=0., circular_pupil=True, obscuration=0., flux=1.): """Return NumPy array containing circular (default) or square pupil PSF with low-order aberrations. The PSF is centred on the array[array_shape[0] / 2, array_shape[1] / 2] pixel by default, and uses surface brightness rather than flux units for pixel values, matching SBProfile. To ensure properly Nyquist sampled output any user should set lam_over_diam >= 2. * dx. Ouput NumPy array is C-contiguous. @param array_shape the NumPy array shape desired for the output array. @param dx grid spacing of PSF in real space units @param lam_over_diam lambda / telescope diameter in the physical units adopted for dx (user responsible for consistency). @param defocus defocus in units of incident light wavelength. @param astig1 first component of astigmatism (like e1) in units of incident light wavelength. @param astig2 second component of astigmatism (like e2) in units of incident light wavelength. @param coma1 coma along x in units of incident light wavelength. @param coma2 coma along y in units of incident light wavelength. @param spher spherical aberration in units of incident light wavelength. @param circular_pupil adopt a circular pupil? @param obscuration linear dimension of central obscuration as fraction of pupil linear dimension, [0., 1.) @param flux total flux of the profile [default flux=1.] """ wf = wavefront( array_shape=array_shape, dx=dx, lam_over_diam=lam_over_diam, defocus=defocus, astig1=astig1, astig2=astig2, coma1=coma1, coma2=coma2, spher=spher, circular_pupil=circular_pupil, obscuration=obscuration) ftwf = np.fft.fft2(wf) # I think this (and the below) is quicker than np.abs(ftwf)**2 # The roll operation below restores the c_contiguous flag, so no need for a direct action im = utilities.roll2d((ftwf * ftwf.conj()).real, (array_shape[0] / 2, array_shape[1] / 2)) return im * (flux / (im.sum() * dx**2))
def psf(array_shape=(256, 256), dx=1., lam_over_diam=2., defocus=0., astig1=0., astig2=0., coma1=0., coma2=0., trefoil1=0., trefoil2=0., spher=0., circular_pupil=True, obscuration=0., flux=1.): """Return NumPy array containing circular (default) or square pupil PSF with low-order aberrations. The PSF is centred on the array[array_shape[0] / 2, array_shape[1] / 2] pixel by default, and uses surface brightness rather than flux units for pixel values, matching SBProfile. To ensure properly Nyquist sampled output any user should set lam_over_diam >= 2. * dx. Ouput NumPy array is C-contiguous. @param array_shape the NumPy array shape desired for the output array. @param dx grid spacing of PSF in real space units @param lam_over_diam lambda / telescope diameter in the physical units adopted for dx (user responsible for consistency). @param defocus defocus in units of incident light wavelength. @param astig1 astigmatism (like e2) in units of incident light wavelength. @param astig2 astigmatism (like e1) in units of incident light wavelength. @param coma1 coma along y in units of incident light wavelength. @param coma2 coma along x in units of incident light wavelength. @param trefoil1 trefoil (one of the arrows along y) in units of incident light wavelength. @param trefoil2 trefoil (one of the arrows along x) in units of incident light wavelength. @param spher spherical aberration in units of incident light wavelength. @param circular_pupil adopt a circular pupil? @param obscuration linear dimension of central obscuration as fraction of pupil linear dimension, [0., 1.) @param flux total flux of the profile [default flux=1.] """ wf = wavefront(array_shape=array_shape, dx=dx, lam_over_diam=lam_over_diam, defocus=defocus, astig1=astig1, astig2=astig2, coma1=coma1, coma2=coma2, trefoil1=trefoil1, trefoil2=trefoil2, spher=spher, circular_pupil=circular_pupil, obscuration=obscuration) ftwf = np.fft.fft2( wf) # I think this (and the below) is quicker than np.abs(ftwf)**2 # The roll operation below restores the c_contiguous flag, so no need for a direct action im = utilities.roll2d((ftwf * ftwf.conj()).real, (array_shape[0] / 2, array_shape[1] / 2)) return im * (flux / (im.sum() * dx**2))