08 1-D Rejection

Standalone 1-D reductions now belong in the separate reducers package (import reducers as rd). Use rd.mean, rd.nanmedian, rd.var, rd.percentile, and related functions for generic vectors, flattened images, or axis reductions.

imcombiners.kernels still provides 1-D rejection helpers because those are part of image-combination workflows. They return the same products as stack rejection, but with 1-D shapes and scalar diagnostics.

import numpy as np
import imcombiners.kernels as imck
rng = np.random.default_rng(20260528)
values = rng.normal(1000.0, 30.0, size=10_000).astype("float32")
values[0] = np.nan
values[1] += 700.0

Rejection Masks

mask_rej, std, low, upp, nit, flags = imck.sigclip_1d(
    values,
    sigma=3.0,
    maxiters=5,
    cenfunc="median",
)

print(mask_rej.shape)
print(std, low, upp, nit, flags)
(10000,)
29.535048 912.39746 1088.95 4 0

The mask-only functions are convenient when you want to inspect or reuse the survivors yourself:

mask = imck.sigclip_mask_1d(values, sigma=3.0)
survivors = values[~mask & np.isfinite(values)]

print(survivors.size)
9970

Rejected Combine

For output-only robust statistics, call the _combine_1d helpers:

sigclip_median = imck.sigclip_combine_1d(
    values,
    combine="median",
    sigma=3.0,
    maxiters=5,
)

trimmed_mean = imck.minmax_combine_1d(
    values,
    combine="mean",
    n_min=1,
    n_max=1,
)

print(sigclip_median, trimmed_mean)
1000.7613525390625 1000.5289916992188

The available rejection families mirror the image-stack API:

Full result Mask only Output-only combine
sigclip_1d sigclip_mask_1d sigclip_combine_1d
ccdclip_1d ccdclip_mask_1d ccdclip_combine_1d
minmax_1d minmax_mask_1d minmax_combine_1d
pclip_1d pclip_mask_1d pclip_combine_1d
linearclip_1d - -

Validation

By default the functions validate shape, dtype, mask length, and contiguity. In a tight loop, prepare the vector once and pass validate=False:

workspace = np.ascontiguousarray(values, dtype=np.float32)
mask = imck.sigclip_mask_1d(workspace, sigma=3.0, validate=False)
print(mask.sum())
30

Use validate=False only when you already know the input is a 1-D contiguous float32 or float64 array and any mask has matching length.