:py:mod:`nessai.gw.utils` ========================= .. py:module:: nessai.gw.utils .. autoapi-nested-parse:: Utilities specific to the gw subpackage. .. !! processed by numpydoc !! Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: nessai.gw.utils.DistanceConverter nessai.gw.utils.NullDistanceConverter nessai.gw.utils.PowerLawConverter nessai.gw.utils.ComovingDistanceConverter Functions ~~~~~~~~~ .. autoapisummary:: nessai.gw.utils.get_distance_converter Attributes ~~~~~~~~~~ .. autoapisummary:: nessai.gw.utils.logger .. py:data:: logger .. !! processed by numpydoc !! .. py:class:: DistanceConverter Bases: :py:obj:`abc.ABC` Base object for converting from a distance parameter to a uniform parameter. See :py:obj:`nessai.gw.reparameterisations.DistanceReparameterisation` for more details on how the distance converters are used. .. !! processed by numpydoc !! .. py:attribute:: has_conversion :annotation: = False Indicates if the converter class includes a conversion. This is used when defining the prior in the X-prime space. For example, the :code:`NullDistanceConverter` doesn't apply a conversion to a uniform parameter, so the prime prior cannot be defined. .. !! processed by numpydoc !! .. py:attribute:: has_jacobian :annotation: = False Indicates if the transform applied by the converter has a tractable jacobian. .. !! processed by numpydoc !! .. py:method:: to_uniform_parameter(self, d) :abstractmethod: Converter to parameter that has uniform prior. :Parameters: **d** : array_like Distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant .. !! processed by numpydoc !! .. py:method:: from_uniform_parameter(self, d) :abstractmethod: Convert from a parameter that has a uniform prior. :Parameters: **d** : array_like Scaled distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant .. !! processed by numpydoc !! .. py:class:: NullDistanceConverter(**kwargs) Bases: :py:obj:`DistanceConverter` Converter that applies the identity transformation. Used for cases where the prior on distance is not specified. .. !! processed by numpydoc !! .. py:attribute:: has_jacobian :annotation: = True .. !! processed by numpydoc !! .. py:method:: to_uniform_parameter(self, d) Applies the identity transformation. :Parameters: **d** : array_like Distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant, which will always be zero. .. !! processed by numpydoc !! .. py:method:: from_uniform_parameter(self, d) Applies the identity transformation. :Parameters: **d** : array_like Distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant, which will always be zero. .. !! processed by numpydoc !! .. py:class:: PowerLawConverter(power=None, scale=1000.0, **kwargs) Bases: :py:obj:`DistanceConverter` Convert from a distance parameter sampled from a power law to a uniform parameter. Assumes d is proportional to :math:`d^{(\text{power} + 1)}` following the convention in Bilby. :Parameters: **power** : float Power to use for the power-law. **scale** : float Factor used to rescale distance prior to converting to the uniform parameter. .. !! processed by numpydoc !! .. py:attribute:: has_conversion :annotation: = True .. !! processed by numpydoc !! .. py:attribute:: has_jacobian :annotation: = True .. !! processed by numpydoc !! .. py:method:: to_uniform_parameter(self, d) Convert distance to a parameter with a uniform prior. :Parameters: **d** : array_like Distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant. .. !! processed by numpydoc !! .. py:method:: from_uniform_parameter(self, d) Convert to distance from a parameter that has a uniform prior. :Parameters: **d** : array_like scaled distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant. .. !! processed by numpydoc !! .. py:class:: ComovingDistanceConverter(d_min=None, d_max=None, units='Mpc', cosmology='Planck15', scale=1000.0, pad=0.05, n_interp=500) Bases: :py:obj:`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_max** : float Minimum and maximum distances. **units** : str, optional Units used for the distance, must be compatible with astropy units. **cosmology** : str, optional Cosmology used for conversion, must be compatible with astropy. Default is Planck15. **scale** : float, optional Rescaling applied to distance after converting to co-moving distance. **pad** : float, optional Padding used for min and max of interpolation range: min = (1 - pad) * d_min and max = (1 + pad) * d_max **n_interp** : int, 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. .. !! processed by numpydoc !! .. py:attribute:: has_conversion :annotation: = True .. !! processed by numpydoc !! .. py:attribute:: has_jacobian :annotation: = False .. !! processed by numpydoc !! .. py:method:: to_uniform_parameter(self, d) Convert luminosity distance to a parameter with a uniform prior. :Parameters: **d** : array_like Distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant, which will always be zero. .. !! processed by numpydoc !! .. py:method:: from_uniform_parameter(self, d) Convert from a uniform parameter to luminosity distance. :Parameters: **d** : array_like Scaled distance. :Returns: **d, log_j** : array_like Distance and the log Jacobian determinant, which will always be zero. .. !! processed by numpydoc !! .. py:function:: get_distance_converter(prior) Get a distance converter from a type of prior. If the prior is unknown :py:obj:`nessai.gw.utils.NullDistanceConverter` is returned which has the identity rescaling. :Parameters: **prior** : str, {'uniform-comoving-volume', 'power-law'} The prior that is being used for the distance parameter. :Returns: :obj:`nessai.gw.utils.DistanceConverter` The corresponding distance converter. .. !! processed by numpydoc !!