Exemple #1
0
                   pixarea,
                   H0_min,
                   H0_max,
                   z_min,
                   z_max,
                   zerr_use=zerr_use,
                   cosmo_use=cosmo_use))

posterior = np.exp(lnposterior)
plt.ion()
plt.clf()
plt.plot(H0_array, np.exp(lnposterior))
#plt.yscale('log')
plt.xlabel('$H_0$ [km/s/Mpc]', fontsize=20)
plt.ylabel('$p$', fontsize=20)
plt.tight_layout()
plt.savefig(DIR_PLOTS + out_plot)

idx_max = np.argmax(posterior)

perc_max = posterior[:idx_max].sum() / posterior.sum()

maxposterior = posterior[idx_max]

print "ML percentile: ", perc_max
print "H0 max posterior: ", H0_array[idx_max], "+", pos.percentile(
    perc_max + 0.34, posterior,
    H0_array) - H0_array[idx_max], "-", H0_array[idx_max] - pos.percentile(
        perc_max - 0.34, posterior, H0_array)
print "H0 Median: ", pos.percentile(0.50, posterior, H0_array)
    if blind:
        #Output path for blinding file
        blindpath = DIR_MAIN + "/blinding_file.p"
        H0_blinded_array = pos.make_blind(H0_array, blindpath)
        print 'Applying blinding factor. Saving value on ', blindpath
        H0_array_out = H0_blinded_array
        print "Blinded results:"
    else:
        print 'No blinding applied!'
        H0_array_out = H0_array

    H0_maxlike = H0_array_out[idx_max]
    H0_err_p = abs(H0_array_out[idx_err_p] - H0_array_out[idx_max])
    H0_err_m = abs(H0_array_out[idx_err_m] - H0_array_out[idx_max])
    H0_median = pos.percentile(0.50, posterior[:, nevent], H0_array_out)

    print " ML percentile: ", perc_max
    print " H0 ML: ", H0_maxlike, "+", H0_err_p, "-", H0_err_m
    print " H0 Median: ", H0_median

fmt = "%10.5f"
if blind:
    header = "H0_Blinded"
else:
    header = "H0"

for nevent in range(nevents):
    norm = np.trapz(posterior[:, nevent], H0_array_out)
    posterior[:, nevent] = posterior[:, nevent] / norm
    dl = int(distmu_average[nevent])
Exemple #3
0
    posterior[:, nevent] = np.exp(lnposterior)

    idx_max = np.argmax(lnposterior)

    perc_max = posterior[:idx_max].sum() / posterior.sum()

    maxposterior = posterior[np.argmax(lnposterior)]

    if blind:
        #Output path for blinding file
        blindpath = DIR_MAIN + "/blinding_file.p"
        H0_blinded_array = pos.make_blind(H0_array, blindpath)
        print 'Applying blinding factor. Saving value on ', blindpath
        print "\nBlinded ML percentile: ", perc_max
        print "Blinded H0 ML: ", H0_blinded_array[idx_max], "+", pos.percentile(
            perc_max + 0.34, posterior[:, nevent],
            H0_blinded_array) - H0_blinded_array[
                idx_max], "-", H0_blinded_array[idx_max] - pos.percentile(
                    perc_max - 0.34, posterior[:, nevent], H0_blinded_array)
        print "Blinded H0 Median: ", pos.percentile(0.50, posterior[:, nevent],
                                                    H0_blinded_array)
    else:
        print 'No blinding applied!'
        print "\nML percentile: ", perc_max
        print "H0 ML: ", H0_array[idx_max], "+", pos.percentile(
            perc_max + 0.34, posterior[:, nevent], H0_array
        ) - H0_array[idx_max], "-", H0_array[idx_max] - pos.percentile(
            perc_max - 0.34, posterior[:, nevent], H0_array)
        print "H0 Median: ", pos.percentile(0.50, posterior[:, nevent],
                                            H0_array)
Exemple #4
0
#plt.yscale('log')
plt.xlabel('$H_0$ [km/s/Mpc]', fontsize=20)
plt.ylabel('$p$', fontsize=20)
plt.tight_layout()
plt.legend()
plt.show()
plt.savefig('H0_posterior_GW170817.png')

idx_max = np.argmax(posterior)
perc_max = posterior[:idx_max].sum() / posterior.sum()
maxposterior = posterior[idx_max]

print "No counterpart:"
print "ML percentile: ", perc_max
print "H0 ML: ", H0_array[idx_max], "+", pos.percentile(
    perc_max + 0.34, posterior,
    H0_array) - H0_array[idx_max], "-", H0_array[idx_max] - pos.percentile(
        perc_max - 0.34, posterior, H0_array)
print "H0 Median: ", pos.percentile(0.50, posterior, H0_array)

idx_max = np.argmax(posterior_ngc)
perc_max = posterior_ngc[:idx_max].sum() / posterior_ngc.sum()
maxposterior = posterior_ngc[idx_max]

print "Assuming NGC 4993"
print "ML percentile: ", perc_max
#print "H0 ML +-34%: ", H0_array[idx_max], "+", pos.percentile(perc_max+0.34, posterior_ngc, H0_array)- H0_array[idx_max], "-", H0_array[idx_max]-pos.percentile(perc_max-0.34, posterior_ngc, H0_array)

print "H0 ML with 16th and 84th percentiles: ", H0_array[idx_max], "+", np.abs(
    pos.percentile(0.84, posterior_ngc, H0_array) -
    H0_array[idx_max]), "-", np.abs(
    lnposterior_bin = pos.lnprob_taud(taud_array[i], z_gal, pb_gal, distmu_gal,
                                      distsigma_gal, distnorm_gal, H0, age_gal,
                                      tau_gal, norm_sfh_gal, taud_min,
                                      taud_max)
    print lnposterior_bin
    lnposterior.append(lnposterior_bin)

posterior = np.exp(lnposterior)
plt.ion()
plt.clf()
plt.plot(taud_array, np.exp(lnposterior))
plt.yscale('log')
plt.xlabel(r'$\tau_d$ [Gyr]', fontsize=20)
plt.ylabel('$p$', fontsize=20)
plt.tight_layout()
plt.show()
plt.savefig('../plots/taud_posterior_GW170814.png')

idx_max = np.argmax(lnposterior)

perc_max = posterior[:idx_max].sum() / posterior.sum()

maxposterior = posterior[np.argmax(lnposterior)]

print "ML percentile: ", perc_max
print "H0 ML: ", taud_array[idx_max], "+", pos.percentile(
    perc_max + 0.34, posterior, taud_array
) - taud_array[idx_max], "-", taud_array[idx_max] - pos.percentile(
    perc_max - 0.34, posterior, taud_array)
print "H0 Median: ", pos.percentile(0.50, posterior, taud_array)