refine_templates_and_solution

ell1fit.refinement.refine_templates_and_solution(observations, setup, nbin, nharm, max_iterations=1, tolerance=0.1)[source]

Alternate between rebuilding the template and refitting the solution.

Parameters:
observationsObservationSet

The event data.

setupFitSetup

Starting configuration, carrying the templates built from the input parfile’s solution.

nbinint

Phase bins used when refolding.

nharmint

Harmonics retained in the template. Held fixed across iterations, to limit the noise-overfitting risk described in the module docstring.

max_iterationsint, optional

Maximum refinement passes. 1 means a single fit against the initial template – identical to not refining at all.

tolerancefloat, optional

Convergence threshold on max_k |dtheta_k| / factor_k.

Returns:
setupFitSetup

The best configuration found, with refined templates and a re-centred baseline. Ready to hand to ell1fit.fitting.optimize_solution().

historylist of dict

One entry per pass, recording score, max_shift and converged, so that convergence can be inspected rather than assumed.