hispecdrp.primitives.stellar_rv.rv_differential_utils

Matched-line differential RV helpers (joint inliers + line QC).

Used by recovery / bulk differential tests and by multi-bulk ccfopt mask culls. The differential estimator is intentionally not agg(B) − agg(A): it matches lines by wavelength and requires joint inlier membership (or applies QC gates) so epoch-asymmetric clipping cannot create a spurious ΔRV.

Functions

ccf_peak_velocity_m_s(ccf, v_min, v_step)

Velocity of the discrete CCF maximum (stored peak-up convention).

estimate_matched_line_differential_rv(tbl_a, ...)

Estimate drv = inject_b − inject_a from matched line-by-line RVs.

line_passes_hard_qc(rv_m_s, rv_err_m_s, *, ...)

Hard single-line QC: finite, err/center gates, optional Gaussian≠peak hop.

match_rvccf_rows_by_wavelength(tbl_a, tbl_b, *)

Greedy nearest-wavelength match of RVCCF rows (velocity half-window).

ccf_peak_velocity_m_s(ccf, v_min, v_step)[source]

Velocity of the discrete CCF maximum (stored peak-up convention).

estimate_matched_line_differential_rv(tbl_a, tbl_b, *, inject_a_m_s, inject_b_m_s, match_half_m_s=5000.0, require_joint_inliers=True, max_rv_err_m_s=10.0, max_abs_rv_from_center_m_s=5000.0, peak_hop_max_m_s=100.0, max_abs_line_diff_resid_m_s=2.0, max_weight_fraction=0.05)[source]

Estimate drv = inject_b − inject_a from matched line-by-line RVs.

Uses joint inliers (recommendation #2), hard QC / peak-hop / leverage caps (#4), and returns the inverse-variance mean of RV_b − RV_a among kept lines (#1) — not agg(B) − agg(A).

line_passes_hard_qc(rv_m_s, rv_err_m_s, *, center_m_s, ccf_peak_m_s=None, max_rv_err_m_s=10.0, max_abs_rv_from_center_m_s=5000.0, peak_hop_max_m_s=100.0)[source]

Hard single-line QC: finite, err/center gates, optional Gaussian≠peak hop.

match_rvccf_rows_by_wavelength(tbl_a, tbl_b, *, match_half_m_s=5000.0)[source]

Greedy nearest-wavelength match of RVCCF rows (velocity half-window).

Returns arrays aligned on matched pairs: wavelengths, RVs, errors, orders, inlier flags, and optional CCF metadata for peak-hop QC.