hispecdrp.utils.line_mask_utils

Line-mask utilities (mask I/O, MaskLines container, template-built masks).

The canonical overview of mask formats and generation lives in the documentation: docs/source/algorithms/line_mask.rst.

Module Attributes

IDEAL_SPECTRUM_STELLAR_RV_KW

Defaults for ideal-spectrum paint + line-mask RV (alias for notebooks/tests).

E2ERV_MASK_BUILD_KW

Defaults for build_e2erv_line_mask_from_template() (RV-aligned e2e mask).

DEFAULT_PACKAGED_LINE_MASK_BASENAME

Packaged default delta line mask basename under package_data_masks_dir().

Functions

_absorption_centers_from_flux_gradients_um(...)

Interpolated λ where dF/dλ = 0 between samples, keeping minima (d²F/dλ² > 0).

_assert_mas_mask_style_matches_columns(...)

If .mas header JSON (# HISPEC_DRP_MASK_META) includes mask_style, require that it matches the numeric layout: delta → 2 columns (vacuum nm, weight); tophat → ≥3 columns (start_nm, end_nm, weight, …).

_ccfopt_search_line_center_um(wave_um, flux, ...)

Two-stage grid search over mask λ near lam0_um maximizing |Gaussian contrast|.

_ccfopt_single_line_gaussian_contrast(...)

Single-line spline CCF + Gaussian fit at injected RV ≈ 0.

_cluster_max_depth(centers_nm, ...)

Union lines with |Δλ| < r_i + r_j; keep largest per-line metric per component (union-find).

_continuum_envelope(flux, size)

_continuum_normalized_d2_flux_dlam2_at_um(...)

Second derivative w.r.t.

_infer_wavelength_disk_to_um(values)

Infer wavelength column scale for legacy two-column text masks: median of positive finite values → Å (>1e3) /1e4, nm (>10) /1e3, else assume µm.

_local_min_continuum_normalized_flux_um(...)

Per centroid, minimum of \(F/F_c\) over discrete samples in [λ - half_width, λ + half_width].

_local_minima_indices(flux, order)

_merge_sorted_centers_um(centers_um, min_sep_um)

Drop duplicates closer than min_sep_um (keep first).

_normalize_mask_style(raw)

Map legacy kpf mask_style labels to canonical tophat.

_parabolic_minimum_wavelength_um(wave_um, ...)

Sub-pixel wavelength of a local absorption minimum.

_segment_mean_continuum_normalized_depth_um(...)

Mean \(1 - F/F_c\) over discrete template samples inside [lo_um, hi_um].

apply_ccfopt_defaults_for_line_by_line(*, ...)

Replace wide StellarRVPrimitive defaults with ccfopt mask-build settings.

build_ccfopt_line_mask_from_l2_line_by_line_rv(...)

Build a CCF-opt delta mask from an injected-RV=0 L2 via line-by-line stellar RV.

build_ccfopt_line_mask_from_l2_single_line_ccf(...)

Build a static rest-frame CCF-opt delta mask by zeroing single-line CCF bias.

build_ccfopt_line_mask_from_rvccf_table(...)

Build a CCF-opt delta mask from a line-by-line stellar-RV RVCCF table.

build_ccfopt_line_mask_from_template_and_seed(...)

Refine a seed delta mask so each line maximizes single-line Gaussian CCF contrast at RV=0.

build_e2erv_line_mask_from_template(...[, ...])

Build a delta line mask aligned with e2e WAVE / RV truth (template centers).

build_line_mask_from_template(template_path, *)

Detect lines in a template spectrum and write a filtered .mas mask.

compare_line_center_lists_um(centers_a, ...)

Match two line-center lists (vacuum µm) within match_tol_nm (nanometers).

detect_template_line_centers_gradient_um(...)

Absorption line centers (vacuum µm) from gradient zeros with positive curvature.

detect_template_line_centers_parabolic_um(...)

Line centers (vacuum µm) from discrete local flux minima + parabolic refinement.

fit_half_width_linear_from_mas(mas_path)

Fit half_width_nm = slope * center_nm + intercept from a SPIROU .mas file.

load_atmospheric_transmission_um([path])

Load Gemini mktrans two-column ASCII: wavelength (µm), transmission (0–1).

masklines_wavelength_unit_meta(unit)

Serializable Astropy/FITS unit strings for MaskLines.metadata wavelength keys.

mean_transmission_over_velocity_interval_um(...)

Mean atmospheric transmission over line_wavelength_um * (1 ± v/c) (vacuum, µm).

package_data_masks_dir()

Absolute path to hispecdrp/data/masks.

packaged_default_line_mask_path()

Absolute path to the packaged default delta mask (same as resolve_mask_path(None)).

paired_line_mask_path_for_template(...[, ...])

Resolve the packaged line mask paired with a template basename or path.

parse_mask_generation_meta_line(line)

If line starts with LINE_MASK_META_PREFIX, return the parsed JSON object.

pixel_edges_from_wavelength(wave_um)

Pixel bin left/right edges (µm) from a sorted wavelength array (midpoints + end padding).

read_mask_generation_meta(path)

Scan the start of a .mas file for parse_mask_generation_meta_line().

resolve_mask_path(mask_path)

Resolve mask_path to an absolute filesystem path, or the packaged default when None.

restrict_mask_to_chunk(mask_lines, w_min_um, ...)

Keep lines whose rest centers can Doppler-shift into [w_min_um, w_max_um] for some velocity in [v_min_m_s, v_max_m_s] (m/s) with denominator (1+zb).

stellar_rv_ccf_mask_lines(*, mask_path[, ...])

Resolve mask lines for line-mask CCF (path, default package mask, or in-memory arrays).

Classes

LineMaskEntry(wavelength_nm, weight)

One template-built mask row: vacuum wavelength (nm) and CCF weight.

MaskLines(mask_style, line_center, ...[, ...])

Tabulated CCF line mask (delta zero-width lines or tophat finite segments).

DEFAULT_PACKAGED_LINE_MASK_BASENAME = 'lte049.0-2.5-0.0a+0.0.BT-Settl.spec.7.ccfopt.delta.mas'

Packaged default delta line mask basename under package_data_masks_dir(). Prefer the e2e-validated mask used to bake HB.sim_hdf_wavesol.line_zp.fits.

E2ERV_MASK_BUILD_KW = {'continuum_filter_size': 181, 'deblend_sep_resels': 1.5, 'min_continuum_normalized_depth': 0.2, 'min_continuum_normalized_flux_floor': 0.001, 'resel_um': 0.00015}

Defaults for build_e2erv_line_mask_from_template() (RV-aligned e2e mask).

IDEAL_SPECTRUM_STELLAR_RV_KW = {'ccf_input_velocity_m_s': 0.0, 'ccf_min_good_pixels': 9, 'mask_ccf_pixel_interp_order': 3, 'max_abs_rv_m_s': 500.0, 'max_rv_err_m_s': 10.0, 'min_contrast': 0.0, 'rezero_verify_abs_rv_m_s': 0.001, 'v_half_window_m_s': 20000.0, 'v_step_m_s': 10.0, 'window_line_by_line': True, 'window_size_um': 5.65e-05}

Defaults for ideal-spectrum paint + line-mask RV (alias for notebooks/tests).

class LineMaskEntry(wavelength_nm, weight)[source]

Bases: object

One template-built mask row: vacuum wavelength (nm) and CCF weight.

class MaskLines(mask_style, line_center, line_left_edge, line_right_edge, line_width, weight, metadata=<factory>)[source]

Bases: object

Tabulated CCF line mask (delta zero-width lines or tophat finite segments).

delta — two on-disk columns (vacuum line-center nm, weight): line_left_edge, line_right_edge, and line_center coincide; line_width is 0. tophat — ≥3 columns (vacuum segment start nm, end nm, weight): line_center is the segment midpoint; line_width = line_right_edge - line_left_edge.

Wavelengths are vacuum; internal arrays use microns (nm÷1000 on read/write for .mas). Use load() and save() for disk I/O with # HISPEC_DRP_MASK_META JSON (read_mask_generation_meta()).

CCF hot paths use line_lambda_um (centers, µm) and weight.

classmethod _from_mas_path(mask_file)[source]
classmethod _from_two_column_path(mask_file)[source]
classmethod empty_like_style(mask_style, *, metadata=None)[source]

Zero-line mask preserving mask_style (e.g. after wavelength restriction).

classmethod from_delta_centers_um(line_lambda_um, weight, *, metadata=None)[source]

Build a delta mask: zero width at each center (µm).

classmethod from_kpf_segment_edges_um(lo_um, hi_um, weight, *, metadata=None)[source]

Deprecated alias for from_tophat_segment_edges_um().

classmethod from_tophat_segment_edges_um(lo_um, hi_um, weight, *, metadata=None)[source]

Build a tophat (finite-width) mask from rest segment bounds in µm.

property line_lambda_um

Rest line centers in µm (line_center in µm).

classmethod load(path)[source]

Load a mask from disk: .mas (vacuum nm on disk → µm) or two-column text (.txt / .dat / .csv; wavelength column Å/nm/µm via median heuristic). Other extensions try .mas parsing first, then two-column.

metadata_dict()[source]

Shallow copy of metadata for inspection or JSON serialization.

save(output_path=None, *, masks_directory=None, basename=None)[source]

Write this mask to a .mas file.

On-disk layout: delta → vacuum line-center (nm), weight; tophat → vacuum segment start (nm), end (nm), weight. One # HISPEC_DRP_MASK_META JSON line (read_mask_generation_meta()).

When output_path is None, writes {masks_directory}/{basename}.{mask_style}.mas with basename from metadata["template_path"] when set, else "mask". masks_directory defaults to package_data_masks_dir().

apply_ccfopt_defaults_for_line_by_line(*, window_size_um, v_half_window, v_step_coarse)[source]

Replace wide StellarRVPrimitive defaults with ccfopt mask-build settings.

When window_line_by_line=True, line-mask CCF should use the same narrow window_size_um and velocity grid as CCFOPT_SINGLE_LINE_STELLAR_RV_KW unless the caller explicitly set non-default values.

build_ccfopt_line_mask_from_l2_line_by_line_rv(seed_mask_path, input_model, *, fiber=1, template_path=None, output_path=None, masks_directory=None, ccf_input_velocity_m_s=0.0, outlier_sigma=1000000.0, use_single_line_builder=False, match_half_m_s=5000.0, max_abs_rv_m_s=500.0, min_contrast=0.0, window_size_um=5.65e-05, window_line_by_line=True, v_half_window_m_s=20000.0, v_step_m_s=10.0, mask_ccf_pixel_interp_order=3, zb=0.0, max_seed_lines=None)[source]

Build a CCF-opt delta mask from an injected-RV=0 L2 via line-by-line stellar RV.

Two-step workflow (default use_single_line_builder=False):

  1. Run StellarRVPrimitive(algorithm="ccf_line_mask") on input_model with the seed mask and line-by-line windowing at ccf_input_velocity_m_s (typically 0). Set outlier_sigma very large (default 1e6) so chunk outlier rejection does not drop mask lines before aggregation.

  2. Pass the per-line RVCCF table to build_ccfopt_line_mask_from_rvccf_table(), which drops seed lines when any matching per-order calibration RV exceeds max_abs_rv_m_s (default CCFOPT_MAX_ABS_RV_M_S), then shifts each kept line λ' = λ × (1 + RV/c) and sets weights proportional to |Gaussian contrast|.

When use_single_line_builder=True, delegate to the slower per-line CCF path build_ccfopt_line_mask_from_l2_single_line_ccf() (gold-standard).

build_ccfopt_line_mask_from_l2_single_line_ccf(seed_mask_path, input_model, *, fiber=2, template_path=None, output_path=None, masks_directory=None, window_size_um=5.65e-05, window_line_by_line=True, v_half_window_m_s=20000.0, v_step_m_s=10.0, ccf_input_velocity_m_s=0.0, mask_ccf_pixel_interp_order=3, ccf_min_good_pixels=9, max_abs_rv_m_s=500.0, min_contrast=0.0, rezero_verify_abs_rv_m_s=0.001, max_rv_err_m_s=10.0, zb=0.0, max_seed_lines=None)[source]

Build a static rest-frame CCF-opt delta mask by zeroing single-line CCF bias.

For each seed line, run the same line-mask CCF path as StellarRVPrimitive(algorithm="ccf_line_mask") with line-by-line settings (CCFOPT_SINGLE_LINE_STELLAR_RV_KW, matching rv_recovery_sim.ipynb) but with a mask containing only that line. Shift the line center so the recovered RV equals the injected prior (ccf_input_velocity_m_s, typically 0):

λ' = λ_seed × (1 + (RV − ccf_input_velocity) / c)

The output .mas is a fixed rest-frame list (does not vary with bulk RV). Weights are proportional to |Gaussian CCF contrast| at the measured (pre-shift) CCF and are renormalized to sum to 1.

Lines are dropped when:

  • no valid chunk RV, |RV| above max_abs_rv_m_s, or contrast at/below min_contrast;

  • formal RV uncertainty ≥ max_rv_err_m_s (default 10 m/s);

  • after the λ shift, re-measured |RV − center| ≥ rezero_verify_abs_rv_m_s (default 0.001 m/s = 0.1 cm/s), or the re-measured uncertainty fails the same max_rv_err_m_s gate.

Parameters:
  • seed_mask_path – Packaged *.delta.mas seed.

  • input_model – Blaze-corrected L2-like model (WAVE_FIB* / SPEC_FIB*).

  • fiber – Fiber label matching the L2 attributes (default 2).

build_ccfopt_line_mask_from_rvccf_table(seed_mask_path, rvccf_table, *, template_path=None, output_path=None, masks_directory=None, match_half_m_s=5000.0, max_abs_rv_m_s=500.0, min_contrast=0.0)[source]

Build a CCF-opt delta mask from a line-by-line stellar-RV RVCCF table.

For each seed line, gather all RVCCF rows within match_half_m_s (any echelle order). Drop the seed when any matching row has |RV| > max_abs_rv_m_s (failed / aliased calibration in at least one order). Otherwise pick the nearest unused matching row, shift the mask center so that chunk’s measured RV becomes 0:

λ' = λ_seed × (1 + RV / c),

and set the weight proportional to |Gaussian contrast| of that chunk’s stored CCF. Weights are renormalized to sum to 1.

Parameters:
  • seed_mask_path – Path to the seed *.delta.mas (typically the packaged depth-weighted mask).

  • rvccf_table – Astropy table from StellarRVPrimitive with window_line_by_line=True (columns RV, WAVELENGTH, CCF, V_MIN, V_MAX, V_STEP).

  • template_path – Optional template path for metadata / default output naming.

  • output_path – Output .mas path (default <stem>.ccfopt.delta.mas under masks_directory).

  • masks_directory – Output .mas path (default <stem>.ccfopt.delta.mas under masks_directory).

  • match_half_m_s – Maximum |Δv| between seed λ and chunk WAVELENGTH for a match.

  • max_abs_rv_m_s – Drop a seed line when any matching RVCCF row (across orders) has |RV| above this gate (failed / aliased per-line calibration).

  • min_contrast – Drop lines whose absolute Gaussian contrast is at or below this floor.

build_ccfopt_line_mask_from_template_and_seed(template_path, seed_mask_path, *, wl_min_um=0.8, wl_max_um=3.0, spectrum_window_half_um=0.01, ccf_v_half_m_s=8000.0, ccf_v_step_m_s=25.0, search_half_m_s=2500.0, coarse_step_m_s=250.0, fine_half_m_s=300.0, fine_step_m_s=25.0, rv_gate_m_s=2000.0, min_good_pixels=32, output_path=None, masks_directory=None, wave_um=None, flux=None)[source]

Refine a seed delta mask so each line maximizes single-line Gaussian CCF contrast at RV=0.

For every seed center λ₀, search trial centers λ = λ₀ (1 + δv/c) on the template spectrum (injected RV = 0) and keep the wavelength that maximizes |Gaussian contrast| from calc_ccf_metrics(). Output weights are proportional to that contrast and are renormalized to sum to 1.

Parameters:
  • template_path – Path to a BT-Settl .h5 template (used for I/O naming / metadata; also loaded unless wave_um / flux are provided).

  • seed_mask_path – Path to an existing delta .mas seed (typically the packaged depth-weighted mask).

  • wave_um – Optional in-memory vacuum-µm spectrum (for tests). When either is set, both must be set and template_path is used only for metadata / default output naming.

  • flux – Optional in-memory vacuum-µm spectrum (for tests). When either is set, both must be set and template_path is used only for metadata / default output naming.

  • output_path – Full output path. Default: <stem>.ccfopt.delta.mas under masks_directory.

Returns:

path_written, entries – Output .mas path and in-memory rows.

build_e2erv_line_mask_from_template(template_path, *, wl_min_um=0.8, wl_max_um=3.0, min_continuum_normalized_depth=0.2, deblend_sep_resels=1.5, resel_um=0.00015, continuum_filter_size=181, min_continuum_normalized_flux_floor=0.001, output_path=None, masks_directory=None)[source]

Build a delta line mask aligned with e2e WAVE / RV truth (template centers).

Uses parabolic absorption centroids (same family as the sim-HDF line WAVE correction), a resolution-element deblend that keeps the deepest line in each blend, and continuum-normalized depth weights (sum → 1). No CCF-opt λ shifts — centers stay at template truth so CCF at injected RV=0 is unbiased when WAVE labels apparent line centers.

Default output: <template_stem>.e2erv.delta.mas.

build_line_mask_from_template(template_path, *, wl_min_um=0.8, wl_max_um=3.0, min_continuum_normalized_depth=0.1, low_pass_width_multiplier=7.283985083415576, telluric_velocity_half_width_km_s=288.2674944075802, telluric_min_mean_transmission=0.0, transmission_file=None, continuum_filter_size=181, min_continuum_normalized_flux_floor=0.0001, apply_deblend=True, apply_telluric_filter=True, local_min_fn_window_half_width_nm=None, output_path=None, masks_directory=None)[source]

Detect lines in a template spectrum and write a filtered .mas mask.

Centroids come from detect_template_line_centers_gradient_um(). Each output row is (wavelength_vacuum_nm, weight) with no segment edges. Raw weights are continuum-normalized depth \(1 - F/F_c\) at each line center (interpolated), then are divided by their sum so output weights sum to 1.

Deblending (when apply_deblend) uses 0.5 * low_pass_width_multiplier * median(Δλ_nm) as the merge radius per line (deepest line kept in each cluster), where median(Δλ_nm) is from the sorted template grid. Pass apply_deblend=False / apply_telluric_filter=False (see RELAXED_TEMPLATE_MASK_BUILD_KW) to maximize line count.

Parameters:
  • template_path – Path to a supported template (BT-Settl .h5).

  • wl_min_um – Wavelength clip in vacuum microns before line search.

  • wl_max_um – Wavelength clip in vacuum microns before line search.

  • min_continuum_normalized_depth – Passed to detect_template_line_centers_gradient_um() and re-applied after interpolation to centers.

  • low_pass_width_multiplier – Scales the deblending radius vs. the template median wavelength step (nm). Ignored when apply_deblend is false.

  • telluric_velocity_half_width_km_s – Half-width in km/s for the telluric averaging interval (± this value). Ignored when apply_telluric_filter is false.

  • telluric_min_mean_transmission – Lines with mean transmission below this value are removed (telluric path only).

  • transmission_file – Two-column mktrans-style path (µm, transmission). Default: bundled data/atmosphere/mktrans_zm_10_10.dat.

  • continuum_filter_size – Odd-ish pixel size for the maximum-filter continuum envelope.

  • min_continuum_normalized_flux_floor – If not None, drop candidate lines whose local minimum of \(F/F_c\) (over ±local_min_fn_window_half_width_nm around the centroid) is below this value. Saturated cores have \(F/F_c \to 0\) and are skipped. Set None to keep saturated cores (relaxed seed).

  • apply_deblend – If false, skip nearest-neighbor deblend clustering (keep all depth-passing lines).

  • apply_telluric_filter – If false, skip the atmospheric-transmission gate.

  • local_min_fn_window_half_width_nm – Half-width of the wavelength interval (nm, vacuum) used for the local \(\min(F/F_c)\) test. If None, uses 5 × the template median step (nm).

  • output_path – Full path for the output .mas. If None, writes under masks_directory as <template_basename>.delta.mas (delta is the on-disk MASK_STYLE_DELTA layout; distinct stems per style match MaskLines.save()).

  • masks_directory – Default output directory (package data/masks if None).

Returns:

path_written, entries – Output file path and in-memory rows (wavelength_nm, weight).

compare_line_center_lists_um(centers_a, centers_b, *, match_tol_nm=0.05)[source]

Match two line-center lists (vacuum µm) within match_tol_nm (nanometers).

Returns counts and boolean masks over the sorted union of inputs for which centers fall in only A, only B, or both (matched pairs use greedy nearest-neighbor within tolerance on the merged sorted list — for diagnostics only).

Notes

Greedy matching: sort all centers from A and B with tags; sweep λ increasing, pairing unmatched A with next unmatched B if |Δλ| ≤ tol (in µm: tol_nm * 1e-3). Simpler approach: for each a in A, match if any b in B with |a-b| <= tol_um.

Returns:

dict – Keys: n_a, n_b, n_match, n_a_only, n_b_only, match_tol_nm, matched_pairs (list of (a_um, b_um)), centers_a_only_um, centers_b_only_um.

detect_template_line_centers_gradient_um(wave_um, flux, *, continuum_filter_size=181, min_continuum_normalized_depth=0.04, merge_min_sep_um=None)[source]

Absorption line centers (vacuum µm) from gradient zeros with positive curvature.

Intervals where the first derivative of flux w.r.t. λ (numpy.gradient) crosses zero are refined to a wavelength; the point is kept only if the second derivative of flux w.r.t. λ is positive (flux minimum, not maximum) and the usual continuum-normalized depth exceeds min_continuum_normalized_depth.

This is an alternative to chaining _local_minima_indices() with _parabolic_minimum_wavelength_um(); lists can be compared with compare_line_center_lists_um().

Parameters:
  • wave_um – Sorted vacuum-µm template grid (as from load_template_from_path).

  • flux – Sorted vacuum-µm template grid (as from load_template_from_path).

  • continuum_filter_size – Odd-ish size for _continuum_envelope() (depth definition).

  • min_continuum_normalized_depth – Minimum 1 - F/F_c at the interpolated stationary point.

  • merge_min_sep_um – Merge roots closer than this (µm). Default: 0.25 * median(Δλ) on the grid.

Returns:

np.ndarray – Centers in vacuum microns, sorted ascending.

detect_template_line_centers_parabolic_um(wave_um, flux, *, local_min_order=2, continuum_filter_size=181, min_continuum_normalized_depth=None)[source]

Line centers (vacuum µm) from discrete local flux minima + parabolic refinement.

This matches the centroid step in build_line_mask_from_template() before depth / deblend / telluric filters: _local_minima_indices() on flux and _parabolic_minimum_wavelength_um() at each index.

Parameters:
  • wave_um – Same sorted vacuum-µm grid as load_template_from_path (ascending λ).

  • flux – Same sorted vacuum-µm grid as load_template_from_path (ascending λ).

  • local_min_order – order for scipy.signal.argrelextrema().

  • continuum_filter_size – Used only if min_continuum_normalized_depth is set.

  • min_continuum_normalized_depth – If not None, drop centers with 1 - F/F_c below this threshold at the refined λ (F, F_c interpolated), matching the spirit of the mask depth cut in build_line_mask_from_template().

Returns:

np.ndarray – 1-D float64 centers in vacuum microns, sorted ascending.

fit_half_width_linear_from_mas(mas_path)[source]

Fit half_width_nm = slope * center_nm + intercept from a SPIROU .mas file.

Comment lines (#, ;, //) are skipped; centers and half-widths are computed from the first two columns (start_nm, end_nm).

load_atmospheric_transmission_um(path=None)[source]

Load Gemini mktrans two-column ASCII: wavelength (µm), transmission (0–1).

Comment lines (#, ;, //) are skipped. The bundled file under data/atmosphere/ ships with a documented header; data rows are fixed-format decimals. External copies that omit a leading 0 on the first column (e.g. .900180) are still accepted.

masklines_wavelength_unit_meta(unit)[source]

Serializable Astropy/FITS unit strings for MaskLines.metadata wavelength keys.

mean_transmission_over_velocity_interval_um(line_wavelength_um, trans_wavelength_um, transmission, half_width_km_s)[source]

Mean atmospheric transmission over line_wavelength_um * (1 ± v/c) (vacuum, µm).

half_width_km_s is a half-width in km/s; the interval is \(\pm\) that value (total span \(2 v / c\) in fractional wavelength). Sampling uses a fixed number of points on the interval; values are linearly interpolated in the transmission table and clipped to the table bounds.

package_data_masks_dir()[source]

Absolute path to hispecdrp/data/masks.

packaged_default_line_mask_path()[source]

Absolute path to the packaged default delta mask (same as resolve_mask_path(None)).

paired_line_mask_path_for_template(template_filename, *, mask_style='delta', masks_directory=None)[source]

Resolve the packaged line mask paired with a template basename or path.

For template lte049.0-2.5-0.0a+0.0.BT-Settl.spec.7.h5, returns .../lte049.0-2.5-0.0a+0.0.BT-Settl.spec.7.delta.mas when mask_style is delta.

parse_mask_generation_meta_line(line)[source]

If line starts with LINE_MASK_META_PREFIX, return the parsed JSON object.

The remainder of the line after the prefix must be a single JSON object.

pixel_edges_from_wavelength(wave_um)[source]

Pixel bin left/right edges (µm) from a sorted wavelength array (midpoints + end padding).

read_mask_generation_meta(path)[source]

Scan the start of a .mas file for parse_mask_generation_meta_line().

resolve_mask_path(mask_path)[source]

Resolve mask_path to an absolute filesystem path, or the packaged default when None.

Raises:

FileNotFoundError – If mask_path is None and the default mask file is missing.

restrict_mask_to_chunk(mask_lines, w_min_um, w_max_um, *, v_min_m_s, v_max_m_s, zb=0.0)[source]

Keep lines whose rest centers can Doppler-shift into [w_min_um, w_max_um] for some velocity in [v_min_m_s, v_max_m_s] (m/s) with denominator (1+zb).

stellar_rv_ccf_mask_lines(*, mask_path, mask_wavelength=None, mask_weight=None)[source]

Resolve mask lines for line-mask CCF (path, default package mask, or in-memory arrays).