Example #1
0
    bgmin, bg, bgmax = np.percentile(bgchain, [16, 50, 84])
    bymin, by, bymax = np.percentile(bychain, [16, 50, 84])

    # Plot power spectra
    figs_cl = lik.plot_data(sam.p0,
                            d,
                            save_figures=True,
                            save_data=True,
                            prefix=p.get_sampler_prefix(v['name']),
                            get_theory_1h=th1h,
                            get_theory_2h=th2h)

    # Plot likelihood
    figs_ch = lik.plot_chain(sam.chain,
                             save_figure=True,
                             prefix=p.get_sampler_prefix(v['name']))
    print(" Best-fit parameters:")
    pars = []
    for i, nn, in enumerate(sam.parnames):
        CHAIN = sam.chain[:, i]
        vmin, vv, vmax = np.percentile(CHAIN, [16, 50, 84])
        pars.append(vv)
        errmin, errmax = vv - vmin, vmax - vv
        print("  " + nn + " : %.3lE +/- (%.3lE %.3lE)" % (vv, errmax, errmin))
        if nn == 'b_hydro':
            bmeans.append(vv)  # median
            sbmeans[0].append(errmin)  # min errorbar
            sbmeans[1].append(errmax)  # max errorbar
        chain = sam.chain
    pars.append(lik.chi2(sam.p0))
Example #2
0
    # bgchain = np.array([hm_bias(cosmo, 1./(1 + zarr), d.tracers[0][0],
    #                   **(lik.build_kwargs(p0))) for p0 in sam.chain[::100]])
    # bychain = np.array([hm_bias(cosmo, 1./(1 + zarr), d.tracers[1][1],
    #                   **(lik.build_kwargs(p0))) for p0 in sam.chain[::100]])

    # bgmin, bg, bgmax = np.percentile(bgchain, [16, 50, 84])
    # bymin, by, bymax = np.percentile(bychain, [16, 50, 84])

    # Plot power spectra
    figs_cl = lik.plot_data(sam.p0, d, save_figures=True, save_data=True,
                            prefix=p.get_sampler_prefix(v['name']),
                            get_theory_1h=th1h, get_theory_2h=th2h)

    # Plot likelihood
    figs_ch = lik.plot_chain(sam.chain, taus=taus[:,s],
                             pars=None,
                             save_figure=True,
                             prefix=p.get_sampler_prefix(v['name']))
    print(" Best-fit parameters:")
    pars = []
    for i, nn, in enumerate(sam.parnames):
        CHAIN = sam.chain[:, i]
        vmin, vv, vmax = np.percentile(CHAIN, [16, 50, 84])
        pars.append(vv)
        errmin, errmax = vv-vmin, vmax-vv
        print("  " + nn + " : %.3lE +/- (%.3lE %.3lE)" % (vv, errmax, errmin))
        if nn == 'b_hydro':
            bmeans.append(vv)          # median
            sbmeans[0].append(errmin)  # min errorbar
            sbmeans[1].append(errmax) # max errorbar
        chain = sam.chain
    pars.append(lik.chi2(sam.p0))
Example #3
0
    hm_correction = None
for v in p.get('data_vectors'):
    if v['name'] == bin_name:
        d = DataManager(p, v, cosmo)
        z, nz = np.loadtxt(d.tracers[0][0].dndz, unpack=True)
        zmean = np.average(z, weights=nz)
        sigz = np.sqrt(np.sum(nz * (z - zmean)**2) / np.sum(nz))

        # Theory predictor wrapper
        def th(pars):
            return get_theory(p,
                              d,
                              cosmo,
                              return_separated=False,
                              hm_correction=hm_correction,
                              selection=sel,
                              **pars)

        lik = Likelihood(p.get('params'),
                         d.data_vector,
                         d.covar,
                         th,
                         debug=p.get('mcmc')['debug'])
        sam = Sampler(lik.lnprob, lik.p0, lik.p_free_names,
                      p.get_sampler_prefix(v['name']), p.get('mcmc'))
        sam.get_chain()
        figs_ch = lik.plot_chain(sam.chain,
                                 save_figure=True,
                                 prefix='notes/paper/')
plt.show()