Esempio n. 1
0
def get_rec_int_dzdmu(z, X, Y, cov, sigf, lenf):
    print('The start time is: %s' % time.asctime())
    s_time = time.perf_counter()

    gp = rexGP(X, Y, cov, sigf, lenf)

    rec = np.array([gp.integrate_one_over_mu(zi, 0.0) for zi in z])
    sigsq = np.array([gp.Cov_integrate_one_over_mu(zi, zi, 0) for zi in z])

    e_time = time.perf_counter()
    print('Using time %s s' % (e_time - s_time))
    return rec, sigsq
Esempio n. 2
0
def multi_get_integrate_f_pq_x(z, X, Y, cov, sigf, lenf):
    print('The start time is: %s' % time.asctime())
    s_time = time.perf_counter()

    gp = rexGP(X, Y, cov, sigf, lenf)

    Afunc = lambda x: 1.0
    Bfunc = lambda x: 1.0
    bet = 0.0
    alp = -1.0

    n = z.shape[0]

    #~~~~~~~~~~~~~~~~
    cores = cpu_count()
    pool1 = Pool(cores)
    pool2 = Pool(cores)
    p1_list = []
    p2_list = []

    for i in range(n):
        pp = pool1.apply_async(gp.integrate_f_pq_x,
                               args=(Afunc, Bfunc, z[i], 0.0, alp, bet))
        ps = pool2.apply_async(gp.Cov_integrate_f_pq_x,
                               args=(Afunc, Bfunc, z[i], z[i], 0.0, alp, bet))
        p1_list.append(pp)
        p2_list.append(ps)
    #result1 = np.array([pp.get() for pp in p1_list])
    #result2 = np.array([ps.get() for ps in p2_list])

    rec = [pp.get() for pp in p1_list]
    sigsq = p2_list

    pool1.close()
    pool2.close()
    pool1.join()
    pool2.join()

    e_time = time.perf_counter()
    print('Using time %s s' % (e_time - s_time))
    return rec, sigsq
Esempio n. 3
0
def get_integrate_f_pq_x(z, X, Y, cov, sigf, lenf):
    print('The start time is: %s' % time.asctime())
    s_time = time.perf_counter()

    gp = rexGP(X, Y, cov, sigf, lenf)

    Afunc = lambda x: 1.0
    Bfunc = lambda x: 1.0
    bet = 0.0
    alp = -1.0

    rec = np.array(
        [gp.integrate_f_pq_x(Afunc, Bfunc, zi, 0.0, alp, bet) for zi in z])
    sigsq = np.array([
        gp.Cov_integrate_f_pq_x(Afunc, Bfunc, zi, zi, 0.0, alp, bet)
        for zi in z
    ])

    e_time = time.perf_counter()
    print('Using time %s s' % (e_time - s_time))
    return rec, sigsq
Esempio n. 4
0
plt.plot(z, recddfx, '--r')
plt.fill_between(z, recddfx+sigddf, recddfx-sigddf, color='red', alpha=0.5)

plt.plot(d2rec[:,0], d2rec[:,1], ':b')
plt.errorbar(d2rec[:,0], d2rec[:,1], d2rec[:,2], color='blue')

plt.xlabel('z')
plt.ylabel(r'$d2f\sigma_8(z)dz2$')

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# reconst \int_0^x 1/mu(x) dx

sigf, lenf = res.x
gp = rexGP(X,Y,cov,sigf,lenf)

z = np.linspace(0,2,41)

rec_int_dzdmu = np.array([gp.integrate_one_over_mu(zi,0.0) for zi in z])
sig_int_dzdmu = np.array([gp.Cov_integrate_one_over_mu(zi,zi,0) for zi in z])

ff = rec_int_dzdmu
sig = np.sqrt(sig_int_dzdmu)

plt.figure()

plt.plot(z, ff, '--r')
plt.fill_between(z, ff+sig, ff-sig, color='green', alpha=0.5)