HanningWindow#
- class photutils.psf_matching.HanningWindow[source]#
Bases:
SplitCosineBellWindowClass to define a 2D Hanning (or Hann) window function.
The Hann window is a taper formed by using a raised cosine with ends that touch zero. The taper begins at the center and smoothly decreases to zero at the edges. This window equals 1.0 only at the exact center point.
This is a classic general-purpose window function widely used in signal processing. It provides good suppression of ringing artifacts in the matching kernel at the cost of tapering the entire image. For PSF matching, use this window when edge effects and ringing artifacts are a primary concern and you can accept tapering most of the data. If you want to preserve more of the central region, consider using
TukeyWindowinstead.Notes
Equivalent to
SplitCosineBellWindow(alpha=1.0, beta=0.0).Examples
import matplotlib.pyplot as plt from photutils.psf_matching import HanningWindow taper = HanningWindow() 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 HanningWindow taper = HanningWindow() 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.