jwspecabund.strong_line

Strong-line metallicity calibrations from Sanders et al. (2025).

Simultaneous polynomial fit across available diagnostic ratios (O3, O2, R23, O32) with Monte Carlo error propagation.

References

Sanders, R. L. et al. 2025, ApJ (submitted).

Functions

compute_line_ratios(line_fluxes, line_errors)

Compute available strong-line diagnostic ratios.

sanders25_metallicity(line_fluxes, line_errors)

Derive 12+log(O/H) via simultaneous Sanders+25 calibrations.

jwspecabund.strong_line.compute_line_ratios(line_fluxes, line_errors, snr_thresh=1.5)[source]

Compute available strong-line diagnostic ratios.

Parameters:
  • line_fluxes (dict) – {line_name: flux}.

  • line_errors (dict) – {line_name: flux_err}.

  • snr_thresh (float) – Minimum SNR for a line to be used (default 1.5).

Returns:

{ratio_name: {"val": log10_ratio, "err": error}}.

Return type:

dict

jwspecabund.strong_line.sanders25_metallicity(line_fluxes, line_errors, n_mc=1000, snr_thresh=1.5, seed=42, progress=True)[source]

Derive 12+log(O/H) via simultaneous Sanders+25 calibrations.

Parameters:
  • line_fluxes (dict) – {line_name: flux}.

  • line_errors (dict) – {line_name: flux_err}.

  • n_mc (int) – Monte Carlo iterations for error propagation (default 1000).

  • snr_thresh (float) – Minimum SNR for a ratio to be used (default 1.5).

  • seed (int) – Random seed for reproducibility.

  • progress (bool) – Show a tqdm progress bar (default True).

Returns:

(Z_best, Z_lo, Z_hi, chi2, ratios_used, Z_mc_samples) where Z_best is 12+log(O/H), Z_lo/Z_hi are 16th/84th percentiles, chi2 is the best-fit chi-squared, ratios_used lists the diagnostics, and Z_mc_samples is the full MC array.

Return type:

tuple

Raises:

ValueError – If no valid diagnostic ratios are available.