Skip to content
Snippets Groups Projects
Commit 0394aa72 authored by Colm Talbot's avatar Colm Talbot Committed by Moritz Huebner
Browse files

add aligned spin prior

parent ff8cb967
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ Changes currently on master, but not under a tag.
- Hyperparameter estimation now enables the user to provide the single event evidences
- Add nested samples to nestle output
- Prior and child classes now implement the \_\_eq\_\_ magic method for comparisons
- Add AlignedSpin gw prior
### Changes
- Fix construct_cbc_derived_parameters
......
......@@ -7,7 +7,6 @@ import os
import shutil
from collections import OrderedDict
class TestPriorInstantiationWithoutOptionalPriors(unittest.TestCase):
def setUp(self):
......@@ -152,7 +151,8 @@ class TestPriorClasses(unittest.TestCase):
tupak.core.prior.Cauchy(name='test', unit='unit', alpha=0, beta=1),
tupak.core.prior.Lorentzian(name='test', unit='unit', alpha=0, beta=1),
tupak.core.prior.Gamma(name='test', unit='unit', k=1, theta=1),
tupak.core.prior.ChiSquared(name='test', unit='unit', nu=2)
tupak.core.prior.ChiSquared(name='test', unit='unit', nu=2),
tupak.gw.prior.AlignedSpin(name='test', unit='unit')
]
def test_minimum_rescaling(self):
......
import os
from ..core.prior import PriorSet, FromFile, Prior, DeltaFunction, Gaussian
from ..core.prior import (PriorSet, Uniform, FromFile, Prior, DeltaFunction,
Gaussian, Interped)
from ..core.utils import logger
import numpy as np
from scipy.interpolate import UnivariateSpline
......@@ -26,6 +27,43 @@ class UniformComovingVolume(FromFile):
latex_label=latex_label, unit='Mpc')
class AlignedSpin(Interped):
def __init__(self, a_prior=Uniform(0, 1), z_prior=Uniform(-1, 1),
name=None, latex_label=None, unit=None):
"""
Prior distribution for the aligned (z) component of the spin.
This takes prior distributions for the magnitude and cosine of the tilt
and forms a compound prior.
This is useful when using aligned-spin only waveform approximants.
This is an extension of e.g., (A7) of https://arxiv.org/abs/1805.10457.
Parameters
----------
a_prior: Prior
Prior distribution for spin magnitude
z_prior: Prior
Prior distribution for cosine spin tilt
name: see superclass
latex_label: see superclass
unit: see superclass
"""
self.a_prior = a_prior
self.z_prior = z_prior
chi_min = min(a_prior.maximum * z_prior.minimum,
a_prior.minimum * z_prior.maximum)
chi_max = a_prior.maximum * z_prior.maximum
xx = np.linspace(chi_min, chi_max, 800)
aas = np.linspace(a_prior.minimum, a_prior.maximum, 1000)
yy = [np.trapz(np.nan_to_num(a_prior.prob(aas) / aas *
z_prior.prob(x / aas)), aas) for x in xx]
Interped.__init__(self, xx=xx, yy=yy, name=name,
latex_label=latex_label, unit=unit)
class BBHPriorSet(PriorSet):
def __init__(self, dictionary=None, filename=None):
""" Initialises a Prior set for Binary Black holes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment