Exemplo n.º 1
0
def gencurves(fname):
    global rh,rns,wt
    chain = np.genfromtxt(fname+'.chain', skip_header=0, skip_footer=1)
    print(chain.shape)
    rh = []
    rns = []
    wt = []
    minchis=1e30
    for i in range(chain.shape[0]):
        x = chain[i,:]
        if x[1] < minchis:
            q = x[3:]
            minchis = x[1]
        if chain[i,0] > 100:
            rp,rn,a,b = chain[i,6],chain[i,7],chain[i,8],chain[i,9]
            if rn < 0:
                v = rp*(np.log(4))**.5
            else:
                rn *= rp
                a *= rp
                b *= rp
                v = Rhalf(rp,rn,a,b)
            rh.append(v/30)
            rns.append(rn/rp)
            w = chain[i,0] - chain[i-1,0]
            w /= chain[-1,0] - 100
            wt.append(w)
    rh = np.array(rh)
    rns = np.array(rns)
    wt = np.array(wt)
    print(np.sum(wt))
    print(q)
    print(minchis,lcurv.chis(q),1-st.chi2.cdf(minchis,pars[1]-pars[0]+1-7))
    lcurv.writecurves(q)
Exemplo n.º 2
0
def gencurves(fname):
    global rh, rns, wt
    chain = np.genfromtxt(fname + '.chain', skip_header=0, skip_footer=1)
    print(chain.shape)
    rh = []
    rns = []
    wt = []
    minchis = 1e30
    for i in range(chain.shape[0]):
        x = chain[i, :]
        if x[1] < minchis:
            q = x[3:]
            minchis = x[1]
        if chain[i, 0] > 100:
            rp, rn, a, b = chain[i, 6], chain[i, 7], chain[i, 8], chain[i, 9]
            if rn < 0:
                v = rp * (np.log(4))**.5
            else:
                rn *= rp
                a *= rp
                b *= rp
                v = Rhalf(rp, rn, a, b)
            rh.append(v / 30)
            rns.append(rn / rp)
            w = chain[i, 0] - chain[i - 1, 0]
            w /= chain[-1, 0] - 100
            wt.append(w)
    rh = np.array(rh)
    rns = np.array(rns)
    wt = np.array(wt)
    print(np.sum(wt))
    print(q)
    print(minchis, lcurv.chis(q),
          1 - st.chi2.cdf(minchis, pars[1] - pars[0] + 1 - 7))
    lcurv.writecurves(q)
Exemplo n.º 3
0

def resid(p):
    nobs, x = lcurv.residuals(p)
    x = x[:nobs]
    return x


lo[0], hi[0] = 750, 850
lo[1], hi[1] = 450, 550
p[0] = 780
p[1] = 480

q = leastsq(resid, p)[0]
"""
rawlnp,ans = metrop.samp(lnprob, lo, hi, 200)

q = 0*p
for k in range(7):
    print(min(ans[:,k]), max(ans[:,k]))
    q[k] = numpy.median(ans[:,k])
print(q)
print('chi^2 = ',lcurv.chis(q))
"""
print(q)
print(lcurv.chis(q))
q = p
p[0] = 700
p[1] = 600
lcurv.writecurves(q)
Exemplo n.º 4
0
pars = [51, 290]
if fname[1] == 'c':
    pars += [1.0, Rp, Rn, a, b]
elif fname[1] == 'g':
    pars += [1.0, sig, -2, 0, 0]
else:
    print('Filename error')
    sys.exit()
pars = np.array(pars)
print(pars)

lcurv.readmap()

errlev = 0.04
lcurv.mockdata(pars, errlev)

chain = np.genfromtxt(fname + '.chain', skip_header=0, skip_footer=1)
print(chain.shape)

minchis = 1e30
for i in range(chain.shape[0]):
    x = chain[i, :]
    if x[1] < minchis:
        q = x[3:]
        minchis = x[1]

print(q)
print(minchis, lcurv.chis(q),
      1 - st.chi2.cdf(minchis, pars[1] - pars[0] + 1 - 7))
lcurv.writecurves(q)
Exemplo n.º 5
0
    nobs,x = lcurv.residuals(p)
    x = x[:nobs] 
    return x

lo[0],hi[0] = 750,850
lo[1],hi[1] = 450,550
p[0] = 780
p[1] = 480

q = leastsq(resid,p)[0]

"""
rawlnp,ans = metrop.samp(lnprob, lo, hi, 200)

q = 0*p
for k in range(7):
    print(min(ans[:,k]), max(ans[:,k]))
    q[k] = numpy.median(ans[:,k])
print(q)
print('chi^2 = ',lcurv.chis(q))
"""
print(q)
print(lcurv.chis(q))
q=p
p[0]=700
p[1]=600
lcurv.writecurves(q)



Exemplo n.º 6
0
	def chisquare(self, Params):
		return lcurv.chis(Params)
Exemplo n.º 7
0
 def chisquare(self, Params):
     return lcurv.chis(Params)