nessai.gw.utils
Utilities specific to the gw subpackage.
Module Contents
Classes
Base object for converting from a distance parameter to a uniform parameter. |
|
Converter that applies the identity transformation. |
|
Convert from a distance parameter sampled from a power law to a uniform |
|
Object to convert luminosity distance with a prior that is uniform |
Functions
|
Get a distance converter from a type of prior. |
Attributes
- nessai.gw.utils.logger
- class nessai.gw.utils.DistanceConverter
Bases:
abc.ABC
Base object for converting from a distance parameter to a uniform parameter.
See
nessai.gw.reparameterisations.DistanceReparameterisation
for more details on how the distance converters are used.- has_conversion = False
Indicates if the converter class includes a conversion. This is used when defining the prior in the X-prime space. For example, the
NullDistanceConverter
doesn’t apply a conversion to a uniform parameter, so the prime prior cannot be defined.
- has_jacobian = False
Indicates if the transform applied by the converter has a tractable jacobian.
- abstract to_uniform_parameter(self, d)
Converter to parameter that has uniform prior.
- Parameters
- darray_like
Distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant
- abstract from_uniform_parameter(self, d)
Convert from a parameter that has a uniform prior.
- Parameters
- darray_like
Scaled distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant
- class nessai.gw.utils.NullDistanceConverter(**kwargs)
Bases:
DistanceConverter
Converter that applies the identity transformation.
Used for cases where the prior on distance is not specified.
- has_jacobian = True
- to_uniform_parameter(self, d)
Applies the identity transformation.
- Parameters
- darray_like
Distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant, which will always be zero.
- from_uniform_parameter(self, d)
Applies the identity transformation.
- Parameters
- darray_like
Distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant, which will always be zero.
- class nessai.gw.utils.PowerLawConverter(power=None, scale=1000.0, **kwargs)
Bases:
DistanceConverter
Convert from a distance parameter sampled from a power law to a uniform parameter.
Assumes d is proportional to \(d^{(\text{power} + 1)}\) following the convention in Bilby.
- Parameters
- powerfloat
Power to use for the power-law.
- scalefloat
Factor used to rescale distance prior to converting to the uniform parameter.
- has_conversion = True
- has_jacobian = True
- to_uniform_parameter(self, d)
Convert distance to a parameter with a uniform prior.
- Parameters
- darray_like
Distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant.
- from_uniform_parameter(self, d)
Convert to distance from a parameter that has a uniform prior.
- Parameters
- darray_like
scaled distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant.
- class nessai.gw.utils.ComovingDistanceConverter(d_min=None, d_max=None, units='Mpc', cosmology='Planck15', scale=1000.0, pad=0.05, n_interp=500)
Bases:
DistanceConverter
Object to convert luminosity distance with a prior that is uniform in co-moving volume to a parameter with a uniform prior.
The uniform parameter is a scaled version of the co-moving distance cubed. This transformation does not have a tractable Jacobian determinant and therefore returns zero.
- Parameters
- d_min, d_maxfloat
Minimum and maximum distances.
- unitsstr, optional
Units used for the distance, must be compatible with astropy units.
- cosmologystr, optional
Cosmology used for conversion, must be compatible with astropy. Default is Planck15.
- scalefloat, optional
Rescaling applied to distance after converting to co-moving distance.
- padfloat, optional
Padding used for min and max of interpolation range: min = (1 - pad) * d_min and max = (1 + pad) * d_max
- n_interpint, optional
Length of vector used for generating the look up table. For a range of [100, 5000] 200 seems to the minimum for the conversion to be invertible up to 6 decimal places. The recommended setting is at 500.
- has_conversion = True
- has_jacobian = False
- to_uniform_parameter(self, d)
Convert luminosity distance to a parameter with a uniform prior.
- Parameters
- darray_like
Distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant, which will always be zero.
- from_uniform_parameter(self, d)
Convert from a uniform parameter to luminosity distance.
- Parameters
- darray_like
Scaled distance.
- Returns
- d, log_jarray_like
Distance and the log Jacobian determinant, which will always be zero.
- nessai.gw.utils.get_distance_converter(prior)
Get a distance converter from a type of prior.
If the prior is unknown
nessai.gw.utils.NullDistanceConverter
is returned which has the identity rescaling.- Parameters
- priorstr, {‘uniform-comoving-volume’, ‘power-law’}
The prior that is being used for the distance parameter.
- Returns
nessai.gw.utils.DistanceConverter
The corresponding distance converter.