SplitCosineBellWindow#
- class photutils.psf_matching.SplitCosineBellWindow(alpha, beta)[source]#
Bases:
objectClass 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) / 2along an axis of sizen. For a nonsquare shape, it differs between the two axes, so the window is elliptical.alphamust 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.
betamust be between 0.0 and 1.0, inclusive.
- Raises:
- ValueError
If
alphaorbetais not between 0.0 and 1.0, inclusive.
- Warns:
AstropyUserWarningIf
alpha + betais 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)
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)
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) / 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.