HanningWindow#

class photutils.psf_matching.HanningWindow[source]#

Bases: SplitCosineBellWindow

Class 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 sidelobe suppression in Fourier space, reducing ringing artifacts 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 TukeyWindow instead.

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)

../_images/photutils-psf_matching-HanningWindow-1.png

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)

../_images/photutils-psf_matching-HanningWindow-2.png

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 size of the output array along each axis.

Returns:
result2D ndarray

The window function as a 2D array.