hispecdrp.primitives.spectral_extraction.extract_spectroperfection

Spectroperfection extract from TraceProf shear + LSF moments.

Forward operator: each spectral sample deposits a sheared spatial profile (from the fiberflat) along iso-λ. Default spectral_kernel='bilinear' inverts that pixel-grid operator (LSF geometry via the measured shear). spectral_kernel='gaussian' also inverts an LFC-measured spectral LSF.

Functions

_gauss_pdf(dx, sigma)

_pix_lo_hi(ny, pix_range)

extract_spectroperfection(rate, rate_var, ...)

Banded weighted LS spectroperfection extract.

forward_spectroperfection(spec, profile_img, ...)

Deposit spec with the spectroperfection operator (d = A f).

iter_spectroperfection_weights(trace_y, ...)

Yield (j, y, x, weight): detector spectral row j, cross-disp y, source spectral sample x.

_gauss_pdf(dx, sigma)[source]
_pix_lo_hi(ny, pix_range)[source]
_profile_on_cut(profile_img, x, window_inds, yc, shear)[source]

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

extract_spectroperfection(rate, rate_var, profile_img, trace_y, *, extraction_aperture, shear=None, sigma_spec=None, lsf_n_sigma=5.0, rate_dq=None, do_not_use=1, pix_range=None, spectral_kernel='bilinear', ridge_frac=None)[source]

Banded weighted LS spectroperfection extract.

profile_img is the 2-D fiberflat spatial profile. shear is the iso-λ tilt from LFC spots. The default spectral_kernel='bilinear' inverts the sheared pixel-grid deposit (same 1-D basis as box/optimal); 'gaussian' additionally inverts an LFC-measured spectral LSF and needs ridge_frac to stay stable on real PSFs.

forward_spectroperfection(spec, profile_img, trace_y, *, extraction_aperture, shear=None, sigma_spec=None, lsf_n_sigma=5.0, pix_range=None, spectral_kernel='bilinear')[source]

Deposit spec with the spectroperfection operator (d = A f).

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).

iter_spectroperfection_weights(trace_y, profile_img, *, extraction_aperture, shear, sigma_spec, lsf_n_sigma=5.0, pix_range=None)[source]

Yield (j, y, x, weight): detector spectral row j, cross-disp y, source spectral sample x.