def lambda_tilde_here(delta):
    # compute m1,m2
    eta = 0.25 * (1.0 - delta * delta)
    m1, m2 = lalsimutils.m1m2(mc_source, eta)
    lam1 = lam_fit(m1)
    lam2 = lam_fit(m2)
    lambda_tilde, dLt = lalsimutils.tidal_lambda_tilde(m1, m2, lam1, lam2)
    return lambda_tilde
示例#2
0
def extract_combination_from_LI(samples_LI, p):
    """
    extract_combination_from_LI
      - reads in known columns from posterior samples
      - for selected known combinations not always available, it will compute them from standard quantities
    Unike version in ConstructIntrinsicPosterior, this code does not rely on ChooseWaveformParams to perform coordinate changes...
    """
    if p in samples_LI.dtype.names:  # e.g., we have precomputed it
        return samples_LI[p]
    if p in remap_ILE_2_LI.keys():
        if remap_ILE_2_LI[p] in samples_LI.dtype.names:
            return samples_LI[remap_ILE_2_LI[p]]
    # Return cartesian components of spin1, spin2.  NOTE: I may already populate these quantities in 'Add important quantities'
    if (p == 'chi_eff' or p == 'xi') and 'a1z' in samples_LI.dtype.names:
        m1 = samples_LI['m1']
        m2 = samples_LI['m2']
        a1z = samples_LI['a1z']
        a2z = samples_LI['a2z']
        return (m1 * a1z + m2 * a2z) / (m1 + m2)
    if p == 'chiz_plus':
        print(" Transforming ")
        if 'a1z' in samples_LI.dtype.names:
            return (samples_LI['a1z'] + samples_LI['a2z']) / 2.
        if 'theta1' in samples_LI.dtype.names:
            return (samples_LI['a1'] * np.cos(samples_LI['theta1']) +
                    samples_LI['a2'] * np.cos(samples_LI['theta2'])) / 2.
#        return (samples_LI['a1']+ samples_LI['a2'])/2.
    if p == 'chiz_minus':
        print(" Transforming ")
        if 'a1z' in samples_LI.dtype.names:
            return (samples_LI['a1z'] - samples_LI['a2z']) / 2.
        if 'theta1' in samples_LI.dtype.names:
            return (samples_LI['a1'] * np.cos(samples_LI['theta1']) -
                    samples_LI['a2'] * np.cos(samples_LI['theta2'])) / 2.
#        return (samples_LI['a1']- samples_LI['a2'])/2.
    if 'theta1' in samples_LI.dtype.names:
        if p == 's1x':
            return samples_LI["a1"] * np.sin(samples_LI['theta1']) * np.cos(
                samples_LI['phi1'])
        if p == 's1y':
            return samples_LI["a1"] * np.sin(samples_LI['theta1']) * np.sin(
                samples_LI['phi1'])
        if p == 's2x':
            return samples_LI["a2"] * np.sin(samples_LI['theta2']) * np.cos(
                samples_LI['phi2'])
        if p == 's2y':
            return samples_LI["a2"] * np.sin(samples_LI['theta2']) * np.sin(
                samples_LI['phi2'])
        if p == 'chi1_perp':
            return samples_LI["a1"] * np.sin(samples_LI['theta1'])
        if p == 'chi2_perp':
            return samples_LI["a2"] * np.sin(samples_LI['theta2'])
    elif 'tilt1' in samples_LI.dtype.names:
        if p == 'chi1_perp':
            return samples_LI["a1"] * np.sin(samples_LI['tilt1'])
        if p == 'chi2_perp':
            return samples_LI["a2"] * np.sin(samples_LI['tilt2'])
    else:  # aligned
        if p == 'chi1_perp':
            return np.zeros(len(samples_LI["m1"]))
        if p == 'chi2_perp':
            return np.zeros(len(samples_LI["m1"]))

    if 'lambdat' in samples_LI.dtype.names:  # LI does sampling in these tidal coordinates
        lambda1, lambda2 = lalsimutils.tidal_lambda_from_tilde(
            samples_LI["m1"], samples_LI["m2"], samples_LI["lambdat"],
            samples_LI["dlambdat"])
        if p == "lambda1":
            return lambda1
        if p == "lambda2":
            return lambda2
    if p == 'delta' or p == 'delta_mc':
        return (samples_LI['m1'] - samples_LI['m2']) / (
            (samples_LI['m1'] + samples_LI['m2']))
    # Return cartesian components of Lhat
    if p == 'product(sin_beta,sin_phiJL)':
        return np.sin(samples_LI[remap_ILE_2_LI['beta']]) * np.sin(
            samples_LI['phi_jl'])
    if p == 'product(sin_beta,cos_phiJL)':
        return np.sin(samples_LI[remap_ILE_2_LI['beta']]) * np.cos(
            samples_LI['phi_jl'])

    if p == 'mc':
        m1v = samples["m1"]
        m2v = samples["m2"]
        return lalsimutils.mchirp(m1v, m2v)
    if p == 'eta':
        m1v = samples["m1"]
        m2v = samples["m2"]
        return lalsimutils.symRatio(m1v, m2v)

    # Backup : access lambdat if not present
    if (p == 'lambdat'
            or p == 'dlambdat') and 'lambda1' in samples.dtype.names:
        Lt, dLt = lalsimutils.tidal_lambda_tilde(samples['m1'], samples['m2'],
                                                 samples['lambda1'],
                                                 samples['lambda2'])
        if p == 'lambdat':
            return Lt
        if p == 'dlambdat':
            return dLt

    if p == "q" and 'm1' in samples.dtype.names:
        return samples["m2"] / samples["m1"]

    print(" No access for parameter ", p, " in ", samples.dtype.names)
    return np.zeros(len(samples_LI['m1']))  # to avoid causing a hard failure
示例#3
0
                samples['chi_eff'] = (samples["m1"] * samples["a1z"] +
                                      samples["m2"] * samples["a2z"]) / (
                                          samples["m1"] + samples["m2"])

        elif 'a1x' in samples.dtype.names:
            chi1_perp = np.sqrt(samples['a1x']**2 + samples['a1y']**2)
            chi2_perp = np.sqrt(samples['a2x']**2 + samples['a2y']**2)
            samples = add_field(samples, [('chi1_perp', float)])
            samples['chi1_perp'] = chi1_perp
            samples = add_field(samples, [('chi2_perp', float)])
            samples['chi2_perp'] = chi2_perp

        if 'lambda1' in samples.dtype.names and not ('lambdat'
                                                     in samples.dtype.names):
            Lt, dLt = lalsimutils.tidal_lambda_tilde(samples['m1'],
                                                     samples['m2'],
                                                     samples['lambda1'],
                                                     samples['lambda2'])
            samples = add_field(samples, [('lambdat', float)])
            samples['lambdat'] = Lt
            samples = add_field(samples, [('dlambdat', float)])
            samples['dlambdat'] = dLt

        if 'chi1_perp' in samples.dtype.names:
            # impose Kerr limit, if neede
            npts = len(samples["m1"])
            indx_ok = np.arange(npts)
            chi1_squared = samples['chi1_perp']**2 + samples["a1z"]**2
            chi2_squared = samples["chi2_perp"]**2 + samples["a2z"]**2
            indx_ok = np.logical_and(chi1_squared < opts.chi_max,
                                     chi2_squared < opts.chi_max)
            npts_out = np.sum(indx_ok)