コード例 #1
0
def addm1m2(pos):
    injection = pos.injection()
    # Produce m1,m2 if requested and not available
    if ('mc' in pos.names or 'mchirp' in pos.names) and \
        'eta' in pos.names and \
        ('mass1' not in pos.names or 'm1' not in pos.names) and\
        ('m2' not in pos.names or 'm2' not in pos.names):

        if 'mc' in pos.names:
            mchirp_name = 'mc'
        else:
            mchirp_name = 'mchirp'
        inj_mass1 = None
        inj_mass2 = None
        if injection:
            inj_mass1, inj_mass2 = bppu.mc2ms(injection.mchirp, injection.eta)
        mass1_samps, mass2_samps = bppu.mc2ms(pos[mchirp_name].samples,
                                              pos['eta'].samples)
        mass1_pos = bppu.PosteriorOneDPDF('m1',
                                          mass1_samps,
                                          injected_value=inj_mass1)
        mass2_pos = bppu.PosteriorOneDPDF('m2',
                                          mass2_samps,
                                          injected_value=inj_mass2)
        pos.append(mass1_pos)
        pos.append(mass2_pos)
    return
コード例 #2
0
def compute_mass_parameterizations(samples):
    params = samples.dtype.names
    has_mc = 'mchirp' in params
    has_eta = 'eta' in params
    has_q = 'q' in params
    has_ms = 'mass1' in params and 'mass2' in params
    has_mtotal = 'mtotal' in params

    if has_mc:
        mc = samples['mchirp']
        if not has_eta:
            if has_q:
                eta = bppu.q2eta(mc, samples['q'])
            else:
                raise ValueError("Chirp mass given with no mass ratio.")
        else:
            eta = samples['eta']

        if not has_ms:
            m1, m2 = bppu.mc2ms(mc, eta)

        mtotal = m1 + m2

    elif has_ms:
        m1 = samples['mass1']
        m2 = samples['mass2']
        mtotal = m1 + m2
        eta = m1 * m2 / (mtotal * mtotal)
        mc = mtotal * np.power(eta, 3./5.)

    elif has_mtotal:
        mtotal = samples['mtotal']
        if has_eta:
            eta = samples['eta']
            mc = mtotal * np.power(eta, 3./5.)
            m1, m2 = bppu.mc2ms(mc, eta)
        elif has_q:
            m1 = mtotal / (1 + samples['q'])
            m2 = mtotal - m1
        else:
            raise ValueError("Chirp mass given with no mass ratio.")
    return mc, eta, m1, m2, mtotal
コード例 #3
0
def compute_mass_parameterizations(samples):
    params = samples.dtype.names
    has_mc = 'mchirp' in params
    has_eta = 'eta' in params
    has_q = 'q' in params
    has_ms = 'mass1' in params and 'mass2' in params
    has_mtotal = 'mtotal' in params

    if has_mc:
        mc = samples['mchirp']
        if not has_eta:
            if has_q:
                eta = bppu.q2eta(mc, samples['q'])
            else:
                raise ValueError("Chirp mass given with no mass ratio.")
        else:
            eta = samples['eta']

        if not has_ms:
            m1, m2 = bppu.mc2ms(mc, eta)

        mtotal = m1 + m2

    elif has_ms:
        m1 = samples['mass1']
        m2 = samples['mass2']
        mtotal = m1 + m2
        eta = m1 * m2 / (mtotal * mtotal)
        mc = mtotal * np.power(eta, 3. / 5.)

    elif has_mtotal:
        mtotal = samples['mtotal']
        if has_eta:
            eta = samples['eta']
            mc = mtotal * np.power(eta, 3. / 5.)
            m1, m2 = bppu.mc2ms(mc, eta)
        elif has_q:
            m1 = mtotal / (1 + samples['q'])
            m2 = mtotal - m1
        else:
            raise ValueError("Chirp mass given with no mass ratio.")
    return mc, eta, m1, m2, mtotal
コード例 #4
0
def addm1m2(pos):
    injection = pos.injection()
    # Produce m1,m2 if requested and not available
    if ('mc' in pos.names or 'mchirp' in pos.names) and \
        'eta' in pos.names and \
        ('mass1' not in pos.names or 'm1' not in pos.names) and\
        ('m2' not in pos.names or 'm2' not in pos.names):

        if 'mc' in pos.names:
            mchirp_name='mc'
        else:
            mchirp_name='mchirp'
        inj_mass1=None
        inj_mass2=None
        if injection:
            inj_mass1,inj_mass2=bppu.mc2ms(injection.mchirp,injection.eta)
        mass1_samps,mass2_samps=bppu.mc2ms(pos[mchirp_name].samples,pos['eta'].samples)
        mass1_pos=bppu.PosteriorOneDPDF('m1',mass1_samps,injected_value=inj_mass1)
        mass2_pos=bppu.PosteriorOneDPDF('m2',mass2_samps,injected_value=inj_mass2)
        pos.append(mass1_pos)
        pos.append(mass2_pos)
    return