Skip to content

Optics

Optic

Bases: TransmissiveLayer, AberratedLayer

A basic 'Optic' class, which optionally applies a transmission, OPD and phase to the input wavefront, with the option for normalise after.

UML

UML

Attributes:

Name Type Description
transmission Array

The Array of transmission values to be applied to the input wavefront.

opd (Array, metres)

The Array of OPD values to be applied to the input wavefront.

phase (Array, radians)

The Array of phase values to be applied to the input wavefront.

normalise bool

Whether to normalise the wavefront after passing through the optic.

Source code in src/dLux/layers/optics.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class Optic(TransmissiveLayer, AberratedLayer):
    """
    A basic 'Optic' class, which optionally applies a transmission, OPD and phase to
    the input wavefront, with the option for normalise after.

    ??? abstract "UML"
        ![UML](../../assets/uml/Optic.png)

    Attributes
    ----------
    transmission: Array
        The Array of transmission values to be applied to the input wavefront.
    opd : Array, metres
        The Array of OPD values to be applied to the input wavefront.
    phase : Array, radians
        The Array of phase values to be applied to the input wavefront.
    normalise: bool
        Whether to normalise the wavefront after passing through the optic.
    """

    def __init__(
        self: OpticalLayer,
        transmission: Array = None,
        opd: Array = None,
        phase: Array = None,
        normalise: bool = False,
    ):
        """
        Parameters
        ----------
        transmission: Array = None
            The Array of transmission values to be applied to the input wavefront.
        opd : Array, metres = None
            The Array of OPD values to be applied to the input wavefront.
        phase : Array, radians = None
            The Array of phase values to be applied to the input wavefront.
        normalise: bool = False
            Whether to normalise the wavefront after passing through the optic.
        """
        super().__init__(
            transmission=transmission,
            opd=opd,
            phase=phase,
            normalise=normalise,
        )

        if self.transmission is not None:
            if self.opd is not None:
                if self.transmission.shape != self.opd.shape:
                    raise ValueError(
                        "transmission and opd must have the same shape. Got "
                        f"shapes {self.transmission.shape} and {self.opd.shape}."
                    )
            if self.phase is not None:
                if self.transmission.shape != self.phase.shape:
                    raise ValueError(
                        "transmission and phase must have the same shape. Got "
                        f"shapes {self.transmission.shape} and {self.phase.shape}."
                    )

    def apply(self: OpticalLayer, wavefront: Wavefront) -> Wavefront:
        """
        Applies the layer to the wavefront.

        Parameters
        ----------
        wavefront : Wavefront
            The wavefront to operate on.

        Returns
        -------
        wavefront : Wavefront
            The transformed wavefront.
        """
        wavefront *= self.transmission
        wavefront += self.opd
        wavefront = wavefront.add_phase(self.phase)
        if self.normalise:
            wavefront = wavefront.normalise()
        return wavefront

__init__(transmission=None, opd=None, phase=None, normalise=False)

Parameters:

Name Type Description Default
transmission Array

The Array of transmission values to be applied to the input wavefront.

None
opd Array, metres = None

The Array of OPD values to be applied to the input wavefront.

None
phase Array, radians = None

The Array of phase values to be applied to the input wavefront.

None
normalise bool

Whether to normalise the wavefront after passing through the optic.

False
Source code in src/dLux/layers/optics.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def __init__(
    self: OpticalLayer,
    transmission: Array = None,
    opd: Array = None,
    phase: Array = None,
    normalise: bool = False,
):
    """
    Parameters
    ----------
    transmission: Array = None
        The Array of transmission values to be applied to the input wavefront.
    opd : Array, metres = None
        The Array of OPD values to be applied to the input wavefront.
    phase : Array, radians = None
        The Array of phase values to be applied to the input wavefront.
    normalise: bool = False
        Whether to normalise the wavefront after passing through the optic.
    """
    super().__init__(
        transmission=transmission,
        opd=opd,
        phase=phase,
        normalise=normalise,
    )

    if self.transmission is not None:
        if self.opd is not None:
            if self.transmission.shape != self.opd.shape:
                raise ValueError(
                    "transmission and opd must have the same shape. Got "
                    f"shapes {self.transmission.shape} and {self.opd.shape}."
                )
        if self.phase is not None:
            if self.transmission.shape != self.phase.shape:
                raise ValueError(
                    "transmission and phase must have the same shape. Got "
                    f"shapes {self.transmission.shape} and {self.phase.shape}."
                )

apply(wavefront)

Applies the layer to the wavefront.

Parameters:

Name Type Description Default
wavefront Wavefront

The wavefront to operate on.

required

Returns:

Name Type Description
wavefront Wavefront

The transformed wavefront.

Source code in src/dLux/layers/optics.py
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
def apply(self: OpticalLayer, wavefront: Wavefront) -> Wavefront:
    """
    Applies the layer to the wavefront.

    Parameters
    ----------
    wavefront : Wavefront
        The wavefront to operate on.

    Returns
    -------
    wavefront : Wavefront
        The transformed wavefront.
    """
    wavefront *= self.transmission
    wavefront += self.opd
    wavefront = wavefront.add_phase(self.phase)
    if self.normalise:
        wavefront = wavefront.normalise()
    return wavefront
BasisOptic

Bases: TransmissiveLayer, BasisLayer

A basic 'Optic' class, with a aberrations applied through a set of basis vectors coefficients. This can be applied either as an opd or phase, using the as_phase attribute. Also optionally applies a transmission and normalisation.

UML

UML

Attributes:

Name Type Description
transmission Array

The Array of transmission values to be applied to the input wavefront.

basis (Array, metres)

Arrays holding the pre-calculated basis vectors.

coefficients Array

The Array of coefficients to be applied to each basis vector.

as_phase bool

Whether to apply the basis as a phase phase or OPD. If True the basis is applied as a phase, else it is applied as an OPD.

normalise bool

Whether to normalise the wavefront after passing through the optic.

Source code in src/dLux/layers/optics.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
class BasisOptic(TransmissiveLayer, BasisLayer):
    """
    A basic 'Optic' class, with a aberrations applied through a set of basis vectors
    coefficients. This can be applied either as an opd or phase, using the `as_phase`
    attribute. Also optionally applies a transmission and normalisation.

    ??? abstract "UML"
        ![UML](../../assets/uml/BasisOptic.png)

    Attributes
    ----------
    transmission: Array
        The Array of transmission values to be applied to the input wavefront.
    basis: Array, metres
        Arrays holding the pre-calculated basis vectors.
    coefficients: Array
        The Array of coefficients to be applied to each basis vector.
    as_phase : bool
        Whether to apply the basis as a phase phase or OPD. If True the basis is
        applied as a phase, else it is applied as an OPD.
    normalise : bool
        Whether to normalise the wavefront after passing through the optic.
    """

    def __init__(
        self: OpticalLayer,
        basis,
        transmission=None,
        coefficients=None,
        as_phase=False,
        normalise=False,
    ):
        """
        Parameters
        ----------
        basis: Array, metres
            Arrays holding the pre-calculated basis vectors.
        coefficients: Array = None
            The Array of coefficients to be applied to each basis vector.
        transmission: Array = None
            The Array of transmission values to be applied to the input wavefront.
        as_phase : bool = False
            Whether to apply the basis as a phase phase or OPD. If True the basis is
            applied as a phase, else it is applied as an OPD.
        normalise : bool = False
            Whether to normalise the wavefront after passing through the optic.
        """
        super().__init__(
            transmission=transmission,
            basis=basis,
            coefficients=coefficients,
            as_phase=as_phase,
            normalise=normalise,
        )

    def apply(self: OpticalLayer, wavefront: Wavefront()) -> Wavefront():
        """
        Applies the layer to the wavefront.

        Parameters
        ----------
        wavefront : Wavefront
            The wavefront to operate on.

        Returns
        -------
        wavefront : Wavefront
            The transformed wavefront.
        """
        wavefront *= self.transmission

        if self.as_phase:
            wavefront = wavefront.add_phase(self.eval_basis())
        else:
            wavefront += self.eval_basis()

        if self.normalise:
            wavefront = wavefront.normalise()
        return wavefront

__init__(basis, transmission=None, coefficients=None, as_phase=False, normalise=False)

Parameters:

Name Type Description Default
basis

Arrays holding the pre-calculated basis vectors.

required
coefficients

The Array of coefficients to be applied to each basis vector.

None
transmission

The Array of transmission values to be applied to the input wavefront.

None
as_phase bool = False

Whether to apply the basis as a phase phase or OPD. If True the basis is applied as a phase, else it is applied as an OPD.

False
normalise bool = False

Whether to normalise the wavefront after passing through the optic.

False
Source code in src/dLux/layers/optics.py
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
def __init__(
    self: OpticalLayer,
    basis,
    transmission=None,
    coefficients=None,
    as_phase=False,
    normalise=False,
):
    """
    Parameters
    ----------
    basis: Array, metres
        Arrays holding the pre-calculated basis vectors.
    coefficients: Array = None
        The Array of coefficients to be applied to each basis vector.
    transmission: Array = None
        The Array of transmission values to be applied to the input wavefront.
    as_phase : bool = False
        Whether to apply the basis as a phase phase or OPD. If True the basis is
        applied as a phase, else it is applied as an OPD.
    normalise : bool = False
        Whether to normalise the wavefront after passing through the optic.
    """
    super().__init__(
        transmission=transmission,
        basis=basis,
        coefficients=coefficients,
        as_phase=as_phase,
        normalise=normalise,
    )

apply(wavefront)

Applies the layer to the wavefront.

Parameters:

Name Type Description Default
wavefront Wavefront

The wavefront to operate on.

required

Returns:

Name Type Description
wavefront Wavefront

The transformed wavefront.

Source code in src/dLux/layers/optics.py
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
def apply(self: OpticalLayer, wavefront: Wavefront()) -> Wavefront():
    """
    Applies the layer to the wavefront.

    Parameters
    ----------
    wavefront : Wavefront
        The wavefront to operate on.

    Returns
    -------
    wavefront : Wavefront
        The transformed wavefront.
    """
    wavefront *= self.transmission

    if self.as_phase:
        wavefront = wavefront.add_phase(self.eval_basis())
    else:
        wavefront += self.eval_basis()

    if self.normalise:
        wavefront = wavefront.normalise()
    return wavefront