hispecdrp.primitives.utils.ccf.ccf_line_mask_spline

Line-mask stellar RV via cubic-spline mask CCF and calc_ccf_metrics().

Functions

_ccf_metrics_to_preview_fits(metrics)

Map CCFMetrics to stellar-RV preview gaussian_fit / bisector_fit slots.

_fit_ccf_metrics_on_stored_ccf(vel_grid, ...)

Gaussian + bisector metrics on spline mask CCF rows.

_fit_spline_mask_ccf_metrics(vel_grid, ...)

Fit CCFMetrics on a spline mask CCF with mask-line peak seeding.

_line_mask_spline_peak_index(v_grid, ccf_raw)

Prominence-based peak index on -ccf_raw (mask-line convention).

_pipeline_rv_from_metrics(metrics, *[, ...])

Chunk RV from CCFMetrics Gaussian fit only.

_resolve_spline_mask_metrics_center_m_s(...)

Metrics-window center: prominence peak, optionally recentered near prior_m_s.

_stored_corr_strength_in_window(vel_grid, ...)

Correlation-peak strength in [anchor±half_width] (larger = stronger), or NaN.

finalize_ccf_preview_dict_spline(...[, ...])

Build _ccf_preview_by_fiber using calc_ccf_metrics() per slot.

fit_line_mask_order_mean_rv_spline(vel_grid, ...)

Order-mean RV for a single-chunk echelle row using calc_ccf_metrics().

line_mask_scout_center_m_s(scout_rvs, ...)

Velocity center from a coarse scout pass on mask CCFs.

rv_per_chunks_line_mask_spline(wave_um, ...)

Per-chunk line-mask RV via compute_ccf_spline() + calc_ccf_metrics().

finalize_ccf_preview_dict_spline(order_slots, all_ccf_rows, v_grid, v_min, v_max, v_step, all_ccf_err_rows=None, *, gaussian_seed_mean_m_s=None, metrics_fit_half_width_m_s=None)[source]

Build _ccf_preview_by_fiber using calc_ccf_metrics() per slot.

Same layout as finalize_ccf_preview_dict().

fit_line_mask_order_mean_rv_spline(vel_grid, ccf_mean_stored, ccf_err_mean=None, *, gaussian_seed_mean_m_s=None, metrics_fit_half_width_m_s=None)[source]

Order-mean RV for a single-chunk echelle row using calc_ccf_metrics().

Returns (rv, rv_err, used_order_mean).

line_mask_scout_center_m_s(scout_rvs, v_grid, ccf_stored_mean)[source]

Velocity center from a coarse scout pass on mask CCFs.

Prefer the RV already measured by the scout chunk worker (Gaussian centroid after the Numba seed). That estimate is typically within a coarse-grid step of the true peak.

Do not use a global argmax on the mean stored CCF: with LINE_MASK_CCF_STORED_NEGATED_FROM_RAW the stored series is often entirely negative and the true alignment is a minimum of the stored values, so argmax-style scouts can land hundreds of km/s away from the real peak.

Falls back to the same prominence peak used by _fit_spline_mask_ccf_metrics(), then to a sub-pixel extremum on the stored CCF if needed.

rv_per_chunks_line_mask_spline(wave_um, spec, spec_err, dq_bad_mask, mask_lines, *, window_size_um, v_min_m_s=-500000.0, v_max_m_s=500000.0, v_step_m_s=50.0, v_grid_m_s=None, zb=0.0, return_ccf=False, min_good_pixels=10, window_line_by_line=False, line_mask_line_chunk_v_center_m_s=None, gaussian_seed_mean_m_s=None, metrics_fit_half_width_m_s=None, line_set_velocity_m_s=None)[source]

Per-chunk line-mask RV via compute_ccf_spline() + calc_ccf_metrics().

Chunking matches rv_per_chunks_line_mask(). Stored CCF rows follow LINE_MASK_CCF_STORED_NEGATED_FROM_RAW.

The spline CCF freezes its line set at line_set_velocity_m_s when finite; otherwise at gaussian_seed_mean_m_s, then line_mask_line_chunk_v_center_m_s. If none of those are set (broad scout with no input RV), membership is recomputed at each trial velocity — freezing at rest with \(F=0\) for missing lines creates false CCF minima on wide grids.

Returns also include per-chunk Queloz bis / bis_err (m/s) from CCFMetrics.