Skip to content

Propagators¤

MFT

dLux.layers.propagators.MFT ¤

Bases: Propagator

Propagates a Wavefront using the MFT algorithm, allowing for the pixel_scale and number of pixels to be specified in the output plane.

UML

UML

Attributes:

Name Type Description
npixels int

The number of pixels in the output plane.

pixel_scale (float, meters / pixel or radians / pixel)

The pixel scale in the output plane. Has units of radians/pixel if focal_length is None, else meters/pixel.

focal_length (float, meters)

The focal_length of the lens/mirror this propagator represents. If None, the output pixel_scale has units radians/pixel, else meters/pixels.

inverse bool

If False, propagate forward through the system. If True, propagate backward through the system.

Source code in dLux/layers/propagators.py
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
class MFT(Propagator):
    """
    Propagates a `Wavefront` using the MFT algorithm, allowing for the pixel_scale and
    number of pixels to be specified in the output plane.

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

    Attributes
    ----------
    npixels : int
        The number of pixels in the output plane.
    pixel_scale : float, meters/pixel or radians/pixel
        The pixel scale in the output plane. Has units of radians/pixel if focal_length
        is None, else meters/pixel.
    focal_length : float, meters
        The focal_length of the lens/mirror this propagator represents. If None, the
        output pixel_scale has units radians/pixel, else meters/pixels.
    inverse: bool
        If False, propagate forward through the system. If True, propagate backward
        through the system.
    """

    npixels: int
    pixel_scale: float

    def __init__(
        self: MFT,
        npixels: int,
        pixel_scale: float,
        focal_length: float = None,
        inverse: bool = False,
    ):
        """
        Parameters
        ----------
        npixels : int
            The number of pixels in the output plane.
        pixel_scale : float, meters/pixel or radians/pixel
            The pixel scale in the output plane. Has units of radians/pixel if
            focal_length is None, else meters/pixel.
        focal_length : float = None, meters
            The focal_length of the lens/mirror this propagator represents. If None,
            the output pixel_scale has units radians/pixel, else meters/pixels.
        inverse: bool = False
            If False, propagate forward through the system. If True, propagate
            backward through the system.
        """
        super().__init__(focal_length=focal_length, inverse=inverse)

        self.pixel_scale = float(pixel_scale)
        self.npixels = int(npixels)

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

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

        Returns
        -------
        wavefront : Wavefront
            The transformed wavefront.
        """
        return wavefront.propagate(
            npixels=self.npixels,
            pixel_scale=self.pixel_scale,
            focal_length=self.focal_length,
            inverse=self.inverse,
        )

__call__(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 dLux/layers/propagators.py
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
def __call__(self: MFT, wavefront: Wavefront) -> Wavefront:
    """
    Applies the layer to the wavefront.

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

    Returns
    -------
    wavefront : Wavefront
        The transformed wavefront.
    """
    return wavefront.propagate(
        npixels=self.npixels,
        pixel_scale=self.pixel_scale,
        focal_length=self.focal_length,
        inverse=self.inverse,
    )

__init__(npixels, pixel_scale, focal_length=None, inverse=False) ¤

Parameters:

Name Type Description Default
npixels int

The number of pixels in the output plane.

required
pixel_scale (float, meters / pixel or radians / pixel)

The pixel scale in the output plane. Has units of radians/pixel if focal_length is None, else meters/pixel.

required
focal_length float = None, meters

The focal_length of the lens/mirror this propagator represents. If None, the output pixel_scale has units radians/pixel, else meters/pixels.

None
inverse bool

If False, propagate forward through the system. If True, propagate backward through the system.

False
Source code in dLux/layers/propagators.py
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
def __init__(
    self: MFT,
    npixels: int,
    pixel_scale: float,
    focal_length: float = None,
    inverse: bool = False,
):
    """
    Parameters
    ----------
    npixels : int
        The number of pixels in the output plane.
    pixel_scale : float, meters/pixel or radians/pixel
        The pixel scale in the output plane. Has units of radians/pixel if
        focal_length is None, else meters/pixel.
    focal_length : float = None, meters
        The focal_length of the lens/mirror this propagator represents. If None,
        the output pixel_scale has units radians/pixel, else meters/pixels.
    inverse: bool = False
        If False, propagate forward through the system. If True, propagate
        backward through the system.
    """
    super().__init__(focal_length=focal_length, inverse=inverse)

    self.pixel_scale = float(pixel_scale)
    self.npixels = int(npixels)
FFT

dLux.layers.propagators.FFT ¤

Bases: Propagator

Propagates a Wavefront using the FFT algorithm.

UML

UML

Attributes:

Name Type Description
focal_length float

The focal_length of the lens/mirror this propagator represents. If None, the output pixel_scale has units radians/pixel, else meters/pixels.

inverse bool

If False, propagate forward through the system. If True, propagate backward through the system.

pad int

The zero-padding factor to apply to the Wavefront before propagation. In general, this should be greater than 2 to avoid aliasing.

crop int

The cropping factor to apply to the Wavefront after propagation. In general, this should only be applied after a corresponding padding factor has been applied to avoid aliasing.

Source code in dLux/layers/propagators.py
 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
100
101
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
class FFT(Propagator):
    """
    Propagates a `Wavefront` using the FFT algorithm.

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

    Attributes
    ----------
    focal_length : float
        The focal_length of the lens/mirror this propagator represents. If None, the
        output pixel_scale has units radians/pixel, else meters/pixels.
    inverse: bool
        If False, propagate forward through the system. If True, propagate backward
        through the system.
    pad : int
        The zero-padding factor to apply to the `Wavefront` before propagation. In
        general, this should be greater than 2 to avoid aliasing.
    crop : int
        The cropping factor to apply to the `Wavefront` after propagation. In general,
        this should only be applied after a corresponding padding factor has been
        applied to avoid aliasing.
    """

    pad: int
    crop: int
    center: bool

    def __init__(
        self: FFT,
        focal_length: float = None,
        inverse: bool = False,
        pad: int = 1,
        crop: int = 1,
        center: bool = True,
    ):
        """
        Parameters
        ----------
        focal_length : float = None
            The focal_length of the lens/mirror this propagator represents. If None, the
            output pixel_scale has units radians/pixel, else meters/pixels.
        inverse: bool = False
            If False, propagate forward through the system. If True, propagate
            backward through the system.
        pad : int = 1
            The zero-padding factor to apply to the `Wavefront` before propagation. In
            general, this should be greater than 2 to avoid aliasing.
        crop : int = 1
            The cropping factor to apply to the `Wavefront` after propagation. In
            general, this should only be applied after a corresponding padding factor
            has been applied to avoid aliasing.
        center : bool = True
            If True, the output coordinates are centered at 0. If False, output
            coordinates use the default transform convention.
        """
        super().__init__(focal_length=focal_length, inverse=inverse)
        self.pad = int(pad)
        self.crop = int(crop)
        self.center = bool(center)

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

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

        Returns
        -------
        wavefront : Wavefront
            The transformed wavefront.
        """
        if self.center:
            spec = CoordSpec(c=0.0)
        else:
            spec = None
        size_out = wavefront.npixels * self.pad // self.crop
        return wavefront.propagate_FFT(
            pad=self.pad,
            focal_length=self.focal_length,
            inverse=self.inverse,
            spec_out=spec,
        ).resize(size_out)

__call__(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 dLux/layers/propagators.py
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
def __call__(self: FFT, wavefront: Wavefront) -> Wavefront:
    """
    Applies the layer to the wavefront.

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

    Returns
    -------
    wavefront : Wavefront
        The transformed wavefront.
    """
    if self.center:
        spec = CoordSpec(c=0.0)
    else:
        spec = None
    size_out = wavefront.npixels * self.pad // self.crop
    return wavefront.propagate_FFT(
        pad=self.pad,
        focal_length=self.focal_length,
        inverse=self.inverse,
        spec_out=spec,
    ).resize(size_out)

__init__(focal_length=None, inverse=False, pad=1, crop=1, center=True) ¤

Parameters:

Name Type Description Default
focal_length float = None

The focal_length of the lens/mirror this propagator represents. If None, the output pixel_scale has units radians/pixel, else meters/pixels.

None
inverse bool

If False, propagate forward through the system. If True, propagate backward through the system.

False
pad int = 1

The zero-padding factor to apply to the Wavefront before propagation. In general, this should be greater than 2 to avoid aliasing.

1
crop int = 1

The cropping factor to apply to the Wavefront after propagation. In general, this should only be applied after a corresponding padding factor has been applied to avoid aliasing.

1
center bool = True

If True, the output coordinates are centered at 0. If False, output coordinates use the default transform convention.

True
Source code in dLux/layers/propagators.py
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
def __init__(
    self: FFT,
    focal_length: float = None,
    inverse: bool = False,
    pad: int = 1,
    crop: int = 1,
    center: bool = True,
):
    """
    Parameters
    ----------
    focal_length : float = None
        The focal_length of the lens/mirror this propagator represents. If None, the
        output pixel_scale has units radians/pixel, else meters/pixels.
    inverse: bool = False
        If False, propagate forward through the system. If True, propagate
        backward through the system.
    pad : int = 1
        The zero-padding factor to apply to the `Wavefront` before propagation. In
        general, this should be greater than 2 to avoid aliasing.
    crop : int = 1
        The cropping factor to apply to the `Wavefront` after propagation. In
        general, this should only be applied after a corresponding padding factor
        has been applied to avoid aliasing.
    center : bool = True
        If True, the output coordinates are centered at 0. If False, output
        coordinates use the default transform convention.
    """
    super().__init__(focal_length=focal_length, inverse=inverse)
    self.pad = int(pad)
    self.crop = int(crop)
    self.center = bool(center)