pint.templates.lcprimitives.LCWrappedFunction

class pint.templates.lcprimitives.LCWrappedFunction(**kwargs)[source]

Bases: LCPrimitive

Super-class for profiles derived from wrapped functions.

While some distributions (e.g. the wrapped normal) converge quickly, others (e.g. the wrapped Lorentzian) converge very slowly and must be truncated before machine precision is reached.

In order to preserve normalization, the pdf is slightly adjusted: f(phi) = sum_(i,-N,N,g(phi+i)) + (1 - int(phi,-N,N,g(phi)) ).

This introduces an additional parameteric dependence which must be accounted for by computation of the gradient.

Generally, class-specific setup work is performed in init. Here, init is called and certain guaranteed default members are established.

Methods

approx_derivative(phases[, log10_ens, ...])

approx_gradient(phases[, log10_ens, eps])

approx_hessian(phases[, log10_ens, eps])

base_derivative(phases[, log10_ens, index, ...])

base_func(phases[, log10_ens, index])

base_grad(phases[, log10_ens, index])

base_grad_deriv(phases[, log10_ens, index])

base_hess(phases[, log10_ens, index])

base_int(phases[, log10_ens, index])

cdf(x[, log10_ens])

center_gauss_prior([enable])

[Convenience] Set gauss mode to current params.

check_bounds([p])

check_gradient([atol, rtol, quiet])

closest_to_peak(phases)

Return the minimum distance between a member of the array of phases and the position of the mode of the primitive.

copy()

derivative(phases[, log10_ens, order])

Return the phase gradient (dprim/dphi) at a vector of phases.

dict_string()

Return a string to express the object as a dictionary that can be easily instantiated using its keys.

enable_gauss_prior([enable])

[Convenience] Turn on gaussian prior.

eval_string()

Return a string that can be evaluated to instantiate a nearly- identical object.

fwhm()

Return the full-width at half-maximum of the light curve model.

get_bounds([free])

get_errors([free])

get_fixed_energy_version([log10_en])

get_free_mask()

Return a mask with True if parameters are free, else False.

get_gauss_prior_parameters()

get_location([error])

get_norm([error])

get_parameter_names([free])

get_parameters([free])

get_width([error, hwhm, right])

Return the width of the distribution.

gradient(phases[, log10_ens, free])

Return the gradient evaluated at a vector of phases.

gradient_derivative(phases[, log10_ens, free])

Return the gradient evaluated at a vector of phases.

hessian(phases[, log10_ens, free])

Return the hessian evaluated at a vector of phases.

hwhm([right])

Return the half-width at half-maximum of the light curve model.

init()

integrate(x1, x2[, log10_ens])

Base implemention with scipy quad.

is_energy_dependent()

is_two_sided()

True if primitive is asymmetric.

num_parameters([free])

parse_kwargs(kwargs)

random(n[, log10_ens])

Default is accept/reject.

sanity_checks([eps])

A few checks on normalization, integration, etc.

set_errors(errs)

set_location(loc)

set_parameters(p[, free])

__call__(phases, log10_ens=3)[source]

Return wrapped template + DC component corresponding to truncation.

gradient(phases, log10_ens=3, free=False)[source]

Return the gradient evaluated at a vector of phases.

outputa num_parameter x len(phases) ndarray,

the num_parameter-dim gradient at each phase

gradient_derivative(phases, log10_ens=3, free=False)[source]

Return the gradient evaluated at a vector of phases.

outputa num_parameter x len(phases) ndarray,

the num_parameter-dim gradient at each phase

hessian(phases, log10_ens=3, free=False)[source]

Return the hessian evaluated at a vector of phases.

NB that this is restricted to the sub-space for this primitive.

outputa num_parameter x num_parameter x len(phases) ndarray,

the num_parameter-dim^2 hessian at each phase

derivative(phases, log10_ens=3, order=1)[source]

Return the phase gradient (dprim/dphi) at a vector of phases.

order: order of derivative (1=1st derivative, etc.)

output : a len(phases) ndarray, dprim/dphi

NB this will generally be opposite in sign to the gradient of the location parameter.

integrate(x1, x2, log10_ens=3)[source]

Base implemention with scipy quad.

center_gauss_prior(enable=False)

[Convenience] Set gauss mode to current params.

closest_to_peak(phases)

Return the minimum distance between a member of the array of phases and the position of the mode of the primitive.

dict_string()

Return a string to express the object as a dictionary that can be easily instantiated using its keys.

enable_gauss_prior(enable=True)

[Convenience] Turn on gaussian prior.

eval_string()

Return a string that can be evaluated to instantiate a nearly- identical object.

fwhm()

Return the full-width at half-maximum of the light curve model.

get_free_mask()

Return a mask with True if parameters are free, else False.

get_width(error=False, hwhm=False, right=False)

Return the width of the distribution.

Parameters:
  • error (bool) – if True, return tuple with value and error

  • hwhm (bool) – if True, scale width to be HWHM

  • right (bool) – if True, return “right” component, else “left”. There is no distinction for symmetric dists.

hwhm(right=False)

Return the half-width at half-maximum of the light curve model.

is_two_sided()

True if primitive is asymmetric. Default is False, two-sided child classes should override.

random(n, log10_ens=3)

Default is accept/reject.

sanity_checks(eps=1e-06)

A few checks on normalization, integration, etc.