aiapy.psf.psf(channel: Unit('Angstrom'), *, use_preflightcore=False, diffraction_orders=None, use_gpu=True)[source]#

Calculate the composite PSF for a given channel, including diffraction and core effects.


This function has been adapted from


If the cupy package is installed and your machine has an NVIDIA GPU, the PSF calculation will automatically be accelerated with CUDA. This can lead to several orders of magnitude in performance increase compared to pure numpy on a CPU.

The point spread function (PSF) can be modeled as a 2D Gaussian function of the radial distance \(r\) from the center,

\[I(r, \theta) = I_0 \exp\left(\frac{-r^2}{2\sigma^2}\right)\]


  • \(I_0\) : the intensity of a diffraction spike

  • \(r\) : the radial distance from the center

  • \(\theta = m\lambda/d\)

  • \(m\) : diffraction order

  • \(\lambda\) : the wavelength of light

  • \(\sigma\) : width of Gaussian

The intensity of a particular diffraction spike, \(I_0\), is given by,

\[I_0 = \mathrm{sinc}^2\left(\frac{\theta w}{\lambda}\right)\]


  • \(w\) : the width of the mesh wires

  • \(d\) : spacing between two consecutive mesh wires

The PSF for a given filter can then be calculated as,

\[\mathrm{PSF} = \sum_{m=-\infty}^{+\infty}I_m(r,\theta)\]

where, in practice, one can approximate the summation by simply summing over a sufficiently large number of diffraction orders. In this case, we sum from \(m=--100\) to \(m=100\).

Finally, the composite PSF of the entrance and focal plane filters is given by,

\[\mathrm{PSF}_c = \left|\mathcal{F}\left\{ \mathcal{F}\{\mathrm{PSF}_f\} \mathcal{F}\{\mathrm{PSF}_e\} \right\}\right|\]

where \(\mathcal{F}\) denotes the Fourier transform, \(\mathrm{PSF}_f\) is the PSF of the focal plane filter, and \(\mathrm{PSF}_e\) is the PSF of the entrance filter. For a more detailed explanation of the PSF and the above calculation, see [1].

  • channel (Quantity) – Wavelength of channel

  • use_preflightcore (bool, optional) – If True, use the pre-flight values of the mesh width

  • diffraction_orders (array-like, optional) – The diffraction orders to sum over. If None, the full range from -100 to +100 in steps of 1 will be used.

  • use_gpu (bool, optional) – If True and cupy is installed, do PSF deconvolution on the GPU with cupy.


The composite PSF of the entrance and focal plane filters.

Return type: