jwspecmcmc.result
MCMC result containers.
MCMCResult holds the full posterior chains and derived
quantities. MCMCResult.to_fit_result() converts the median
posterior to a jwspecfit.fitter.FitResult for compatibility
with jwspecfit.plotting.plot_fit().
MCMCBroadFitResult wraps an MCMCResult with BIC
model-selection metadata for broad Balmer component fitting.
Classes
|
MCMC result with BIC-based broad Balmer component selection. |
|
MCMC posterior summary for a single emission line. |
|
Container for a complete MCMC fitting result. |
- class jwspecmcmc.result.MCMCBroadFitResult(mcmc_result, selected_model, bic_narrow, bic_broad1, bic_broad2, bic_both, oiii_selected='off', bic_oiii_off=nan, bic_oiii_broad1=nan, bic_oiii_broad2=nan, bic_oiii_both=nan, hei_selected='off', bic_hei_off=nan, bic_hei_broad1=nan, bic_hei_broad2=nan, bic_hei_both=nan)[source]
Bases:
objectMCMC result with BIC-based broad Balmer component selection.
Wraps an
MCMCResult(full MCMC posteriors on the winning model) together with BIC model-selection metadata.- Parameters:
mcmc_result (MCMCResult) – Full MCMC posteriors for the selected model.
selected_model (str) – Model name:
"narrow","broad1","broad2", or"both".bic_narrow (float) – BIC for narrow-only model.
bic_broad1 (float) – BIC for narrow + intermediate broad model (NaN if not attempted).
bic_broad2 (float) – BIC for narrow + very broad model (NaN if not attempted).
bic_both (float) – BIC for narrow + both broad components (NaN if not attempted).
oiii_selected (str)
bic_oiii_off (float)
bic_oiii_broad1 (float)
bic_oiii_broad2 (float)
bic_oiii_both (float)
hei_selected (str)
bic_hei_off (float)
bic_hei_broad1 (float)
bic_hei_broad2 (float)
bic_hei_both (float)
- property constraints: ConstraintSet | None
Applied constraints.
- doublet_flux_posterior(line_a, line_b)[source]
Combined flux posterior for a doublet.
Delegates to
MCMCResult.doublet_flux_posterior().
- doublet_snr(line_a, line_b)[source]
SNR of a combined doublet flux.
Delegates to
MCMCResult.doublet_snr().
- flux_ratio_posterior(line_a, line_b)[source]
Compute the posterior distribution of a flux ratio.
Delegates to
MCMCResult.flux_ratio_posterior().
- flux_upper_limit(line_name, n_sigma=3.0)[source]
Noise-based flux upper limit for a line.
Delegates to
MCMCResult.flux_upper_limit().
- flux_upper_limits(line_names=None, n_sigma=3.0, snr_threshold=3.0)[source]
Noise-based upper limits for low-SNR lines.
Delegates to
MCMCResult.flux_upper_limits().
- property lines: dict[str, MCMCLineResult]
Per-line posterior summaries.
- mcmc_result: MCMCResult
- property oiii_broad_selected: bool
True if any OIII broad component was selected.
- Type:
Convenience
- to_fit_result()[source]
Convert to a
jwspecfit.fitter.FitResult.Delegates to
MCMCResult.to_fit_result().- Return type:
- class jwspecmcmc.result.MCMCLineResult(name, rest_wave_A, amplitude, amplitude_err, centroid_A, centroid_err, sigma_A, sigma_err, flux, flux_err, flux_posterior, ew_A, snr)[source]
Bases:
objectMCMC posterior summary for a single emission line.
- Parameters:
name (str) – Line name.
rest_wave_A (float) – Rest-frame wavelength (Angstrom).
amplitude (float) – Median posterior amplitude.
amplitude_err (tuple of float) – (lower, upper) 68% credible interval half-widths on amplitude.
centroid_A (float) – Median posterior centroid (Angstrom).
centroid_err (tuple of float) – (lower, upper) 68% CI half-widths on centroid.
sigma_A (float) – Median posterior sigma (Angstrom).
sigma_err (tuple of float) – (lower, upper) 68% CI half-widths on sigma.
flux (float) – Median integrated flux (= amplitude for area-normalised Gaussians).
flux_err (tuple of float) – (lower, upper) 68% CI half-widths on flux.
flux_posterior (np.ndarray) – Full flux posterior samples.
ew_A (float) – Median rest-frame equivalent width (Angstrom).
snr (float) – Signal-to-noise ratio (flux / mean of flux_err tuple).
- class jwspecmcmc.result.MCMCResult(lines, flat_chains, flat_chains_free, flat_log_prob, chains, params, model_flux, continuum, spectrum, line_names=<factory>, constraints=None, convergence=<factory>, sampler_name='', sampler_meta=<factory>, lya_params=None)[source]
Bases:
objectContainer for a complete MCMC fitting result.
- Parameters:
lines (dict of MCMCLineResult) – Per-line posterior summaries, keyed by line name.
flat_chains (np.ndarray) – Flattened posterior samples in the full parameter space, shape
(n_samples, 3 * n_lines).flat_chains_free (np.ndarray) – Flattened posterior samples in the free parameter space, shape
(n_samples, n_free).flat_log_prob (np.ndarray) – Log-posterior for each sample.
chains (np.ndarray or None) – Raw chains of shape
(n_walkers, n_steps, n_free)(emcee) orNone(nautilus).params (np.ndarray) – Median posterior in the full parameter space.
model_flux (np.ndarray) – Median model flux (µJy, continuum-subtracted).
continuum (np.ndarray) – Continuum estimate (µJy).
spectrum (Spectrum) – Input spectrum.
constraints (ConstraintSet) – Applied constraints.
convergence (dict) – Convergence diagnostics (R-hat, ESS).
sampler_name (str) – Name of the sampler used (
"emcee"or"nautilus").sampler_meta (dict) – Additional sampler metadata (n_walkers, n_steps, etc.).
lya_params (ndarray | None)
- constraints: ConstraintSet | None = None
- doublet_flux_posterior(line_a, line_b)[source]
Compute the combined flux posterior for a doublet.
Sums the flux posteriors sample-by-sample, giving the correct combined distribution even when individual members are degenerate (e.g. blended CIII] 1907+1909).
- doublet_snr(line_a, line_b)[source]
Compute the SNR of a combined doublet flux.
Uses the summed flux posterior to get a single SNR that is not degraded by the amplitude degeneracy between blended members.
- flux_upper_limit(line_name, n_sigma=3.0)[source]
Compute a noise-based flux upper limit for a line.
Uses the local RMS of the continuum-and-model-subtracted residuals near the line, multiplied by the line width and n_sigma. This is the standard approach for non-detections and is independent of the posterior (which may be prior- dominated for weak lines).
- flux_upper_limits(line_names=None, n_sigma=3.0, snr_threshold=3.0)[source]
Compute noise-based upper limits for low-SNR lines.
- Parameters:
- Returns:
dict of {str –
{line_name: flux_upper_limit}for each line below the SNR threshold.- Return type:
float}
- lines: dict[str, MCMCLineResult]
- to_fit_result()[source]
Convert to a
jwspecfit.fitter.FitResult.Uses the median posterior as the best fit and the mean of the asymmetric 68% CI as the symmetric flux error.
- Return type: