TopHatWindow#
- class photutils.psf_matching.TopHatWindow(beta)[source]#
Bases:
SplitCosineBellWindowClass to define a 2D top hat window function.
This window equals 1.0 inside a circular region defined by
beta(elliptical for a nonsquare shape) and drops sharply to 0.0 outside, with no smooth transition. It is also known as a rectangular or boxcar window.This window preserves the most data (everything inside the cutoff radius is untouched), but the sharp edge creates strong ringing artifacts in the matching kernel. Use this only when you need to strictly preserve data within a specific region and can tolerate significant artifacts, or when the sharp cutoff is explicitly desired.
For most PSF matching applications,
TukeyWindowis preferred as it provides much better artifact suppression while still preserving a large central region. UseTopHatWindowprimarily for masking or when studying the effects of abrupt truncation.- Parameters:
- betafloat
The radius of the window as a fraction of the maximum radius. The maximum radius is the distance in pixels from the array center to the edge, which is
(n - 1) / 2along an axis of sizen. For a nonsquare shape, it differs between the two axes, so the window is elliptical. The window is zero beyond the window radius. Must be between 0.0 and 1.0, inclusive.
- Raises:
- ValueError
If
betais not between 0.0 and 1.0, inclusive.
Notes
Equivalent to
SplitCosineBellWindow(alpha=0.0, beta=beta).Examples
import matplotlib.pyplot as plt from photutils.psf_matching import TopHatWindow taper = TopHatWindow(beta=0.4) data = taper((101, 101)) fig, ax = plt.subplots() axim = ax.imshow(data, origin='lower') fig.colorbar(axim)
(
Source code,png,hires.png,pdf,svg)
A 1D cut across the image center:
import matplotlib.pyplot as plt from photutils.psf_matching import TopHatWindow taper = TopHatWindow(beta=0.4) data = taper((101, 101)) fig, ax = plt.subplots() ax.plot(data[50, :])
(
Source code,png,hires.png,pdf,svg)
Methods Summary
__call__(shape)Generate the window function for the given shape.
Methods Documentation
- __call__(shape)#
Generate the window function for the given shape.
- Parameters:
- shapetuple of int
The shape of the output array. It must have two elements. The window radii are defined relative to
(n - 1) / 2along each axis of sizen, so the window is elliptical for a nonsquare shape. When the window is applied to a Fourier transform, it then has the same cutoff in spatial frequency along both axes.
- Returns:
- result2D
ndarray The window function as a 2D array.
- result2D
- Raises:
- ValueError
If
shapedoes not have two elements.