コード例 #1
0
 def __init__(self, name, z, DV, DVErr, fidtheory, maxchi2=1e30):
     BaseLikelihood.__init__(self, name)
     self.z = z
     rd = fidtheory.rd
     DV /= rd
     DVErr /= rd
     self.maxchi2 = maxchi2
     print(name, "measurement in ", fidtheory.rd_approx, ":", DV, "+-",
           DVErr)
     self.setData(DV, DVErr)
コード例 #2
0
    def __init__(self,
                 name,
                 filename,
                 chi2col,
                 fid_theory,
                 z,
                 skiprows=0,
                 aperp_col=0,
                 apar_col=1):
        BaseLikelihood.__init__(self, name)
        print()
        print("Loading ", filename)
        data = sp.loadtxt(filename, skiprows=skiprows)
        # first let's autolearn the binning
        aperp = set()
        aparl = set()
        for line in data:
            aperp.add(line[aperp_col])
            aparl.add(line[apar_col])
        aperp = sorted(list(aperp))
        aparl = sorted(list(aparl))
        logltab = sp.zeros((len(aperp), len(aparl)))
        print("Aperp min,max,step,N:", aperp[0], aperp[-1],
              aperp[1] - aperp[0], len(aperp))
        print("Aparl min,max,step,N:", aparl[0], aparl[-1],
              aparl[1] - aparl[0], len(aparl))

        self.aperp = sp.array(aperp)
        self.aparl = sp.array(aparl)

        # now fill in the table
        for line in data:
            ii = aperp.index(line[aperp_col])
            jj = aparl.index(line[apar_col])
            if chi2col > 0:
                chi2 = line[chi2col]
                logltab[ii, jj] = -chi2 / 2.0
            else:
                # col is probability, add 1e-50 to avoid taking log of zero.
                logltab[ii, jj] = sp.log(line[chi2col * -1] + 1e-50)

        logltab = logltab - logltab.max()
        self.loglint = RectBivariateSpline(self.aperp,
                                           self.aparl,
                                           logltab,
                                           kx=1,
                                           ky=1)
        print("Loading done")
        print("rd = ", fid_theory.rd, " Mpc")
        self.fidDaOverrd = fid_theory.DaOverrd(z)
        self.fidHIOverrd = fid_theory.HIOverrd(z)
        print("Fiducials at z=", z, ":", self.fidDaOverrd, self.fidHIOverrd)
        self.z = z
コード例 #3
0
ファイル: SimpleCMB.py プロジェクト: ja-vazquez/april
 def __init__(self, name, mean, cov, kill_Da=False, kill_rd=False):
     print("Initializing CMB likelihood:", name)
     cov = sp.array(cov)
     if kill_Da:
         cov[2, :] = 0.0
         cov[:, 2] = 0.0
         cov[2, 2] = 1e10
         name += "_noDa"
     if kill_rd:
         cov[0:2, 0:2] = 0.0
         cov[0, 0] = 1e10
         cov[1, 1] = 1e10
         name += "_noRd"
     BaseLikelihood.__init__(self, name)
     self.mean = sp.array(mean)
     self.cov  = cov
     self.icov = la.inv(cov)
コード例 #4
0
    def __init__(self, name, filename, fid_theory, z):
        BaseLikelihood.__init__(self, name)
        print()
        print("Loading ", filename)
        data = sp.loadtxt(filename)
        self.chi2i = interp1d(data[:, 0], data[:, 1])
        self.fidDVOverrd = fid_theory.DVOverrd(z)

        # find minimum
        alphamin = minimize(self.chi2i, 1.0, bounds=[
                            [0.9, 1.1]], method='SLSQP').x[0]
        rms  = quad(lambda x: sp.exp(-self.chi2i(alphamin+x)/2)*x*x, -0.1, 0.1)[0]
        rms /= quad(lambda x: sp.exp(-self.chi2i(alphamin+x)/2), -0.1, 0.1)[0]
        DVf  = self.fidDVOverrd*fid_theory.rd
        print(name, "measurement in", fid_theory.rd_approx,
              " : DV=", DVf*alphamin, "+-", sp.sqrt(rms)*DVf)
        print("with rd=", fid_theory.rd, "DV_fid=", DVf, "alphamin=", alphamin)
        self.z = z
コード例 #5
0
 def __init__(self):
     BaseLikelihood.__init__(self, "testlike")
     self.x = 0
     self.y = 0
コード例 #6
0
 def setTheory(self, theory):
     BaseLikelihood.setTheory(self, theory)
     for l in self.llist_:
         l.setTheory(theory)
         assert (self.theory_ is l.theory_)
コード例 #7
0
 def __init__(self, llist=[]):
     BaseLikelihood.__init__(self, "Composite")
     self.llist_ = llist
コード例 #8
0
ファイル: samplertest.py プロジェクト: gaby7646/april
 def __init__(self):
     BaseLikelihood.__init__(self,"testlike")
     self.x=0
     self.y=0