Stellar RV primitive (L2)
The HISPEC DRP supports two cross-correlation based stellar radial-velocity (RV) algorithms
dispatched by StellarRVPrimitive:
ccf_stellar_templateCross-correlate an observed spectrum against a (rest-frame) template spectrum in \(\ln\lambda\) and fit the CCF peak to estimate RV.
ccf_line_maskCross-correlate an observed spectrum against a line mask (a weighted list of line locations, optionally with finite widths), producing a mask statistic as a function of trial velocity and fitting its peak to estimate RV.
For line-mask file formats, MaskLines conventions, and
template-to-mask generation, see Line masks.
For shared CCF machinery (template and mask-line paths, peak fitting, and deriving RV from a CCF
curve in ccf_utils), see Cross-correlation (CCF).
Primitive overview and references
At a high level, StellarRVPrimitive:
reads
SPEC_FIB*,SPEC_ERR_FIB*,SPEC_DQ_FIB*, andWAVE_FIB*from the input L2 model,runs the selected algorithm per fiber and (optionally) a subset of echelle orders,
writes
RVCCF_FIB*/RVCCFAVG_FIB*(and optional CCF supplement columns) on the output L2 clone, andoptionally writes/opens Plotly previews and overlay-debug HTML via
hispecdrp.primitives.stellar_rv.previews.stellar_rv_preview.
The ccf_line_mask implementation is inspired by public mask-line CCF descriptions and open code
in the community; HISPEC DRP does not ship Keck KPF pipeline source.
References
KPF mask-line algorithm reference (
alg_rv_mask_line.py): https://github.com/Keck-DataReductionPipelines/KPF-Pipeline/blob/81609b0ac0ab6d12536fb771bfdd0112001340c3/modules/radial_velocity/src/alg_rv_mask_line.pyKPF radial_velocity module source tree: https://github.com/Keck-DataReductionPipelines/KPF-Pipeline/tree/81609b0ac0ab6d12536fb771bfdd0112001340c3/modules/radial_velocity/src
spirou-ccf helper library (
spiroulib.py): https://github.com/edermartioli/spirou-ccf/blob/main/spiroulib.pyspirou-ccf example masks: https://github.com/edermartioli/spirou-ccf/tree/main/ccf_masks
Units and conventions
Velocities: internally, RVs and CCF velocity axes are in m/s across both algorithms. Some preview surfaces may display km/s for readability (labels/hover text), but stored values and primitive inputs/outputs remain m/s unless explicitly documented otherwise.
Wavelengths: wavelength arrays and chunk centers are in micron (µm), and chunk sizing uses
window_size_um(µm).Tables: outputs are written to
RVCCF_FIB*(per-chunk) andRVCCFAVG_FIB*(fiber summary). Column units follow the table schema (typically RV in m/s and wavelength in µm).
RV tables and data storage (RVCCF)
L2 datamodel formatting (code references)
The RV tables are defined as L2 datamodel extensions in
hispecdrp.datamodels.extensions. The helper
create_rv_extensions() maps these HDU schemas to the
fiber-specific HDU names (e.g. RVCCF_FIB1).
The canonical column definitions are the module-level dictionaries:
RVCCF_HDURVCCFAVG_HDU
The stellar RV primitive writes two main product tables per fiber:
RVCCF_FIB*Per-chunk measurements. Each row corresponds to a wavelength chunk (or line-window segment when line-by-line chunking is used). The table includes:
RV/RV_ERR: per-chunk RV estimate and uncertainty (m/s)ORDER: echelle order numberWAVELENGTH: chunk center wavelength (µm)INLIER: robust inlier mask used for aggregationoptional CCF supplement columns (velocity axis metadata and CCF arrays) when enabled
RVCCFAVG_FIB*Aggregate RV and uncertainty for the fiber. The RV combination uses robust outlier rejection (median/MAD) followed by an inverse-variance weighted mean; the reported uncertainty is \(\\max(\\sigma_{\\mathrm{IVW}},\\,\\mathrm{MAD}/\\sqrt{N})\). In the infinite-S/N limit this converges to the empirical
MAD/√Nfloor.
For details of the combination logic, see
combine_rv_estimates_median_mad_weighted().
Preview plots
The pipeline provides two preview surfaces:
- Unified Plotly preview
The standard stellar-RV preview (RV vs wavelength, CCF + Gaussian fits, residuals) is produced by
create_stellar_rv_preview().- Overlay debug HTML
Interactive spectrum + CCF overlay HTML for debugging mask-line (and template) behavior. For
ccf_line_mask, the spectrum panel shows the observed spectrum with shifted mask segments, and a dense Lagrange-interpolated spectrum trace using the same interpolation order as the mask CCF.
The overlay debug page is written by
write_mask_overlay_debug_pages().
Workflow outline (ccf_line_mask)
This is a high-level outline of what StellarRVPrimitive
does when algorithm="ccf_line_mask" for one fiber (the template-CCF algorithm follows a different path).
Entry point
_run_algorithm_ccf_line_mask()resolves coarse velocity grid defaults (v_min_coarse,v_max_coarse,v_step_coarse), optional centered-window configuration aroundccf_input_velocity(v_half_window), loads mask lines once, then calls the fiber driver:Velocity axis
The fiber driver constructs a uniform velocity grid:
ccf_input_velocity ± v_half_windowatv_step_coarsewhen a center is set.
When
ccf_input_velocityis unset, an auto-center scout runs one pass on the broad uniform grid to estimate the peak, then rebuilds a centered uniform window for the fiber.Per-order chunking and mask CCF
For each echelle order in
do_orders, the driver computes wavelength chunks:fixed-width chunks via
ccf_order_n_chunks_for_span(), orline-by-line Voronoi chunks when
window_line_by_line=Trueandccf_input_velocityis finite (seebuild_line_mask_chunk_wavelength_intervals_line_by_line()).
The per-order worker calls:
which runs the Numba kernel over all chunks (parallel
prangeover chunk index when applicable):producing per-chunk arrays
CCF(v)and (when requested)ccf_err(v).Per-chunk RV and uncertainty
Per-chunk RVs come from a Gaussian fit to the (stored-convention) CCF:
Line-mask path:
fit_ccf_rv()viarv_per_chunks_line_mask()(Numba Lagrange sampler;mask_ccf_pixel_interp_order/max_cores)Legacy / template helpers:
fit_ccf_rv()
The reported chunk
RV/RV_ERRare the Gaussian centroid and its photon-weighted Gaussian uncertainty (interpolated science-pixel errors, oversampling-corrected). Fiberflat / blaze terms inSPEC_ERRare not used as independent CCF-bin noise. Per-chunkRV_ERRdecreases with S/N and converges to a numerical floor in the noiseless limit. A discrete-peak Numba seed may be used only when the Gaussian fit does not succeed.CCF sign convention: stored CCF rows (RVCCF / preview slots) follow the negated convention so the absorption-like feature appears as a peak near the true RV (see
LINE_MASK_CCF_STORED_NEGATED_FROM_RAW).Fiber-level aggregation
Chunk-level estimates are robustly combined into a fiber RV using:
with fallback to per-chunk MAD rejection + inverse-variance mean when needed.
Previews and RVCCF supplement
When previews are requested, the driver builds preview slots and runs per-slot Gaussian/refine:
When requested for table outputs, the primitive may also build RVCCF supplement columns:
Additional notes (primitive behavior and details)
Default coarse CCF step: when
v_step_coarseis unset, the default coarse step is 50 m/s (ccf_common.V_STEP_DEFAULT_M_S). Very long velocity grids may be subsampled insidefit_ccf_rv()to keep fitting robust and fast.Overlay debug HTML chunking and gating: the mask/template overlay debug pages list wavelength chunks (matching
window_size_umchunking, or line-by-line Voronoi bins whenwindow_line_by_line=True) and gate chunk inclusion withccf_min_good_pixelsand data quality flags (e.g.DO_NOT_USE), consistent with the underlying chunk drivers.Overlay embedded array downsampling (display-only): for the overlay debug preview HTML only, embedded arrays (spectrum / CCF / template traces) are downsampled before being written into the page to keep file sizes reasonable. This affects what is plotted in the browser, not the underlying pipeline arrays or RVCCF products. Limits are controlled by the environment variables
HISPEC_DRP_MASK_OVERLAY_SPECTRUM_MAX_POINTS,HISPEC_DRP_MASK_OVERLAY_CCF_MAX_POINTS, andHISPEC_DRP_TEMPLATE_OVERLAY_MAX_TEMPLATE_POINTS(seestellar_rv_preview).Dense interpolated spectrum trace in overlay debug HTML: the overlay debug page always includes a dense Lagrange-interpolated spectrum trace using the same interpolation order as the mask CCF (
mask_ccf_pixel_interp_order). See “Preview plots” above for the dense grid formula.Overlay initial velocity: the overlay page’s initial velocity matches finite
ccf_input_velocitywhen set; otherwise it defaults to0m/s.
Unit tests and command-line overrides
The main integration tests for stellar RV live in tests/stage2/test_stellar_rv_primitive.py.
Useful command-line / environment overrides used by these tests include:
HISPEC_DRP_SHOW_BSPEC_BTSETTL_PREVIEWS=1Single switch for optional stellar-RV previews in
tests/stage2/test_stellar_rv_primitive.py: after BT-Settl BSPEC integration tests, write and open preview HTML (mask-overlay + unified Plotly forccf_line_mask, and unified Plotly + template-overlay HTML forccf_stellar_templatewhen that optional leg runs). Also enables the unified Plotly preview intest_stellar_rv_primitive_recovers_rv_per_chunk. Forces HTML-only behavior for the unified Plotly preview (skips Kaleido PNG export when this env is set; seehispecdrp.primitives.stellar_rv.previews.stellar_rv_preview). When unset, those optional preview legs are skipped.HISPEC_DRP_MASK_CCF_PIXEL_INTERP_ORDER=<int>Override the mask CCF interpolation order used by the tests (and reflected in the overlay debug spectrum interpolation trace label).
HISPEC_DRP_BSPEC_BTSETTL_ORDERWhich BSPEC echelle orders the BT-Settl BSPEC tests use. Default when unset is
139(single order). Set toallto use every BSPEC order fromHISPECConfig(same as the formerHISPEC_DRP_BSPEC_BTSETTL_ALL_ORDERS=1). Otherwise a comma-separated list of integer echelle orders (e.g.139,140).HISPEC_DRP_BSPEC_BTSETTL_WINDOW_UM=<float>Override the chunk width (µm) used in the BT-Settl BSPEC tests.
HISPEC_DRP_BSPEC_BTSETTL_RELAX_PARALLEL_ASSERTS=1Relax strict RV recovery / benchmark assertions for exploratory runs (previews still run).
See also
hispecdrp.primitives.utils.ccf.ccf_utils— template CCF + mask-line CCFhispecdrp.primitives.stellar_rv.previews.stellar_rv_preview— preview generation
API references
- class StellarRVPrimitive(dataset=None, config=None, context=None, log_config=None, parent=None, **kwargs)[source]
Bases:
BasePrimitiveCross-correlate L2 spectra against a template or a line mask to measure RV.
Algorithms
ccf_line_mask(default) — mask-shifted CCF using a line mask (SPIROU.masor two-column center+weight tables; seeline_mask_utils). Per-chunk CCFs use Numba Lanczos / linear spectrum sampling (rv_per_chunks_line_mask()/mask_ccf_pixel_interp_order; default Lanczos-3); final RVs are Gaussian centroids fromfit_ccf_rv().ccf_stellar_template— weighted CCF in \(\ln\lambda\) against a stellar template; per-chunk RVs; median/MAD rejection; inverse-variance mean (ccf_utils).
All constructor arguments list their default from
PARAMETERS; override per run as needed. Order matches the grouped layout inPARAMETERS.- Parameters:
suffix (str) – Default:
"stellar_rv". Short label used by the framework for this primitive’s derived products, logging, and file naming together withoutput_dir.algorithm (str) – Default:
"ccf_line_mask". Must be a key ofSTELLAR_RV_ALGORITHMS. Chooses_run_algorithm_ccf_line_mask(line-mask CCF, no PHOENIX template) or_run_algorithm_ccf_stellar_template(log-λ template CCF).do_fibers (sequence of str or None) – Default:
None. Which fiber indices to process (e.g.["1","2"]).Noneusesget_do_traces()/ recipe defaults for the input model.do_orders (sequence of int or None) – Default:
None. Echelle order numbers (not row indices) to include.Noneselects all orders handled by the same L2 helper as sibling primitives (subject to config / model).template_path (str or None) – Default:
None. Path to a stellar template spectrum on disk forccf_stellar_template. Passed toresolve_stellar_template_to_log_micron()withtemplate_wavelength/template_fluxwhen those are set.template_wavelength (array-like or None) – Default:
None. In-memory template wavelength grid (µm). Used withtemplate_fluxwhen you do not load fromtemplate_path.template_flux (array-like or None) – Default:
None. Template flux samples matchingtemplate_wavelength(same length).mask_path (str or None) – Default:
None. Path to a SPIROU.masor KPF-style two-column mask file forccf_line_mask(delta-line model).Noneresolves to the packaged lte049 ccfopt delta mask (seepackaged_default_line_mask_path()) viaresolve_mask_path()when you are not passingmask_wavelength/mask_weight.mask_wavelength (array-like or None) – Default:
None. In-memory mask rest wavelengths (µm) forccf_line_mask. Must be paired withmask_weight; when both are set,mask_pathis not required for loading.mask_weight (array-like or None) – Default:
None. Weights matchingmask_wavelength(same length).mask_ccf_pixel_interp_order (int) – Default:
3. Mask algorithm only: Lanczos parameter a (1= linear;3= Lanczos-3 windowed-sinc in pixel-index space) for sampling flux and the per-pixel gate onto Doppler-shifted mask-line wavelengths in_calc_mask_ccf_chunks_numba(). Values are clamped to[1, ccf_utils.MAX_MASK_CCF_PIXEL_INTERP_ORDER]. Values greater than 1 use Lanczos-a (not historical Lagrange polynomials).window_size_um (float) – Default:
0.25. Approximate wavelength span (µm) of each chunk along an order: spectra are split into contiguous bins of roughly this width for per-chunk RVs (template algorithm) or mask CCF chunking (mask algorithm).outlier_sigma (float) – Default:
3.0. Multiplier for error-aware chunk rejection before the inverse-variance weighted mean: keep chunks with|RV − center| <= outlier_sigma * max(MAD, σ_i)(seecombine_stellar_rv_chunk_estimates()).chunk_rv_max_abs_m_s (float) – Default:
120000.0(120 km s−1). Per-chunk RVs with|RV|above this limit are excluded before aggregation (coarse-grid CCF alias peaks). Set very large to disable. Ignored whenccf_input_velocityis set (prior gate used instead).chunk_rv_prior_half_width_m_s (float or None) – Default:
None. Whenccf_input_velocityis set, keep only chunks with|RV − ccf_input_velocity| <= half_widthbefore aggregation.Noneusesmax(2000, 0.5 × v_half_window)m/s.window_line_by_line (bool) – Default:
True. Line-mask algorithm only (ccf_line_mask). Ignored forccf_stellar_template(that path always chunks onwindow_size_um). WhenFalse, chunk boundaries followwindow_size_umviaccf_order_n_chunks_for_span(). WhenTrue, each mask line defines its own wavelength chunk (Voronoi bins in observed λ atccf_input_velocity, which must be finite — grid center). Spectral pixels per chunk use the intersection of that Voronoi interval with a symmetricwindow_size_umband; seebuild_line_mask_chunk_wavelength_intervals_line_by_line().v_min_coarse (float or None) – Default:
None. Broad uniform CCF lower bound (m/s) when no center is set (scout / full-range search).None→V_MIN_DEFAULT_M_S.v_max_coarse (float or None) – Default:
None. Broad uniform CCF upper bound (m/s).None→V_MAX_DEFAULT_M_S.v_step_coarse (float or None) – Default:
25.0. Uniform velocity sampling (m/s) for both the broad and centered grids.None→V_STEP_DEFAULT_M_S.ccf_input_velocity (float or None) – Default:
None. If set (m/s), the CCF uses a uniform window centered here:[ccf_input_velocity − v_half_window, ccf_input_velocity + v_half_window]atv_step_coarse. IfNone, a scout pass on the broad uniform grid estimates the peak, then the fiber is evaluated on a centered window (v_half_windowatv_step_coarse).v_half_window (float) – Default:
15000.0. Half-width (m/s) of the centered uniform velocity window (±this value aroundccf_input_velocityor the auto-scout center).ccf_zb (float) – Default:
0.0. Both algorithms: barycentric factor \(z_b\). Forccf_line_maskit enters \(\lambda_{\rm obs} = \lambda_{\rm rest}(1+v/c)/(1+z_b)\) (zbinrun_ccf_line_mask_for_fiber()/rv_per_chunks_line_mask()). Forccf_stellar_templateit applies the same multiplicative shift in \(\ln\lambda\) template evaluation as in_ccf_chunk_ccf_numba(). Set by the caller or pipeline (e.g.Stage2Pipelinepopulates this fromBARYCORRBERVwhen not overridden).ccf_min_good_pixels (int) – Default:
9. Both algorithms: minimum unmasked finite spectral pixels per wavelength chunk (chunking fromwindow_size_umviaccf_order_n_chunks_for_span(), or fromwindow_line_by_lineVoronoi bins) required to form a CCF and fit an RV. Forccf_line_maskthis ismin_good_pixelsinrv_per_chunks_line_mask(); forccf_stellar_templateit gates the Numba per-chunk CCF and the Python per-chunk fit. Overlay debug HTML uses the same threshold for chunk inclusion.output_model (str) – Default:
"L2Model". Datamodel type name passed toget_output_model()when cloning the input to attach RVCCF tables.max_cores (int or None) – Default:
None. Upper bound on parallel Numba threads: template path uses it for echelle-order parallelism; mask path passes it torun_ccf_line_mask_for_fiber()/ chunk loops.Noneletsresolve_numba_threads()pick a host-appropriate count;1forces single-threaded, reproducible runs.debug_ccf (bool) – Default:
False. Extra logging and diagnostics. Forccf_stellar_template, forces the slower non-Numba CCF path instead of the parallel driver.preview_write_png (bool) – Default:
True. Whensave_previewis True, also write a stacked Kaleido PNG alongside the HTML preview. Set False for large line-mask runs (many CCF slots) where PNG export can take minutes or hang in headless Chrome.preview_png_scale (float) – Default:
2.0. Pixel scale multiplier for Kaleido PNG exports whensave_previewandpreview_write_pngare True (seestellar_rv_preview).show_overlay_debug (bool) – Default:
False. Forccf_line_mask, open mask-overlay debug HTML in a browser; forccf_stellar_template, open template-overlay debug HTML. Meaning followsalgorithm.save_overlay_debug (bool) – Default:
False. Forccf_line_mask, write mask-overlay HTML (_output["mask_overlay_debug"]); forccf_stellar_template, write template-overlay HTML (_output["template_overlay_debug"]).
- _combine_chunk_rvs(all_rvs, all_rv_errs, *, fiber)[source]
Robust per-fiber aggregate from chunk RV arrays (sanity gate + MAD + weighted mean).
Returns
(inlier_mask, rv_mean_m_s, rv_std_m_s).
- _create_preview()[source]
- static _get_spectrograph(input_model)[source]
Return spectrograph name from model metadata.
- Parameters:
input_model (DataModel) – Input data model with meta.spectrograph.
- Returns:
str – “BSPEC” or “RSPEC” if present in metadata; otherwise “BSPEC”.
- _process_fiber(input_model, output_model, fiber, spectrograph, do_orders, order_vec, template_ln, template_flux)[source]
Run the configured stellar RV algorithm for one fiber and write RVCCF/RVCCFAVG.
Dispatches to the algorithm named in
self.algorithm(seeSTELLAR_RV_ALGORITHMS). The algorithm returns per-chunk arrays, aggregate RV, and optional per-chunk CCF supplement columns; this method writesRVCCF_FIB{fiber}(merged RV + CCF) andRVCCFAVG_FIB{fiber}to the output model.- Parameters:
input_model (DataModel) – Open L2 (or compatible) model with per-fiber
SPEC_FIB*/WAVE_FIB*(and optional ERR/DQ). Used to read science data for the chosen fiber.output_model (DataModel) – Cloned L2 output; receives Astropy tables on attributes
rvccf_fib*/rvccfavg_fib*(framework naming).fiber (str) – Fiber id string, e.g.
"1", matching attribute suffixes_FIB1.spectrograph (str) –
"BSPEC"or"RSPEC"from metadata; stored in RV tables for downstream.do_orders (list of int) – Echelle order numbers to include in the CCF (subset of
order_vec).order_vec (list of int) – Map from echelle row index to physical order number (one entry per spectral row).
template_ln (np.ndarray) – Natural log of template wavelength in microns; used by template algorithm. For
ccf_line_maskthis is an empty placeholder array.template_flux (np.ndarray) – Template flux aligned with
template_ln; empty for mask-only algorithm.
- _process_fiber_orders(order_tasks, wave, spec, err, dq, do_not_use, template_ln, template_flux, fiber, *, mode, max_cores=None, want_preview=False, v_min_m_s=-500000.0, v_max_m_s=500000.0, v_step_m_s=50.0, ccf_center_m_s=None, ccf_half_window_m_s=20000.0)[source]
Single driver for per-order chunk RVs:
modeisdebug(Pythonmasked_ccf_rvper chunk) orparallel(Numba). Whenwant_previewis True, the parallel path reuses the flat CCF stack for the preview dict; debug + preview usesbuild_ccf_preview_dict()withkind="spectra_orders".- Parameters:
order_tasks (list of tuple) –
(row_index, order_number)for each echelle row to process (already filtered bydo_orders).wave (np.ndarray) – 2D echelle data for the fiber: wavelength, flux, error, and DQ (same shape).
spec (np.ndarray) – 2D echelle data for the fiber: wavelength, flux, error, and DQ (same shape).
err (np.ndarray) – 2D echelle data for the fiber: wavelength, flux, error, and DQ (same shape).
dq (np.ndarray) – 2D echelle data for the fiber: wavelength, flux, error, and DQ (same shape).
do_not_use (int) – DQ bitmask for pixels to exclude from CCF (typically
DQ_FLAGS["DO_NOT_USE"]).template_ln (np.ndarray) – Template in log(µm) and flux for CCF (same length).
template_flux (np.ndarray) – Template in log(µm) and flux for CCF (same length).
fiber (str) – Fiber id for logging.
mode (str) –
"debug"(verbose diagnostics) or"parallel"(Numba).max_cores (int or None, optional) – Effective thread count for parallel mode (already resolved/capped).
want_preview (bool, optional) – Whether to build the mean + per-order CCF preview structure for Plotly.
v_min_m_s (float, optional) – Uniform CCF velocity axis (m/s): broad search from the primitive’s
v_min_coarse/v_max_coarse/v_step_coarse(after defaults). Whenccf_center_m_sis set,v_step_m_ssamples the centered window.v_max_m_s (float, optional) – Uniform CCF velocity axis (m/s): broad search from the primitive’s
v_min_coarse/v_max_coarse/v_step_coarse(after defaults). Whenccf_center_m_sis set,v_step_m_ssamples the centered window.v_step_m_s (float, optional) – Uniform CCF velocity axis (m/s): broad search from the primitive’s
v_min_coarse/v_max_coarse/v_step_coarse(after defaults). Whenccf_center_m_sis set,v_step_m_ssamples the centered window.ccf_center_m_s – When
ccf_center_m_sis notNone, build a uniform window viabuild_centered_uniform_velocity_grid()(ccf_input_velocity,v_half_window,v_step_coarseon the primitive).ccf_half_window_m_s – When
ccf_center_m_sis notNone, build a uniform window viabuild_centered_uniform_velocity_grid()(ccf_input_velocity,v_half_window,v_step_coarseon the primitive).
- Returns:
tuple –
(all_rvs, all_rv_errs, all_wavelengths, all_orders, preview_detail, rvccf_chunk_supplement)— lists of per-chunk quantities (same length), optional preview dict, and optional CCF supplement table (merged intoRVCCF_FIB*by_write_rv_tables).
- _resolve_chunk_rv_prior_half_width_m_s()[source]
Half-width (m/s) for prior-gated chunk aggregation when a CCF center is set.
- _run_algorithm_ccf_line_mask(input_model, output_model, fiber, spectrograph, do_orders, order_vec, template_ln, template_flux)[source]
Line-mask CCF (SPIROU/KPF-inspired) + Gaussian RV fit.
Minimal delegation to
run_ccf_line_mask_for_fiber().
- _run_algorithm_ccf_stellar_template(input_model, output_model, fiber, spectrograph, do_orders, order_vec, template_ln, template_flux)[source]
Stellar-template cross-correlation + median/MAD + inverse-variance weighted mean.
Cross-correlates the stellar template spectrum to the input spectrum in log(wavelength), producing per-chunk RVs (debug Python or Numba-parallel). Chunk RVs are combined with median/MAD outlier rejection and a weighted mean; CCF curves may be stored for the preview. Returns the standard 6-tuple for _write_rv_tables.
- Returns:
all_wavelengths (np.ndarray) – Chunk center wavelengths (µm).
all_rvs (np.ndarray) – Per-chunk RV (m/s).
all_rv_errs (np.ndarray) – Per-chunk RV uncertainty (m/s).
inlier (np.ndarray) – Boolean mask of chunks used for the aggregate.
rv_mean (float) – Aggregated RV (m/s).
rv_std (float) – Uncertainty of the aggregated RV (m/s).
- _write_rv_tables(output_model, fiber, spectrograph, wavelengths, rvs, rv_errs, rv_agg, rv_agg_err, inlier=None, orders=None, *, rvccf_chunk_supplement=None)[source]
Write RVCCF_FIB{fiber} (per-chunk RV plus optional CCF columns) and RVCCFAVG_FIB{fiber}.
Creates table extensions on the output L2 model with per-chunk RVs and the aggregated RV (mean and std). All velocities are in m/s.
- Parameters:
output_model (DataModel) – L2 output model to update.
fiber (str) – Fiber number (e.g. “1”).
spectrograph (str) – “BSPEC” or “RSPEC”.
wavelengths (np.ndarray) – Chunk center wavelengths (µm).
rvs (np.ndarray) – Per-chunk radial velocity (m/s).
rv_errs (np.ndarray) – Per-chunk RV uncertainty (m/s).
rv_agg (float) – Aggregated RV (e.g. weighted mean) in m/s.
rv_agg_err (float) – Uncertainty of the aggregated RV in m/s.
inlier (np.ndarray, optional) – Boolean mask of chunks used for the aggregate; used for table only.
orders (np.ndarray, optional) – Echelle order number per chunk (same length as
rvs). -1 if unknown.
- static resolve_ccf_zb_for_fiber(primitive, input_model, fiber)[source]
Return the uniform CCF \(z_b\) for previews and overlays.
fiberis accepted for API compatibility; all fibers shareprimitive.ccf_zb.