SplitCosineBellWindow#

class photutils.psf_matching.SplitCosineBellWindow(alpha, beta)[source]#

Bases: object

Class to define a 2D split cosine bell taper function.

This is the base class for window functions, providing full control over both the inner flat region (beta) and the taper width (alpha). The window equals 1.0 in the inner region, smoothly transitions to 0.0 using a cosine taper, and remains 0.0 outside.

This window is useful when you need precise control over both the preserved central region and the taper characteristics.

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. alpha must be between 0.0 and 1.0, inclusive.

betafloat

The radius of the inner flat region as a fraction of the maximum radius. The taper begins beyond this radius. beta must be between 0.0 and 1.0, inclusive.

Raises:
ValueError

If alpha or beta is not between 0.0 and 1.0, inclusive.

Warns:
AstropyUserWarning

If alpha + beta is greater than 1.0. The taper then extends beyond the maximum radius and is truncated by the array edges.

Examples

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

taper = SplitCosineBellWindow(alpha=0.4, beta=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-SplitCosineBellWindow-1.png

A 1D cut across the image center:

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

taper = SplitCosineBellWindow(alpha=0.4, beta=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-SplitCosineBellWindow-2.png

Methods Summary

__call__(shape)

Generate the window function for the given shape.

Methods Documentation

__call__(shape)[source]#

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.