Ejemplo n.º 1
0
def sigma(k,Pk,R):
    yinit = np.array([0.0], dtype=np.float64)
    eps   = 1e-9  #change this for higher/lower accuracy
    h1    = 1e-12
    hmin  = 0.0
    
    W   = 3.0*(np.sin(k*R) - k*R*np.cos(k*R))/(k*R)**3
    Pk1 = Pk*W**2*k**2/(2.0*pi**2)
    
    return np.sqrt(IL.odeint(yinit, k[0], k[-1], eps,
                             h1, hmin, np.log10(k), np.log10(Pk1),
                             'sigma', verbose=False)[0])
def sigma(k,Pk,R):
    yinit = np.array([0.0], dtype=np.float64)
    eps   = 1e-13  #change this for higher/lower accuracy
    h1    = 1e-12
    hmin  = 0.0
    
    W   = 3.0*(np.sin(k*R) - k*R*np.cos(k*R))/(k*R)**3
    Pk1 = Pk*W**2*k**2/(2.0*pi**2)
    
    return np.sqrt(IL.odeint(yinit, k[0], k[-1], eps,
                             h1, hmin, np.log10(k), Pk1,
                             'sigma', verbose=False)[0])
def analytic_Fisher(parameter, z, V, kmax, root_derv):

    num_params = len(parameter)

    # define the Fisher matrix
    Fisher = np.zeros((num_params, num_params), dtype=np.float64)

    # compute the value of kmin
    kmin = 2.0 * np.pi / V**(1.0 / 3.0)

    # check that all ks are equally spaced in log
    for i in xrange(num_params):
        k, deriv = np.loadtxt('%s/derivative_%s_z=%.1f.txt' %
                              (root_derv, parameter[i], z),
                              unpack=True)
        dk = np.log10(k[1:]) - np.log10(k[:-1])
        if not (np.allclose(dk, dk[0])):
            raise Exception('k-values not log distributed')

    # compute sub-Fisher matrix
    for i in xrange(num_params):
        for j in xrange(i, num_params):
            #if i==5:
            #    k1, deriv1 = np.loadtxt('%s/log_derivative_%s_cb_z=%.1f.txt'%(root_derv,parameter[i],z), unpack=True)
            #else:
            k1, deriv1 = np.loadtxt('%s/log_derivative_%s_z=%.1f.txt' %
                                    (root_derv, parameter[i], z),
                                    unpack=True)
            #if j==5:
            #    k2, deriv2 = np.loadtxt('%s/log_derivative_%s_cb_z=%.1f.txt'%(root_derv,parameter[j],z), unpack=True)
            #else:
            k2, deriv2 = np.loadtxt('%s/log_derivative_%s_z=%.1f.txt' %
                                    (root_derv, parameter[j], z),
                                    unpack=True)

            if np.any(k1 != k2): raise Exception('k-values are different!')

            yinit = np.zeros(1, dtype=np.float64)
            eps = 1e-16
            h1 = 1e-18
            hmin = 0.0
            function = 'log'

            I = IL.odeint(yinit,
                          kmin,
                          kmax,
                          eps,
                          h1,
                          hmin,
                          np.log10(k1),
                          k**2 * deriv1 * deriv2,
                          function,
                          verbose=False)[0]

            Fisher[i, j] = I
            if i != j: Fisher[j, i] = Fisher[i, j]

    # add prefactors to subFisher matrix
    Fisher = Fisher * V / (2.0 * np.pi)**2

    return Fisher
Ejemplo n.º 4
0
    np.savetxt(f_out, np.transpose([M, MF]))

M = np.ascontiguousarray(M)
MF = np.ascontiguousarray(MF)

M_HI = M0 * (M / Mmin)**alpha * np.exp(-Mmin / M)

A = MF * M_HI**2
B = MF * M_HI

yinit = np.array([0.0], dtype=np.float64)
numerator = IL.odeint(yinit,
                      1e8,
                      M_max,
                      eps,
                      h1,
                      hmin,
                      np.log10(M),
                      np.log10(A),
                      'sigma',
                      verbose=True)[0]

yinit = np.array([0.0], dtype=np.float64)
denominator = IL.odeint(yinit,
                        1e8,
                        M_max,
                        eps,
                        h1,
                        hmin,
                        np.log10(M),
                        np.log10(B),
                        'sigma',
Ejemplo n.º 5
0
#sigma_DLAs = np.zeros(bins+1, dtype=np.float64)
#if z==2:  M0 = 10.22955643 #value of 10^20
#if z==3:  M0 = 9.89018152  #value of 10^20
#for i in xrange(bins+1):
#    sigma_DLAs[i] = sigma_DLAs_func(M[i], M0, N_HI=10**20.0)


# integral value, its limits and precision parameters
eps   = 1e-14 
h1    = 1e-15 
hmin  = 0.0   

# integral method and integrand function
function = 'log'

yinit = np.zeros(1, dtype=np.float64) 
I1 = IL.odeint(yinit, Mmin, Mmax, eps, h1, hmin, np.log10(M), 
               np.log10(MF*sigma_DLAs*b), function, verbose=True)[0]

yinit = np.zeros(1, dtype=np.float64) 
I2 = IL.odeint(yinit, Mmin, Mmax, eps, h1, hmin, np.log10(M), 
               np.log10(MF*sigma_DLAs), function, verbose=True)[0]

print I1
print I2
print 'b_DLAs(z=%d) = %.3f'%(z,I1/I2)