Utils¶
Helper utilities for image loading and array operations.
- socca.utils.apodization(shape, width, profile='cos', alpha=1.0)[source]¶
Build a 2D apodization window with a tapered border.
Reproduces pixell’s
enmap.apod(map, width, profile, fill="zero"): an array of ones with a taper applied within width pixels of each edge, separately (and multiplicatively) along both axes.- Parameters:
shape (tuple of int) – Shape of the output window, as (ny, nx).
width (int or float) – Width of the tapered border, applied to all four edges. If width is a float in (0, 1), it is interpreted as a fraction of the respective axis length (rounded to the nearest pixel, so the y- and x-axis tapers may differ for a non-square shape); otherwise it is interpreted directly as a number of pixels. If the resolved pixel width is not positive, an array of ones is returned.
profile (str, optional) – Shape of the taper. Either “cos” (raised-cosine, the default) or “lin” (linear ramp).
alpha (float, optional) – Power to which the taper is raised, controlling how sharply it rises from 0 to 1. Default is 1.00 (unmodified taper); values above/below 1 make it steeper/gentler near the edge.
- Returns:
Array of shape shape, with values in [0, 1].
- Return type:
numpy.ndarray
- Raises:
ValueError – If profile is not one of “cos” or “lin”.