kernels.pclip_combine

kernels.pclip_combine(
    arr,
    *,
    mask=None,
    combine,
    frac=-0.5,
    sigma=3.0,
    nkeep=1,
    validate=True,
)

IRAF-style percentile clipping at each pixel (output-only variant).

Parameters

arr : (ndarray, shape(N, *spatial))

Image stack. Accepted dtypes are uint8, uint16, int16, int32, float32, and float64. Integer inputs are promoted to the package’s floating workspace when validate is True. Inputs with more than 3 dimensions are flattened internally; output shapes match the trailing spatial dimensions of the input.

mask : ndarray of bool = None

Input mask; True means already masked. Must have the same shape as arr before any internal flattening.

combine : str

Output combine method evaluated after rejection. Fused combine kernels support "mean", "average", "avg", "median", and "med".

frac : float = -0.5

IRAF pclip value. If abs(frac) < 1, it is converted to an integer rank offset using half of the input image count. Positive values estimate sigma from the high side of the sorted median; negative values estimate sigma from the low side.

sigma : float or tuple of float = 3.0

User-supplied lower and upper clipping multipliers applied to the pclip-estimated spread. This maps to IRAF lsigma and hsigma.

nkeep : int = 1

Minimum number of unmasked samples to retain after pclip rejection.

validate : bool = True

If True, check dimensionality and normalize dtype/contiguity before entering the Rust kernel. If False, callers must provide inputs that satisfy the compiled kernel assumptions.

Returns

combined : (ndarray, shape(*spatial))

Per-output mean or median after applying the input mask, finite-value filtering, and this rejection algorithm.

Notes

This follows IRAF imcombine pclip semantics: choose a sorted rank offset from the median, use that sample’s distance from the median as sigma, then apply lower and upper sigma thresholds.