OpticalElement¶
-
class
hcipy.optics.
OpticalElement
¶ Bases:
object
Base class for all optical elements.
This class can propagate a
Wavefront
through an optical element (or free space), therefore modifying it. Any OpticalElement should be agnostic of the grid and wavelength of the wavefront. If it’s not, you can use themake_agnostic_optical_element()
decorator to create an agnostic optical element out of a gnostic one.Methods Summary
__call__
(self, wavefront)Propagate a wavefront forward through the optical element.
backward
(self, wavefront)Propagate a wavefront backward through the optical element.
forward
(self, wavefront)Propagate a wavefront forward through the optical element.
get_instance
(self[, input_grid, …])Return an OpticalElement that can handle wavefronts with input_grid and wavelength.
get_transformation_matrix_backward
(self[, …])Calculate the linear transformation matrix that corresponds to a backward propagation.
get_transformation_matrix_forward
(self[, …])Calculate the linear transformation matrix that corresponds to a forward propagation.
Methods Documentation
-
__call__
(self, wavefront)¶ Propagate a wavefront forward through the optical element.
- Parameters
- wavefrontWavefront
The wavefront to propagate.
- Returns
- Wavefront
The propagated wavefront.
-
backward
(self, wavefront)¶ Propagate a wavefront backward through the optical element.
A backward propagation is a literal backward propagation through the element. It is not (in general) the inverse of the forward propagation, except in cases where energy is conserved.
This function will be implemented by the derived class.
- Parameters
- wavefrontWavefront
The wavefront to propagate.
- Returns
- Wavefront
The propagated wavefront.
-
forward
(self, wavefront)¶ Propagate a wavefront forward through the optical element.
This will be implemented by the derived class.
- Parameters
- wavefrontWavefront
The wavefront to propagate.
- Returns
- Wavefront
The propagated wavefront.
-
get_instance
(self, input_grid=None, output_grid=None, wavelength=None)¶ Return an OpticalElement that can handle wavefronts with input_grid and wavelength.
While any OpticalElement should in theory be able to handle all grids and wavelengths, this function is added to simplify the interface for those who don’t. It allows the user to always access properties of an OpticalElement, evaluated for a specific input_grid and wavelength.
The user needs to supply at least an input grid or an output grid, and a wavelength. If this is not done, a ValueError will be raised.
- Parameters
- input_gridGrid
The grid on which the input wavefront is defined.
- output_gridGrid or None
The grid on which the output wavefront is defined.
- wavelengthscalar
The wavelength on which the wavefront is defined.
- Returns
- OpticalElement
An optical element that can handle wavefront with the specified input grid and wavelength.
-
get_transformation_matrix_backward
(self, wavelength=1)¶ Calculate the linear transformation matrix that corresponds to a backward propagation.
The matrix is defined such that E_in = M.dot(E_out), where E_out and E_in are the electric fields of the output and input plane respectively, and M is the transformation matrix returned by this function.
A backward propagation is a literal backward propagation through the element. It is not (in general) the inverse of the forward propagation, except in cases where energy is conserved.
- :: warning::
Depending on the chosen resolution, this matrix can be extremely large and use extremely large amounts of memory. For example, a Fresnel propagation on a 128x128 grid will already create a matrix of 2.1GB. Use with caution.
This function will be implemented by the derived class.
- Parameters
- wavelengthscalar
The wavelength for which the transformation matrix will be calculated.
- Returns
- ndarray
The full propagation matrix.
-
get_transformation_matrix_forward
(self, wavelength=1)¶ Calculate the linear transformation matrix that corresponds to a forward propagation.
The matrix is defined such that E_out = M.dot(E_in), where E_out and E_in are the electric fields of the output and input respectively, and M is the transformation matrix returned by this function.
- :: warning::
Depending on the chosen resolution, this matrix can be extremely large and use extremely large amounts of memory. For example, a Fresnel propagation on a 128x128 grid will already create a matrix of 2.1GB. Use with caution.
This function will be implemented by the derived class.
- Parameters
- wavelengthscalar
The wavelength for which the transformation matrix will be calculated.
- Returns
- ndarray
The full propagation matrix.
-