pint.templates.lcfitters.LCFitter

class pint.templates.lcfitters.LCFitter(template, phases, weights=None, log10_ens=3, times=1, binned_bins=1000, binned_ebins=8, phase_shift=0)[source]

Bases: object

Class for fitting light curves.

Arguments: template – an instance of LCTemplate phases – list of photon phases

Keyword arguments: weights [None] optional photon weights log10_ens [None] optional photon energies (log10(E/MeV)) times [None] optional photon arrival times binned_bins [100] phase bins to use in binned likelihood binned_ebins [8] energy bins to use in binned likelihood phase_shift [0] set this if a phase shift has been applied

Methods

aic([template])

Return the Akaike information criterion for the current state.

bic([template])

Return the Bayesian information criterion for the current state.

binned_gradient(p, *args, **kwargs)

binned_loglikelihood(p, *args, **kwargs)

bootstrap_errors([nsamp, fit_kwargs, set_errors])

chi(p, *args)

fit([quick_fit_first, unbinned, ...])

fit_background([unbinned])

Fit the background level, holding the ratios of the pulsed components fixed but varying their total normalization.

fit_bfgs()

fit_cg()

fit_fmin(fit_func[, ftol])

fit_l_bfgs_b()

fit_position([unbinned, track, skip_coarse])

Fit overall template position.

fit_tnc(fit_func, grad_func[, ftol, quiet])

get_ebands([nband])

hess_errors([use_gradient])

Set errors from hessian.

is_energy_dependent()

plot([nbins, fignum, axes, plot_components, ...])

plot_ebands([nband, fignum, plot_zoom, ...])

plot_residuals([nbins, fignum])

quick_fit()

rotate_for_display()

Rotate both internal phases and template to a nice phase.

unbinned_gradient(p, *args, **kwargs)

unbinned_loglikelihood(p, *args, **kwargs)

write_template([outputfile])

fit_position(unbinned=True, track=False, skip_coarse=False)[source]

Fit overall template position. Return shift and its error.

Parameters:
  • unbinned (bool) – Use unbinned likelihood; will be very slow for many photons.

  • track (bool) – Limit best-fit solution to +/- 0.2 periods of zero phase. Helps to avoid 0.5period ambiguity for two-peaked profiles.

Returns:

  • delta_phi (float) – overall phase shift from template

  • delta_phi_err (float) – estimated uncertainty on phase shift from likelihood hessian

fit_background(unbinned=True)[source]

Fit the background level, holding the ratios of the pulsed components fixed but varying their total normalization.

hess_errors(use_gradient=True)[source]

Set errors from hessian. Fit should be called first…

rotate_for_display()[source]

Rotate both internal phases and template to a nice phase.

NB this will potentially break zero-phase references and will also necessitate re-binning if using binned mode.

aic(template=None)[source]

Return the Akaike information criterion for the current state.

Note the sense of the statistic is such that more negative implies a better fit.

bic(template=None)[source]

Return the Bayesian information criterion for the current state.

Note the sense of the statistic is such that more negative implies a better fit.

This should work for energy-dependent templates provided the template and fitter match types.