specsrbench.build.lines

Assemble a drop-in cache on the log constant-R grid: arrays, line fits, S/N.

Produces the cache directory specsrbench.data loads: the reconstructions as plain arrays, a Gaussian fit of every diagnostic line in every method, the S/N those imply, and the summary table the paper and the tests are checked against.

Two departures from the original linear-grid build, both forced by the finer grid:

  • sigma_bounds had a fixed 0.001 um floor, set when one pixel was 0.001601 um everywhere. On this grid a pixel is 0.00025 um at 1 um, and a real R=2700 grating line has sigma ~0.00016 um – below the old floor, so the HR reference’s own lines would fit at the boundary and come out systematically too wide. The floor is now half the local pixel.

  • flux_high / flux_high_err come from eval_set.npz rather than the 135 MB raw dataset, which removed figure 4’s only raw-data dependency.

The method label R-L (30 it) becomes R-L: 30 iterations is not what the retuned pipeline runs, and a label that states a wrong iteration count is worse than one that states none.

Module Attributes

JOINT_LINES

The lines whose flux comes from the joint fit, and their column in it.

Functions

add_line_fluxes(fit_data, arrays)

Add the _flux / _flux_amp arrays for every method to fit_data.

fit_gauss(x, y, mu0[, fit_halfwin, sb_gap, ...])

(amp, sigma, S/N) or (nan, nan, nan).

fit_hbeta_oiii(wavelength, flux, z, *[, ...])

Joint fit of H-beta and the [O III] doublet: three Gaussians, one width.

joint_fits(wave, arr, z)

(amps, sigmas_um), each (n, 3), from fit_hbeta_oiii().

line_fluxes(label, fit_data, joint)

Integrated flux of each diagnostic line, sqrt(2 pi) * amp * sigma.

main([argv])

Fit every line in every reconstruction and write the summary.

method_arrays()

Every reconstruction, and the reference, keyed by its fit-cache label.

specsrbench.build.lines.fit_gauss(x, y, mu0, fit_halfwin=0.25, sb_gap=0.03, sb_width=0.12, core_halfwin=0.05, sigma_hi=0.12, mu_bounds_half=0.01, return_mu=False)[source]

(amp, sigma, S/N) or (nan, nan, nan). Lower sigma bound tracks the grid.

With return_mu the fitted centre is appended. It is bounded to mu0 +- mu_bounds_half (10 nm), so a centre offset between two fits can never exceed 20 nm, and one at the bound means the fit found no line there.

specsrbench.build.lines.JOINT_LINES = {'Hbeta': 0, 'OIII5007': 2}

The lines whose flux comes from the joint fit, and their column in it.

specsrbench.build.lines.fit_hbeta_oiii(wavelength, flux, z, *, window_kms=20000.0, sigma_lo_kms=40.0, sigma_hi_kms=3000.0)[source]

Joint fit of H-beta and the [O III] doublet: three Gaussians, one width.

The model specsr.linefit.fit_hbeta_oiii uses for paper 1’s line-flux figure, ported so the flux of a line means the same thing in both papers. A single Gaussian cannot measure the flux of these lines at prism resolution: centred on H-beta it widens until it holds the [O III] lines as well, and centred on 5007 it absorbs 4959. Fitting the three together at fixed centres with a shared velocity width assigns the blended flux to the right line. Amplitudes are bounded non-negative.

Returns (amps, sigmas_um), each of length three in the order H-beta, 4959, 5007, or None when the lines fall off the grid, the window holds a non-finite pixel, or the fit fails.

Parameters:
specsrbench.build.lines.joint_fits(wave, arr, z)[source]

(amps, sigmas_um), each (n, 3), from fit_hbeta_oiii().

specsrbench.build.lines.line_fluxes(label, fit_data, joint)[source]

Integrated flux of each diagnostic line, sqrt(2 pi) * amp * sigma.

H-alpha and [O II] take the single-Gaussian fit already in fit_data; H-beta and [O III] 5007 take the joint fit. _flux_amp is the amplitude of whichever fit supplied the flux, which is what a detection cut on the flux measurement has to be applied to.

specsrbench.build.lines.method_arrays()[source]

Every reconstruction, and the reference, keyed by its fit-cache label.

specsrbench.build.lines.add_line_fluxes(fit_data, arrays)[source]

Add the _flux / _flux_amp arrays for every method to fit_data.

specsrbench.build.lines.main(argv=None)[source]

Fit every line in every reconstruction and write the summary.

Return type:

int