get_template_func

ell1fit.templates.get_template_func(template, backend='numba')[source]

Get a cubic interpolation function of a pulse template.

The returned callable maps pulse phase to probability density and is evaluated once per event on every posterior call, which makes it the single hottest piece of the whole fit – around 80% of the cost of one likelihood evaluation before this was specialized.

Parameters:
templatenp.ndarray

Pulse template, uniformly sampled in phase.

backend{“numba”, “scipy”}, optional

"numba" evaluates the spline directly, exploiting the fact that the sample grid is uniform. "scipy" uses interp1d and is retained as the reference implementation: it is what the fast path is validated against, and what to fall back to if a result is ever in doubt.

Returns:
callable

Phase to density. Input phase is wrapped, so any real value is valid.

Notes

The two backends agree to about 1e-14 relative – roughly 80 machine epsilon. That residual is not one of them being wrong: it is the difference between evaluating the same cubic in Taylor form about each interval’s left edge and in scipy’s B-spline basis. For scale, the pipeline’s phase accuracy in float64 is around 1e-10 cycles, so this sits four orders of magnitude below the existing numerical floor.