hispecdrp.primitives.spectral_extraction.extract_sheared_sp

Iso-λ sheared separable forward model + banded LS extract (spectroperfectionism-lite).

Horne gather/scatter are not inverses when neighboring iso-λ cuts overlap. For a controlled self-check the world must be the scatter operator A, and extraction must solve the normal equations (A^T N^{-1} A) f = A^T N^{-1} d. Noiseless d = A f then round-trips to machine precision.

Functions

_profile_on_cut(profile_img, x, window_inds, ...)

Sample continuum profile along the iso-λ cut (linear in spectral axis).

extract_sheared_banded_ls(rate, rate_var, ...)

Banded weighted LS extract: f = argmin ||N^{-1/2}(d - A f)||.

forward_sheared_separable(spec, profile_img, ...)

Separable forward model M = A f matching the sheared scatter operator.

iter_sheared_scatter_weights(trace_y, ...)

Yield (x, y, row0, row1, w0, w1, pix_weight) scatter terms.

_profile_on_cut(profile_img, x, window_inds, yc, shear)[source]

Sample continuum profile along the iso-λ cut (linear in spectral axis).

extract_sheared_banded_ls(rate, rate_var, profile_img, trace_y, *, extraction_aperture, shear=None, rate_dq=None, do_not_use=1)[source]

Banded weighted LS extract: f = argmin ||N^{-1/2}(d - A f)||.

rate_var is per-pixel variance (rate_err**2). Pixels with non-finite data, non-positive variance, or DO_NOT_USE are dropped.

forward_sheared_separable(spec, profile_img, trace_y, *, extraction_aperture, shear=None)[source]

Separable forward model M = A f matching the sheared scatter operator.

Returns (model, aperture_mask).

get_extraction_window(yc, window_size, n_pixels=-1)[source]

Computes the fractional overlap of pixels with the extraction window.

Parameters:
  • yc (float) – Center of the extraction window (in pixel coordinates).

  • window_size (float) – Size of the extraction window (in pixels) centered in yc.

  • n_pixels (int, optional) – When >= 0, clip candidate indices to [0, n_pixels - 1] so callers never receive out-of-bounds cross-dispersion indices (avoids Numba OOB segfaults when trace positions are extrapolated or non-finite).

Returns:
  • idx (np.ndarray) – Indices of the pixels that might have overlap with the extraction window.

  • W (np.ndarray) – Fractional overlap of each pixel in idx with the extraction window.

iter_sheared_scatter_weights(trace_y, profile_img, *, extraction_aperture, shear)[source]

Yield (x, y, row0, row1, w0, w1, pix_weight) scatter terms.

pix_weight is PP * W for the aperture sample; w0/w1 split that weight across spectral rows row0/row1 (bilinear).