modules.barycentric_correction
KPF Barycentric Correction module.
Computes per-order barycentric corrections from the EXPMETER_SCI flux-weighted midpoint times and stores them on the L2. WAVE arrays are not modified.
- Outputs (EPRV-standard ImageHDUs, shape (NORDER,)):
BJD_TDB photon-weighted midpoint in BJD_TDB per spectral order
BARYCORR_KMS barycentric velocity per spectral order [km/s]
BARYCORR_Z barycentric redshift per spectral order
Per-CCD scalar summaries (at each chip’s flux-weighted photon-midpoint time) written to the per-CCD barycentric extension headers (BJD_TDB / BARYCORR_KMS / BARYCORR_Z) as registered KPF-pipeline keywords (config/L2-headers.csv):
CCD1BJD GREEN photon-weighted mid-time (BJD_TDB)
CCD1BKMS GREEN barycentric velocity [km/s]
CCD1BZ GREEN barycentric redshift
CCD2BJD RED photon-weighted mid-time (BJD_TDB)
CCD2BKMS RED barycentric velocity [km/s]
CCD2BZ RED barycentric redshift
CCD1BJD/CCD2BJD match the legacy keyword names and semantics; the *BKMS/*BZ companions follow the same CCD{n} naming pattern. INSTRUMENT_HEADER is an immutable pure pass-through of the raw instrument header and is never written.
Notes
Follows the barycentric correction approach described in: - Wright & Eastman (2014) — velocity calculation (barycorrpy) - Butler et al. (1996) — flux-weighted midpoint time
- class kpfpipe.modules.barycentric_correction.BarycentricCorrection(l2_obj, config=None)
Bases:
objectCompute and store per-order barycentric correction on a KPF2.
Derives the flux-weighted midpoint time per expmeter channel (EXPMETER_SCI), averages it over the channels within each spectral order’s wavelength range (SCI2_WAVE), resolves the target’s astrometry (Gaia DR3, with a WMKO header fallback), and calls barycorrpy to populate BJD_TDB / BARYCORR_KMS / BARYCORR_Z. WAVE arrays are not modified.
- Parameters:
l2_obj (KPF2) – Extracted L2 frame. Must have EXPMETER_SCI populated and SCI2_WAVE populated by WavelengthCalibration. INSTRUMENT_HEADER (the preserved L1 PRIMARY) must contain GAIAID, and DATE-BEG/DATE-END when extrapolating.
config (None | dict | ConfigHandler) – Module configuration. Recognized keys: use_gaia_astrometry, use_wmko_fallback.
- KECK_LOCATION = <EarthLocation (-5464397.47826817, -2493181.83118863, 2150991.95499145) m>
- compute_barycentric_correction(output='orders', interpolate=True, extrapolate=True, fix_expmeter_outliers=True)
Compute the barycentric correction at the flux-weighted photon-midpoint time for each output bin.
Mirrors compute_flux_weighted_midpoint_times: output selects the binning. The per-channel integration and the Gaia astrometry are both cached, so calling this for ‘orders’ then ‘ccds’ does the heavy work once.
- Parameters:
output ({'expmeter', 'orders', 'ccds'}) – Binning level; forwarded to compute_flux_weighted_midpoint_times().
interpolate (bool, optional) – Forwarded to compute_flux_weighted_midpoint_times().
extrapolate (bool, optional) – Forwarded to compute_flux_weighted_midpoint_times().
fix_expmeter_outliers (bool, optional) – Forwarded to compute_flux_weighted_midpoint_times().
- Returns:
bjd_tdb (ndarray) – Photon-weighted midpoint in BJD_TDB per output bin.
bary_kms (ndarray) – Barycentric velocity per output bin [km/s].
bary_z (ndarray) – Barycentric redshift per output bin.
- compute_flux_weighted_midpoint_times(output='orders', interpolate=True, extrapolate=True, fix_expmeter_outliers=True, weight_percentile=90)
Compute the flux-weighted midpoint observation time.
The per-channel midpoint is always derived internally; output controls how it is projected.
- Parameters:
output ({'expmeter', 'orders', 'ccds'}) –
‘expmeter’ — per-channel times, shape (nwave,). ‘orders’ — per spectral order: mean of the per-channel times for
the expmeter channels within the order’s wavelength range, shape (NORDER,). Orders outside expmeter coverage fall back to the nearest channel.
- ’ccds’ — per chip: the SCI2-flux-weighted mean of the per-order
values, shape (2,); [GREEN, RED].
interpolate (bool, optional) – If True, estimate flux during gaps between expmeter readings.
extrapolate (bool, optional) – If True, estimate flux during gaps before the first or after the last expmeter reading, using DATE-BEG / DATE-END from INSTRUMENT_HEADER.
fix_expmeter_outliers (bool, optional) – If True (default), detect and replace outlier expmeter readings.
weight_percentile (float, optional) – Per-order SCI2 brightness percentile used to weight orders for the ‘ccds’ output (robust to cosmics). Defaults to 90.
- Returns:
w (ndarray) – Wavelengths corresponding to each output bin [Å].
t_fwm (Time) – Flux-weighted midpoint time (JD-UTC) per output bin.
- info()
Print a summary of the barycentric correction results.
- perform(*, use_gaia_astrometry=None, use_wmko_fallback=None, interpolate=True, extrapolate=True, fix_expmeter_outliers=True)
Compute per-order barycentric correction and store it on the KPF2.
- Parameters:
use_gaia_astrometry (bool, optional) – Override the configured astrometry-source toggles for this call.
use_wmko_fallback (bool, optional) – Override the configured astrometry-source toggles for this call.
interpolate (bool, optional) – Forwarded to compute_flux_weighted_midpoint_times(). See that method for semantics.
extrapolate (bool, optional) – Forwarded to compute_flux_weighted_midpoint_times(). See that method for semantics.
fix_expmeter_outliers (bool, optional) – Forwarded to compute_flux_weighted_midpoint_times(). See that method for semantics.
- Returns:
l2_obj – Input KPF2 with BJD_TDB / BARYCORR_KMS / BARYCORR_Z populated, the per-CCD CCD{1,2}BJD/BKMS/BZ summaries written to those same bary extension headers, the astrometry source (ASTRSRC) written to RECEIPT, and a ‘barycentric_correction’ receipt entry.
- Return type: