CosineBellWindow#

class photutils.psf_matching.CosineBellWindow(alpha)[source]#

Bases: SplitCosineBellWindow

Class to define a 2D cosine bell window function.

This window equals 1.0 only at the exact center point and smoothly tapers to 0.0. The taper begins immediately from the center (no inner plateau) and extends outward over a fraction alpha of the maximum radius.

The window is zero beyond a radius of alpha times the maximum radius, so a small alpha removes all but the lowest spatial frequencies. For the same alpha value, it suppresses much more high-frequency noise than TukeyWindow, which equals 1.0 out to a radius of 1 - alpha times the maximum radius. The cost is that it also removes more of the high-frequency signal. Use this window when you want a smooth low-pass taper with no flat inner region.

Parameters:
alphafloat

The width of the cosine taper 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) / 2 along an axis of size n. For a nonsquare shape, it differs between the two axes, so the window is elliptical. Must be between 0.0 and 1.0, inclusive. When alpha=1, this becomes a HanningWindow. When alpha=0, the window is zero everywhere except at the central pixel of an array with odd dimensions.

Raises:
ValueError

If alpha is not between 0.0 and 1.0, inclusive.

Notes

Equivalent to SplitCosineBellWindow(alpha=alpha, beta=0.0).

Examples

import matplotlib.pyplot as plt
from photutils.psf_matching import CosineBellWindow

taper = CosineBellWindow(alpha=0.3)
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-CosineBellWindow-1.png

A 1D cut across the image center:

import matplotlib.pyplot as plt
from photutils.psf_matching import CosineBellWindow

taper = CosineBellWindow(alpha=0.3)
data = taper((101, 101))
fig, ax = plt.subplots()
ax.plot(data[50, :])

(Source code, png, hires.png, pdf, svg)

../_images/photutils-psf_matching-CosineBellWindow-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 shape of the output array. It must have two elements. The window radii are defined relative to (n - 1) / 2 along each axis of size n, 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.

Raises:
ValueError

If shape does not have two elements.