psf_generator.utils.plots#

A collection of plotting functions.

Attributes#

Functions#

colorbar(mappable[, cbar_ticks, tick_size, cbar_labels])

Colorbar with the option to add or remove ticks.

apply_disk_mask(img)

Apply a disk mask to a square image.

_compute_psf_intensity(→ numpy.ndarray)

Compute the intensity of a complex field.

plot_pupil(pupil, name_of_propagator[, filepath, ...])

Plot the modulus and phase of a scalar or vectorial pupil for the Cartesian propagator.

plot_psf(psf, name_of_propagator[, quantity, ...])

Plot the intensity or modulus or phase of a PSF, applicable to all four propagators.

Module Contents#

psf_generator.utils.plots._FIG_SIZE = 5[source]#
psf_generator.utils.plots._SUP_TITLE_SIZE = 17[source]#
psf_generator.utils.plots._TITLE_SIZE = 12[source]#
psf_generator.utils.plots._LABEL_SIZE = 18[source]#
psf_generator.utils.plots._TICK_SIZE = 16[source]#
psf_generator.utils.plots.lw = 1[source]#
psf_generator.utils.plots.markersize = 6[source]#
psf_generator.utils.plots.colorbar(mappable, cbar_ticks: str | List | None = 'auto', tick_size: float = _TICK_SIZE, cbar_labels: List[str] = None)[source]#

Colorbar with the option to add or remove ticks.

Parameters#

mappable :

Matplotlib Mappable.

cbar_ticksNone or str or List of ticks

If None, no ticks visible. If ‘auto’: ticks are determined automatically. Otherwise, set the ticks as given by cbar_ticks.

tick_size: float, optional

Fontsize of the tick labels.

cbar_labels: list[str], optional

Cbar labels. Default is None, use cbar ticks.

psf_generator.utils.plots.apply_disk_mask(img)[source]#

Apply a disk mask to a square image.

psf_generator.utils.plots._compute_psf_intensity(input_image: numpy.ndarray) numpy.ndarray[source]#

Compute the intensity of a complex field.

The input array must be 4D with this convention:

  • dim one: z axis, or defocus slices.

  • dim two: electric field components. Only one for scalar and three \((\mathbf{e}_x, \mathbf{e}_y, \mathbf{e}_z)\) for vectorial.

  • dim three and four: \((x, y)\) axes.

The intensity is computed as follows:

\[I = \sum_{i=1}^{N} |\mathbf{e}_i(x, y, z)|^2, \quad N = 1 \, \mathrm{or} \, 3.\]

Parameters#

input_imagenp.ndarray

Scalar or vectorial complex field. 4D array.

Returns#

outputnp.ndarray

Intensity of the field. 4D array.

psf_generator.utils.plots.plot_pupil(pupil: torch.Tensor | numpy.ndarray, name_of_propagator: str, filepath: str = None, show_cbar_ticks: bool = False, show_image_ticks: bool = False, show_titles: bool = True)[source]#

Plot the modulus and phase of a scalar or vectorial pupil for the Cartesian propagator.

Parameters#

pupiltorch.Tensor or np.ndarray

Pupil image to plot.

name_of_propagatorstr

Name of the propagator.

filepath: str, optional

Path to save the plot. Default is None, no file is saved.

show_titlesbool, optional

Whether to show the titles on the first row. Default is False.

show_image_ticksbool, optional

Whether to show ticks. Default is False.

show_cbar_ticksbool, optional

Whether to show the ticks for the colorbar. Default is False.

psf_generator.utils.plots.plot_psf(psf: torch.Tensor | numpy.ndarray, name_of_propagator: str, quantity: str = 'modulus', z_slice_number: int = None, x_slice_number: int = None, y_slice_number: int = None, filepath: str = None, show_cbar_ticks: bool = False, show_image_ticks: bool = False, show_titles: bool = False, propagator=None)[source]#

Plot the intensity or modulus or phase of a PSF, applicable to all four propagators.

Parameters#

psftorch.Tensor or np.ndarray

PSF image to plot.

name_of_propagatorstr

Name of the propagator.

quantitystr, optional

Quantity of the PSF to plot. Default is ‘modulus’. Valid choices are ‘modulus’, ‘phase’, ‘stationary_phase’, ‘intensity’, ‘amplitude’.

z_slice_numberint, optional

Z slice number for the x-y plane.

x_slice_numberint, optional

X slice number for the y-z plane.

y_slice_numberint, optional

Y slice number for the x-z plane.

filepathstr, optional

Path to save the plot. Default is None, no file is saved.

show_titlesbool, optional

Whether to show the titles on the first row. Default is False.

show_image_ticksbool, optional

Whether to show ticks. Default is False.

show_cbar_ticksbool, optional

Whether to show the ticks for the colorbar. Default is False.

propagatorPropagator, optional

Propagator object. Required for ‘stationary_phase’ quantity. Default is None.