Skip to main content

Rust-backed image stack combine + rejection kernels (IRAF imcombine parity)

Project description

imcombiners

(Image + Combiner + Rust(rs)), made for Python.

imcombiners logo

imcombiners was built for astronomical image-stack combination. Generic reductions now live in the companion reducers package; imcombiners focuses on stack combination plus imcombine-style rejection. Pure stack reductions use reducers with imcombiners' finite-only policy: both NaN and inf are skipped.

Documentation: https://ysbach.github.io/imcombiners/ GitHub: https://github.com/ysBach/imcombiners

The package started as a tool for the main developer(@ysBach)'s reduction tools (ysfitsutilpy). It is a result of their graduate school life, TA experience (2016-2023), and astropy image combination TF experience (2020). After years of use & trial using numba, I finally rewrote the core in Rust for better speed, reliability, and maintainability.

Now it targets a modern Python API around Rust kernels, with IRAF IMCOMBINE compatibility but with better speed & API. Tests and benchmark material compare supported paths against IRAF, Astropy/NumPy, ccdproc, and bottleneck where appropriate. On a personal laptop (Apple M4 Pro), I experience a factor of few speedup over IRAF and dozens times over Python-based tools (astropy/ccdproc/bottleneck) for typical use cases. See the Documentation.

First Look

The package has four usage modes: Standard Combiner().combine() approach, compact ndcombine() wrapper, Chained Combiner(), and direct kernel calls. Start with standard Combiner usage for ordinary Python workflows. Use chained Combiner calls when you need retained diagnostics, ndcombine() for compact IRAF-like call sites (this function was made in consideration of CLI tools), and direct kernel calls for custom high-throughput layers.

import numpy as np
import imcombiners as imc

rng = np.random.default_rng(20250311)
stack = rng.normal(1000, 5, (15, 256, 256)).astype("float32")

cmb = imc.Combiner(stack)
out = cmb.combine(
    "median",  # final stack-combination method
    # 1. Optional pre-rejection threshold masking
    thresholds=(0.0, 65000.0),
    # 2. Optional per-image zero/scale normalization
    zero=None,
    scale="median",
    # 3. Optional pixel rejection before final combination
    rejectors=[
        imc.MinMaxClip(n_min=1, n_max=0.1),
        imc.SigClip(sigma=3.0, maxiters=5),
    ],
    diagnostics=None,  # output-only fast path
)

See docs/quarto/index.qmd for the detailed explanations, API-level guidance, and conventions behind this example.

Features

  • Stack combination: mean, median, lower median, percentiles, sum, min, max, variance, and weighted mean via weight=.
  • 1-D rejection helpers: imcombiners.kernels exposes _1d functions such as sigclip_mask_1d, pclip_1d, and minmax_combine_1d. Use the companion reducers package for standalone fast reductions such as mean, median, percentile, and variance.
  • Pixel rejection: sigma, CCD noise-model, iterative linear, min/max, and IRAF-style percentile clipping. Rejection centers accept mean, median, and lower median (lmedian/lmed).
  • Pipeline helpers: threshold masking, zero/scale normalization, offset padding, masks, diagnostics=None|"simple"|"full", and output-only fast paths.
  • Performance docs: see docs/quarto/performance/max-performance.qmd and docs/quarto/performance/image-benchmarks.qmd.

Development Install

# You may activate your Python environment before this, e.g.,
# source ~/.venvs/your_env/bin/activate
uv pip install -e ".[dev]"

Testing and Benchmarks

uv run pytest
uv run --extra bench python benchmarks/benchmark_combine.py
uv run python benchmarks/benchmark_threads.py

--quick runs the smoke benchmark matrix. Omit it to run the full table that backs the published benchmark documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imcombiners-0.1.1.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imcombiners-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (620.0 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file imcombiners-0.1.1.tar.gz.

File metadata

  • Download URL: imcombiners-0.1.1.tar.gz
  • Upload date:
  • Size: 61.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for imcombiners-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff1af76fdd9126749ad48a4eb7fa80624fdc4aa1b777ab135ea36f43c323fe6d
MD5 20a1081e95eb76dc5f2e52121d0b0a3f
BLAKE2b-256 154d86de5dd4330dc09fac892e9b637039c3fba3a8afdff550bf90b28960e8df

See more details on using hashes here.

File details

Details for the file imcombiners-0.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

  • Download URL: imcombiners-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 620.0 kB
  • Tags: CPython 3.10+, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for imcombiners-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27c2c19ca3706999bc024d12cde8ddbf2fce90fcb06d222c58a389b1e00ac856
MD5 e7b3c32ba0a8da55012439ebaeb8f82c
BLAKE2b-256 1aff68927224172786d49413300a99d06b20b53e791ea6695f1458f38d1eea6b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page