prtools.calcpsf#

calcpsf(amp, opd, wavelength, sampling, shape, oversample=2, shift=(0, 0), offset=(0, 0), weight=1, flatten=True)[source]#

Calculate a point spread function using far-field diffraction.

Parameters:
  • amp (array_like) – Pupil amplitude

  • opd (array_like) – Pupil OPD

  • wavelength (float or list_like) – Propagation wavelength(s)

  • sampling (float or tuple of floats) –

    Propagation sampling term defined as

    \[\mbox{sampling} = \frac{dx \ du}{z}\]

    where dx is the pupil plane spatial sampling, du is the image plane spatial sampling, and z is the propagation distance. If a single value is supplied, the sampling is assumed to be uniform in both row and column.

  • shape (int or tuple of ints) – Native output shape. If a single value is supplied, the output will have shape = (shape, shape). Note that the actual output shape is floor(shape * oversample)

  • oversample (float) – Number of times to oversample the output plane

  • shift (tuple of floats, optional) – Shift from (0,0) in (r,c) of image plane. Default is (0,0).

  • offset (tuple of floats, optional) – Offset from (0,0) in (r,c) of pupil plane. Default is (0,0).

  • weight (float or list_like) – Weighting for each wavelength in wavelength.

  • flatten (bool, optional) – If True (default),the output is flattened along the spectral dimension. Otherwise, a cube is returned with shape (len(wavelength), shape[0]*oversample, shape[1]*oversample)

Return type:

ndarray

Examples

>>> amp = prtools.circle(shape=(256, 256), radius=100)
>>> coeffs = np.random.uniform(low=-1, high=1, size=8)*1e-7
>>> opd = prtools.zernike_compose(amp, coeffs)
>>> wave = 500e-9
>>> dx = 1/200  # pupil diameter = 1m
>>> du = 5e-6
>>> focal_length = 10
>>> sampling = (dx * du)/focal_length
>>> shape = (64, 64)
>>> oversample = 5
>>> psf = prtools.calcpsf(amp, opd, wave, sampling, shape, oversample)
>>> plt.imshow(psf, cmap='inferno', norm='log', vmin=10e-5)
../_images/prtools-calcpsf-1.png