pint.templates.lcnorm.NormAngles

class pint.templates.lcnorm.NormAngles(norms, **kwargs)[source]

Bases: object

Keep track of N angles (0 to pi/2) representing the coordinates inside a unit radius N-ball.

Generally, the apportionment of the amplitudes of components is indicated by the position of the vector, while the overall normalization is given by the an additional angle, the sine of which provides the (squared) normalization.

Parameters:

norms (tuple or array) – The amplitudes of a set of components; their sum must be <= 1.

Methods

add_component([norm])

Add a component and return resulting object.

copy()

delete_component(index)

Remove a component and return resulting object.

dict_string()

Round down to avoid input errors w/ normalization.

eval_string()

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

get_bounds([free])

Angles are always [0,pi/2).

get_errors([free, propagate])

Get errors on components.

get_free_mask()

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

get_parameter_names([free])

get_parameters([free])

get_total()

Return the amplitude of all norms.

gradient([log10_ens, free])

Return a matrix giving the value of the partial derivative of the ith normalization with respect to the jth angle, i.e.

hessian([log10_ens, free])

Return a matrix giving the value of the 2nd partial derivative of the ith normalization with respect to the jth and kth angles,

init()

is_energy_dependent()

num_parameters([free])

reorder_components(indices)

sanity_checks([eps])

set_errors(errs)

errs an array with the 1-sigma error estimates with shape equal to the number of free parameters.

set_parameters(p[, free])

set_single_norm(index, val)

set_total(val)

Set overall normalization of the represented components.

get_free_mask()[source]

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

set_errors(errs)[source]

errs an array with the 1-sigma error estimates with shape equal to the number of free parameters.

get_errors(free=True, propagate=True)[source]

Get errors on components. If specified, propagate errors from the internal angle parameters to the external normalizations.

get_bounds(free=True)[source]

Angles are always [0,pi/2).

__call__(log10_ens=3)[source]

Return the squared value of the Cartesian coordinates.

E.g., for a 4-sphere, return x0^2 = sin^2(a)*cos^2(b) x1^2 = sin^2(a)*sin^2(b)*cos^2(c) x2^2 = sin^2(a)*sin^2(b)*sin^2(c)*cos^2(d) x3^2 = sin^2(a)*sin^2(b)*sin^2(c)*sin^2(d)

Recall that the normalization is also given as an angle, s.t. the vector lies within the unit sphere.

These values are guaranteed to satisfy the constraint of a sum <= unity and so are suitable for normalizations of a light curve.

NB this version should work with both scalar (log10_ens=3) and vector (log10_ens an array) versions. The shape is [nparam] for scalar and [nparam, nenergy] for vector.

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

Return a matrix giving the value of the partial derivative of the ith normalization with respect to the jth angle, i.e.

M_ij = dn_i/dphi_j

This is the relevant quantity because it is the angles that are actually fit for, so this allows the application of the chain rule.

Because of the way the normalizations are defined, the ith normalization only depends on the (i+1)th first angles, so the upper half of M_ij is zero (see break statement below).

For taking higher derivatives, it is convenient to express the derivative as so: -d(cos^2(x)) = d(sin^2(x)) = sin(2x) So that any non-zero derivative can be expressed by taking the norm, dividing by sin^2/cos^2 as appropriate, and multiplying by +/- sin(2x). Then higher derivatives simply pop out a factor of +/-2 and toggle sin/cos.

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

Return a matrix giving the value of the 2nd partial derivative of the ith normalization with respect to the jth and kth angles,

M_ijk = dn2_i/dphi_j/dphi_k

See above notes for gradient. In general, the cases are

j < k <= i; just calculate as gradient, getting two sin(2x) terms j = k <= i; in this case, pick up a single 2*cos(2x) instead

get_total()[source]

Return the amplitude of all norms.

set_total(val)[source]

Set overall normalization of the represented components.

delete_component(index)[source]

Remove a component and return resulting object.

Pulsed normalization is preserved, and NormAngles or ENormAngles is return as appropriate.

add_component(norm=0.1)[source]

Add a component and return resulting object.

The normalization is specified as a fraction of the current pulsed normalization, such that the resulting NormAngles or ENormAngles object will have the same overall pulsed fraction at the pivot en.

eval_string()[source]

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

dict_string()[source]

Round down to avoid input errors w/ normalization.