Skip to content

Commit

Permalink
added 'method' argument for psf.convolve (#278)
Browse files Browse the repository at this point in the history
added 'method' argument for psf.convolve
  • Loading branch information
maxecharles authored Oct 15, 2024
1 parent 5089344 commit 93af2a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dLux/psfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,26 @@ def downsample(self: PSF, n: int) -> PSF:
"""
return self.set("data", dlu.downsample(self.data, n, mean=False))

def convolve(self: PSF, other: Array) -> PSF:
def convolve(self: PSF, other: Array, method: str = "auto") -> PSF:
"""
Convolves the psf with some input array.
Parameters
----------
other : Array
The psf to convolve with.
method : str = "auto"
The method to use for the convolution. Can be "auto", "direct",
or "fft". Is "auto" by default, which calls "direct".
Returns
-------
psf : PSF
The convolved psf.
"""
return self.set("data", convolve(self.data, other, mode="same"))
return self.set(
"data", convolve(self.data, other, mode="same", method=method)
)

def rotate(self: PSF, angle: float, order: int = 1) -> PSF:
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_psfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_properties(self, psf):
def test_methods(self, psf):
assert psf.downsample(2).npixels == 8
assert isinstance(psf.convolve(np.ones((2, 2))), PSF)
assert isinstance(psf.convolve(np.ones((2, 2)), method="fft"), PSF)
assert isinstance(psf.rotate(np.pi), PSF)
assert isinstance(psf.resize(8), PSF)
assert isinstance(psf.flip(0), PSF)
Expand Down

0 comments on commit 93af2a5

Please sign in to comment.