hispecdrp.primitives.stellar_rv.rv_combine_utils
Helpers for combining per-chunk RV estimates into aggregates.
Functions
Error-aware robust rejection, inverse-variance mean, and IVW uncertainty. |
|
|
Error-aware robust outlier mask on per-chunk RVs. |
|
Aggregate per-chunk RVs for |
|
Inverse-variance weighted mean RV and error on the mean. |
- combine_rv_estimates_median_mad_weighted(rvs, rv_errs, outlier_sigma=4.0, *, center_m_s=None, rv_err_inflation=3.5)[source]
Error-aware robust rejection, inverse-variance mean, and IVW uncertainty.
Outlier rejection uses the uninflated per-chunk
rv_errswithcombine_rvs_median_mad()(|Δ| <= outlier_sigma * max(MAD, σ_i)). Per-chunkrv_errsare scaled byrv_err_inflationonly for IVW weights (default 3.5) so the mean is not dominated by underdispersed formal σ. The reportedrv_stdis \(\max(\sigma_{\mathrm{IVW}},\,\mathrm{MAD}/\sqrt{N})\) of the inliers: photon-weighted IVW when it is honest, and the empirical line scatter when formal σ are optimistic or systematics dominate. As per-chunk σ → 0 (infinite S/N), this converges toMAD/√N. If the median formal σ is >10⁶× the inlier MAD (broken Hessian), IVW is discarded andMAD/√Nis reported. Inflated IVW SE and empiricalMAD/√Nare returned asrv_std_internalandscatter_sefor diagnostics.
- combine_rvs_median_mad(rvs, rv_errs, outlier_sigma=4.0, *, center_m_s=None)[source]
Error-aware robust outlier mask on per-chunk RVs.
Chunks with finite
rvsand positiverv_errsset the rejection center (sample median, orcenter_m_swhen finite) and the ensemble MAD. A chunk is kept when|RV − center| <= outlier_sigma * max(MAD, σ_i)so points that agree within the MAD are never rejected, while points that are both outside the MAD envelope and inconsistent with their own formal
σ_iare rejected. Invalid chunks are marked not inlier.
- combine_stellar_rv_chunk_estimates(rvs, rv_errs, outlier_sigma=4.0, *, chunk_rv_max_abs_m_s=120000.0, chunk_rv_prior_m_s=None, chunk_rv_prior_half_width_m_s=None, median_fallback_sigma=3.0)[source]
Aggregate per-chunk RVs for
StellarRVPrimitive.Applies a sanity gate, error-aware MAD rejection (
|Δ| <= outlier_sigma * max(MAD, σ_i)), and inverse-variance weighting (combine_rv_estimates_median_mad_weighted()). The reported aggregaterv_stdis \(\max(\sigma_{\mathrm{IVW}},\,\mathrm{MAD}/\sqrt{N})\) of the inliers.When
chunk_rv_prior_m_sis finite, the gate keeps|RV − prior| <= half_width(defaultDEFAULT_CHUNK_RV_PRIOR_HALF_WIDTH_M_S) and MAD rejection is anchored to the prior. Otherwise the gate uses|RV| <= chunk_rv_max_abs_m_sand the sample median anchors MAD rejection.When the weighted mean disagrees with the inlier median by more than
median_fallback_sigma × MAD, the median is used for the aggregate RV (guards against alias peaks with underestimated formal errors on coarse CCF grids); the reported uncertainty remains the IVW SE.
- weighted_mean_rv(rvs, rv_errs, inlier)[source]
Inverse-variance weighted mean RV and error on the mean.