psf_generator.utils.plots#
A collection of plotting functions.
Attributes#
Functions#
|
Colorbar with the option to add or remove ticks. |
|
Apply a disk mask to a square image. |
|
Compute the intensity of a complex field. |
|
Plot the modulus and phase of a scalar or vectorial pupil for the Cartesian propagator. |
|
Plot the intensity or modulus or phase of a PSF, applicable to all four propagators. |
Module Contents#
- 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._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.