hispecdrp.primitives.utils.ccf.ccf_common

Shared CCF constants and small helpers used across mask / fit / grid modules.

Functions

_ccf_background_sigma_clipped_median(y, *[, ...])

Iterative sigma-clipped median — robust CCF continuum / background level.

_ccf_background_sigma_clipped_median_dv_weighted(...)

Continuum level with trapezoid-Δv weights.

_ccf_rv_err_numeric_floor(v_step_m_s)

Minimum positive RV uncertainty (m/s) for numerical stability only.

_ccf_trapezoid_dv_weights_m_s(v_m_s)

Trapezoid Δv weights (m/s) for a sorted velocity grid.

_ccf_weighted_median(y, weights)

Weighted median of y with non-negative weights.

_make_velocity_grid(v_min, v_max, v_step)

Uniform RV trial grid in m/s (matches Numba chunk CCF grid spacing).

_velocity_grid_from_window(vel_window, vel_step)

Uniform RV trial grid spanning vel_window (m/s) centered on vsys.

ccf_oversample_nsp(pix_size_m_s, v_step_m_s)

Number of CCF velocity samples per independent detector pixel.

effective_ccf_v_step_for_fit(v_grid)

Finest positive velocity spacing (m/s) on v_grid for CCF RV fits.

resolve_ccf_broad_grid_m_s([v_min, v_max, ...])

Broad uniform CCF velocity grid (m/s); None uses module defaults.

science_centroid_spec_err(spec, spec_err[, ...])

Per-pixel σ for centroiding blaze-corrected (or native) flux.

_ccf_background_sigma_clipped_median(y, *, n_sigma=3.0, max_iter=8, min_keep=5)[source]

Iterative sigma-clipped median — robust CCF continuum / background level.

_ccf_background_sigma_clipped_median_dv_weighted(v_m_s, y, *, n_sigma=3.0, max_iter=8, min_keep=5)[source]

Continuum level with trapezoid-Δv weights.

Weighting by Δv restores a wing-dominated baseline on non-uniform grids and matches uniform-grid behaviour when spacing is constant.

_ccf_rv_err_numeric_floor(v_step_m_s)[source]

Minimum positive RV uncertainty (m/s) for numerical stability only.

_make_velocity_grid(v_min, v_max, v_step)[source]

Uniform RV trial grid in m/s (matches Numba chunk CCF grid spacing).

_velocity_grid_from_window(vel_window, vel_step, vsys=0.0)[source]

Uniform RV trial grid spanning vel_window (m/s) centered on vsys.

ccf_oversample_nsp(pix_size_m_s, v_step_m_s)[source]

Number of CCF velocity samples per independent detector pixel.

Interpolated CCF(v) on a grid finer than Δv_pix reuses the same pixels, so Fisher / LM covariances that treat bins as i.i.d. must inflate σ_μ by √nsp with nsp = max(Δv_pix / Δv_grid, 1).

effective_ccf_v_step_for_fit(v_grid)[source]

Finest positive velocity spacing (m/s) on v_grid for CCF RV fits.

resolve_ccf_broad_grid_m_s(v_min=None, v_max=None, v_step=None)[source]

Broad uniform CCF velocity grid (m/s); None uses module defaults.

science_centroid_spec_err(spec, spec_err, spec_uncal=None, spec_uncal_err=None)[source]

Per-pixel σ for centroiding blaze-corrected (or native) flux.

A multiplicative fiberflat / blaze error is almost entirely amplitude, not line centroid. When L1 spec_uncal / spec_uncal_err are present, map the science-extract relative error onto spec:

σ = |spec| · |spec_uncal_err / spec_uncal|

(equivalent to σ_uncal / blaze). Fall back to spec_err where those arrays are missing or invalid.