bilby.gw.prior.HealPixMapPriorDist

class bilby.gw.prior.HealPixMapPriorDist(hp_file, names=None, bounds=None, distance=False)[source]

Bases: BaseJointPriorDist

Class defining prior according to given HealPix Map, defaults to 2D in ra and dec but can be set to include Distance as well. This only works with skymaps that include the 2D joint probability in ra/dec and that use the normal LALInference type skymaps where each pixel has a DISTMU, DISTSIGMA, and DISTNORM defining the conditional distance distribution along a given line of sight.

Parameters:
hp_filefile path to .fits file

.fits file that contains the 2D or 3D Healpix Map

nameslist (optional)

list of names of parameters included in the JointPriorDist, defaults to [‘ra’, ‘dec’]

boundsdict or list (optional)

dictionary or list with given prior bounds. defaults to normal bounds on ra, dev and 0, inf for distance if this is for a 3D map

Returns:
PriorDistbilby.gw.prior.HealPixMapPriorDist

A JointPriorDist object to store the joint prior distribution according to passed healpix map

__init__(hp_file, names=None, bounds=None, distance=False)[source]

A class defining JointPriorDist that will be overwritten with child classes defining the joint prior distributions between given parameters,

Parameters:
names: list (required)

A list of the parameter names in the JointPriorDist. The listed parameters must have the same order that they appear in the lists of statistical parameters that may be passed in child class

bounds: list (optional)

A list of bounds on each parameter. The defaults are for bounds at +/- infinity.

__call__(*args, **kwargs)

Call self as a function.

Methods

__init__(hp_file[, names, bounds, distance])

A class defining JointPriorDist that will be overwritten with child classes defining the joint prior distributions between given parameters,

check_in_pixel(ra, dec, pix)

Method that checks if given rightacension and declination values are within the given pixel index and the bounds

draw_distance(pix)

Method to recursively draw a distance value from the given set distance distribution and check that it is in the bounds

draw_from_pixel(ra, dec, pix)

Recursive function to uniformly draw ra, and dec values that are located in the given pixel

filled_request()

Check if all requested parameters have been filled.

filled_rescale()

Check if all the rescaled parameters have been filled.

get_instantiation_dict()

ln_prob(value)

Get the log-probability of a sample.

prob(samp)

Get the probability of a sample.

rescale(value, **kwargs)

Rescale from a unit hypercube to JointPriorDist.

reset_request()

Reset the requested parameters to None.

reset_rescale()

Reset the rescaled parameters to None.

reset_sampled()

sample([size])

Draw, and set, a sample from the Dist, accompanying method _sample needs to overwritten

update_distance(pix_idx)

Method to update the conditional distance distributions at given pixel used for distance handling in the JointPrior Parameters.

check_in_pixel(ra, dec, pix)[source]

Method that checks if given rightacension and declination values are within the given pixel index and the bounds

Parameters:
rafloat, int

rightascension value to check

decfloat, int

declination value to check

pixint

index for pixel we want to check in

Returns:
bool

returns True if values inside pixel, False if not

draw_distance(pix)[source]

Method to recursively draw a distance value from the given set distance distribution and check that it is in the bounds

Parameters:
pixint

integer for pixel to draw a distance from

Returns:
distfloat

sample drawn from the distance distribution at set pixel index

draw_from_pixel(ra, dec, pix)[source]

Recursive function to uniformly draw ra, and dec values that are located in the given pixel

Parameters:
rafloat, int

value drawn for rightascension

decfloat, int

value drawn for declination

pixint

pixel index for given pixel we want to get ra, and dec from

Returns:
ra_dectuple

this returns a tuple of ra, and dec sampled uniformly that are in the pixel given

filled_request()[source]

Check if all requested parameters have been filled.

filled_rescale()[source]

Check if all the rescaled parameters have been filled.

ln_prob(value)[source]

Get the log-probability of a sample. For bounded priors the probability will not be properly normalised.

Parameters:
value: array_like

A 1d vector of the sample, or 2d array of sample values with shape NxM, where N is the number of samples and M is the number of parameters.

prob(samp)[source]

Get the probability of a sample. For bounded priors the probability will not be properly normalised.

rescale(value, **kwargs)[source]

Rescale from a unit hypercube to JointPriorDist. Note that no bounds are applied in the rescale function. (child classes need to overwrite accompanying method _rescale().

Parameters:
value: array

A 1d vector sample (one for each parameter) drawn from a uniform distribution between 0 and 1, or a 2d NxM array of samples where N is the number of samples and M is the number of parameters.

kwargs: dict

All keyword args that need to be passed to _rescale method, these keyword args are called in the JointPrior rescale methods for each parameter

Returns:
array:

An vector sample drawn from the multivariate Gaussian distribution.

reset_request()[source]

Reset the requested parameters to None.

reset_rescale()[source]

Reset the rescaled parameters to None.

sample(size=1, **kwargs)[source]

Draw, and set, a sample from the Dist, accompanying method _sample needs to overwritten

Parameters:
size: int

number of samples to generate, defaults to 1

update_distance(pix_idx)[source]

Method to update the conditional distance distributions at given pixel used for distance handling in the JointPrior Parameters. This function updates the current distance pdf, inverse_cdf, and sampler according to given pixel or line of sight.

Parameters:
pix_idxint

pixel index value to create the distribution for

Returns:
NoneNone

just updates these functions at new pixel values