nessai.gw.legacy

Legacy version of GWFlowProposal used in the first paper and the realted utilities and priors

Module Contents

Classes

LegacyGWFlowProposal

A proposal specific to gravitational wave CBC

Functions

determine_rescaled_bounds(prior_min, prior_max, x_min, x_max, invert)

Determine the values of the prior min and max in the rescaled

angle_to_cartesian(alpha, r=None, scale=1.0)

Decompose an angle into a real and imaginary part

cartesian_to_angle(x, y, scale=1.0, zero='centre')

Reconstruct an angle given the real and imaginary part. Assume the angle

ra_dec_to_cartesian(ra, dec, dL=None)

Convert right ascension, declination and (optional) luminosity distance

cartesian_to_ra_dec(x, y, z)

Reconstruct an angle given the real and imaginary part

azimuth_zenith_to_cartesian(azimuth, zenith, dL=None)

Convert azimuth, zenith and (optional) luminosity distance

cartesian_to_azimuth_zenith(x, y, z)

Reconstruct an angle given the real and imaginary part

zero_one_to_cartesian(theta, mode='split')

Convert a variable defined on [0,1] to an angle on [-pi, pi] and

cartesian_to_zero_one(x, y)

Convert Cartesian coordinates to a variable defined on [0, 1] and

transform_from_precessing_parameters(theta_jn, phi_jl, theta_1, theta_2, phi_12, a_1, a_2, m1, m2, f_ref, phase)

transform_to_precessing_parameters(iota, s1x, s1y, s1z, s2x, s2y, s2z, m1, m2, f_ref, phase)

rescale_and_logit(x, xmin, xmax)

rescale_and_sigmoid(x, xmin, xmax)

log_uniform_prior(x, xmin=-1, xmax=1)

Unformalised log probability of uniform prior

log_2d_cartesian_prior(x, y, k=np.pi)

Log probability of Cartesian coordinates for a uniform distibution of

log_2d_cartesian_prior_sine(x, y)

Log probability of Cartesian coordinates for a sine distibution of

log_3d_cartesian_prior(x, y, z)

Log probability of 3d Cartesian coordinates for an isotropic distribution

log_spin_prior(s1x, s1y, s1z, s2x, s2y, s2z, k1=0.99, k2=0.99)

Log probability of the prior on the components of spin vectors

log_spin_prior_uniform(s1x, s1y, s1z, s2x, s2y, s2z, k1=0.99, k2=0.99)

Log probability of the prior on the components of spin vectors

Attributes

logger

nessai.gw.legacy.logger
nessai.gw.legacy.determine_rescaled_bounds(prior_min, prior_max, x_min, x_max, invert)

Determine the values of the prior min and max in the rescaled space. Parameters ———- prior_min : float

Mininum of the prior

prior_maxfloat

Maximum of the prior

x_minfloat

New minimum

x_maxfloat

New maximum

invertfalse or {‘upper’, ‘lower’, ‘both’}

Type of inversion

nessai.gw.legacy.angle_to_cartesian(alpha, r=None, scale=1.0)

Decompose an angle into a real and imaginary part

nessai.gw.legacy.cartesian_to_angle(x, y, scale=1.0, zero='centre')

Reconstruct an angle given the real and imaginary part. Assume the angle is defined on [0, 2 pi] / scale.

Parameters
x, yarray_like

Cartesian coordinates

scalefloat, optional

Rescaling factor used to rescale from [0, 2pi]

zerostr, {centre, bound}

Specifiy is zero should be the central value or lower bound

nessai.gw.legacy.ra_dec_to_cartesian(ra, dec, dL=None)

Convert right ascension, declination and (optional) luminosity distance (defined on [0, 1]) to Cartesian coordinates.

Parameters
ra, dec: array_like

Right ascension and declination

dL: array_like, optional

Corresponding luminosity distance defined on [0, 1]. If None (default) radial componment is drawn froma chi distribution with 3 degrees of freedom

Returns
x, y, z: array_like

Cartesian coordinates

log_J: array_like

Determinant of the log-Jacobian

nessai.gw.legacy.cartesian_to_ra_dec(x, y, z)

Reconstruct an angle given the real and imaginary part

Parameters
x, y, z: array_like

Three dimensional Cartesian coordinates

Returns:
ra, dec: array_like

Right ascension and declination

dl: array_like

Luminosity distance

log_J: array_like

Determinant of the log-Jacobian

nessai.gw.legacy.azimuth_zenith_to_cartesian(azimuth, zenith, dL=None)

Convert azimuth, zenith and (optional) luminosity distance (defined on [0, 1]) to Cartesian coordinates.

Parameters
azimuth, zenith: array_like

Azimuth and zenith

dL: array_like, optional

Corresponding luminosity distance defined on [0, 1]. If None (default) radial componment is drawn froma chi distribution with 3 degrees of freedom

Returns
x, y, z: array_like

Cartesian coordinates

log_J: array_like

Determinant of the log-Jacobian

nessai.gw.legacy.cartesian_to_azimuth_zenith(x, y, z)

Reconstruct an angle given the real and imaginary part

Parameters
x, y, z: array_like

Three dimensional Cartesian coordinates

nessai.gw.legacy.zero_one_to_cartesian(theta, mode='split')

Convert a variable defined on [0,1] to an angle on [-pi, pi] and to Cartesian coordinates with a radius drawn from a chi distribution with two degrees of freedom. The lower bound is place at 0 and the upper bound at -pi/pi.

Parameters
theta: array_like

Array of values bound on [0, 1]

Returns
x, y: array_like

Cartesian coordinates

log_J: array_like

Determinant of the log-Jacobian

nessai.gw.legacy.cartesian_to_zero_one(x, y)

Convert Cartesian coordinates to a variable defined on [0, 1] and a corresponding radius.

Parameters
x, y: array_like

Cartesian coordinates

Returns
theta: array_like

Variable defined on [0,1]

radius: array_like

Corresponding radius

log_J: array_like

Determinant of log-Jacobian

nessai.gw.legacy.transform_from_precessing_parameters(theta_jn, phi_jl, theta_1, theta_2, phi_12, a_1, a_2, m1, m2, f_ref, phase)
nessai.gw.legacy.transform_to_precessing_parameters(iota, s1x, s1y, s1z, s2x, s2y, s2z, m1, m2, f_ref, phase)
nessai.gw.legacy.rescale_and_logit(x, xmin, xmax)
nessai.gw.legacy.rescale_and_sigmoid(x, xmin, xmax)
nessai.gw.legacy.log_uniform_prior(x, xmin=- 1, xmax=1)

Unformalised log probability of uniform prior

nessai.gw.legacy.log_2d_cartesian_prior(x, y, k=np.pi)

Log probability of Cartesian coordinates for a uniform distibution of angles on [0, k] and a radial component drawn from a chi distribution with two degrees of freedom.

nessai.gw.legacy.log_2d_cartesian_prior_sine(x, y)

Log probability of Cartesian coordinates for a sine distibution of angles and a radial component drawn from a chi distribution with two degrees of freedom.

nessai.gw.legacy.log_3d_cartesian_prior(x, y, z)

Log probability of 3d Cartesian coordinates for an isotropic distribution of angles and a radial component drawn from a chi distribution with three degrees of freedom.

nessai.gw.legacy.log_spin_prior(s1x, s1y, s1z, s2x, s2y, s2z, k1=0.99, k2=0.99)

Log probability of the prior on the components of spin vectors assume the distribution of a_i is uniform.

nessai.gw.legacy.log_spin_prior_uniform(s1x, s1y, s1z, s2x, s2y, s2z, k1=0.99, k2=0.99)

Log probability of the prior on the components of spin vectors assume the distribution the components in uniform within the 2-ball.

class nessai.gw.legacy.LegacyGWFlowProposal(model, reparameterisations={}, **kwargs)

Bases: nessai.proposal.FlowProposal

A proposal specific to gravitational wave CBC

set_reparameterisations(self, reparameterisations)

Set the relevant reparamterisation flags

setup_angle(self, name, radial_name=False, scale=1.0, zero='bound')

Add an angular parameter to the list of reparameterisations

property inversion_parameters(self)

Returns a list of parameters to which an inversion (normal or log)

add_inversion(self, name)

Setup inversion

add_log_inversion(self, name)

Setup log inversion

add_angle_conversion(self, name, mode='split')
configure_time(self)

Configure the time parameter if present

configure_sky(self)

Configure the sky parameters

configure_angles(self)

Configure angles

set_rescaling(self)

Set the rescaling functions

check_state(self, x)

Check the state of the rescaling before training

update_rescaled_bounds(self, rescaled_names=None, xmin=None, xmax=None)
setup_uniform_distance_parameter(self, scale_factor=1000, **kwargs)

Set up the uniform distance parameter dc3

Parameters
scale_factorfloat, (optional)

Factor used to rescale comoving distance

kwargs

Keyword arguments parsed to ComovingDistanceConverter

convert_to_dl(self, dc3)

Convert from uniform distance parameter dc3 to luminosity distance

convert_to_dc3(self, dl)

Convert to uniform distance parameter dc3

setup_spin_logit(self, fuzz_factor=0.01)
configure_spin_conversion(self, m1=20, m2=20, phase=0, f_ref=20, scale_factor=1, use_cbrt=True)
rescale(self, x, compute_radius=False, test=None)

Rescale from the x space to the x prime space

inverse_rescale(self, x_prime)

Rescale from the x prime space to the x space

log_prior(self, x)

Modified log prior that handles radial parameters

compute_rescaled_bounds(self, name)
x_prime_log_prior(self, x_prime)

Priors redefined in the x_prime space