Example #1
0
 def eval_s(self, sensor_value):
     h = self.T / (self.Nx - 1)
     sensor_value = sensor_value.reshape((self.M, self.Nx))
     tmp = 1 / sensor_value  # exp(-b)
     v1 = trapz(tmp, h)
     tmp *= self.f * np.linspace(0, self.T, num=self.Nx)
     v2 = trapz(tmp, h)
     C = 1 / v1[:, -1:] * v2[:, -1:]
     v = C * v1 - v2
     return np.mean(v, axis=0)
Example #2
0
 def eval_s_path(self, bases, rv):
     bases = bases.reshape((-1, self.Nx))
     b = np.dot(rv, bases)
     h = self.T / (self.Nx - 1)
     tmp = np.exp(-b)
     v1 = trapz(tmp, h)
     tmp *= self.f * np.linspace(0, self.T, num=self.Nx)
     v2 = trapz(tmp, h)
     C = 1 / v1[-1] * v2[-1]
     v = C * v1 - v2
     return v
Example #3
0
def projectCl(lvec,P,D,dNdz,z,growthFac=None):
    """
    project C_l's given a power spectrum class P (Camb or
    BBKS) and Distance class D together

    arguments:
    lvec: vector of l values
    P: p.pk p.k contains the power spectrum, e.g. pt.Camb instance
    D: frw.Distance instance
    dNdz,z, growthFac: vectors suitable for trapezoid z-integration

    presently it crashes if z=0.0 is included, start from a small z value
    """
    lvec = M.asarray(lvec)
    dNdz2 = M.asarray(dNdz)**2
    z = M.asarray(z)
    da1 = 1./D.rtc(z)/D.h #comoving Da in h^1Mpc

    dNdz2vc = dNdz2/D.vc(z)/D.h**3 # comovin volume in (h^-1Mpc)^3
    #`use growth factor if given
    if growthFac:
        dNdz2vc = dNdz2vc*(growthFac**2)
    lk = M.log(P.k)
    pk = P.pk
    
##     return M.asarray([utils.trapz(utils.splineResample(pk,lk,
##                      M.log(l*da1))*dNdz2vc,z) for l in lvec])
    return M.asarray([utils.trapz(utils.interpolateLin(pk,lk,
                     M.log(l*da1))*dNdz2vc,z) for l in lvec])
Example #4
0
    def runTest(self):
#        from pylab import loglog,show
        z = M.arange(0.0005,0.5,0.0005)
        dNdz = calcdNdz2mass(z)
        dNdz = dNdz/utils.trapz(dNdz,z)
        c = pt.Camb( hubble=70, omega_cdm=0.25,
                  omega_baryon=0.05, w=-1.0,transfer_kmax=500,
                     use_physical='F',do_nonlinear=1)
        c.run()
        dist = frw.Distance(c.cp,zmax=1)
        l = M.arange(10.0,1000,10.0)
        cl = projectCl(l,c,dist,dNdz,z)
#        loglog(l,l**2*cl)
#        show()
        print cl
        return True
Example #5
0
def plotCl(ob=0.05):
    from pylab import loglog,show
    #z = M.arange(0.0005,0.5,0.0005)
    #dNdz = calcdNdz2mass(z)
    tamas = utils.readColumns("simit3n.dndz")
    z = tamas[0]
    dNdz = tamas[1]
    dNdz = dNdz/utils.trapz(dNdz,z)
    c = pt.Camb( hubble=70, omega_cdm=0.3-ob,
              omega_baryon=ob, w=-1.0,transfer_kmax=500,
                 use_physical='F',do_nonlinear=1)
    c.run()
    dist = frw.Distance(c.cp,zmax=1)
    l = M.arange(10.0,1000,1.0)
    cl = projectCl(l,c,dist,dNdz,z)
    loglog(l,l**2*cl)
    show()
Example #6
0
 def eval_s_path(self, bases, rv):
     bases = bases.reshape((-1, self.Nx))
     k = np.dot(rv, bases)
     h = self.T / (self.Nx - 1)
     K = trapz(k, h)
     return self.y0 * np.exp(K)