示例#1
0
	def __init__(self, NP, means, mins, maxs, sds, outfile, errlev=0.1, goodchi2=350.0):
		"""
		Instantiates the class by synthetically generating data.
		"""
		MCMC.__init__(self, TargetAcceptedPoints=1000, NumberOfParams=NP, Mins=mins, Maxs=maxs, SDs=sds, \
			write2file=True, outputfilename=outfile, alpha=0.1, debug=False,\
                                EstimateCovariance=True, CovNum=100, goodchi2=goodchi2)
		lcurv.readmap()
		lcurv.mockdata(means,errlev)
示例#2
0
def mockdata():
    global pars
    lcurv.readmap()
    Rp = 39.4
    Rn, a, b = 0.4, 0, 0.3
    pars = [51, 290, 1.0, Rp, Rn, a, b]
    pars = np.array(pars)
    print(pars)
    errlev = 0.04
    lcurv.mockdata(pars, errlev)
示例#3
0
def mockdata():
    global pars
    lcurv.readmap()
    Rp = 39.4              # scaled by 30
    Rn,a,b = 0.4, 0, 0.3
    print('r_half = ',Rhalf(1,Rn,a,b)*Rp/30)
    pars = [ 51, 290, 1.0, Rp,  Rn, a, b ]
    pars = np.array(pars)
    print(pars)
    errlev = 0.04
    lcurv.mockdata(pars,errlev)
示例#4
0
def mockdata():
    global pars
    lcurv.readmap()
    Rp = 39.4  # scaled by 30
    Rn, a, b = 0.4, 0, 0.3
    print('r_half = ', Rhalf(1, Rn, a, b) * Rp / 30)
    pars = [51, 290, 1.0, Rp, Rn, a, b]
    pars = np.array(pars)
    print(pars)
    errlev = 0.04
    lcurv.mockdata(pars, errlev)
示例#5
0
    def __init__(self,
                 NP,
                 means,
                 mins,
                 maxs,
                 sds,
                 outfile,
                 errlev=0.1,
                 goodchi2=350.0):
        """
		Instantiates the class by synthetically generating data.
		"""
        MCMC.__init__(self, TargetAcceptedPoints=1000, NumberOfParams=NP, Mins=mins, Maxs=maxs, SDs=sds, \
         write2file=True, outputfilename=outfile, alpha=0.1, debug=False,\
                                      EstimateCovariance=True, CovNum=100, goodchi2=goodchi2)
        lcurv.readmap()
        lcurv.mockdata(means, errlev)
示例#6
0
hi = []
for f in (t1, t2, norm, rp, rn, a, b):
    p.append(f[1])
    lo.append(f[0])
    hi.append(f[2])
p = numpy.array(p)
lo = numpy.array(lo)
hi = numpy.array(hi)

errlev = 0.05

print(lo)
print(p)
print(hi)

lcurv.mockdata(p, errlev)


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]
"""
示例#7
0
Rn, a, b = 0.4, 0, 0.3
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)
示例#8
0
文件: main.py 项目: psaha/microlens
hi = []
for f in (t1,t2,norm,rp,rn,a,b):
    p.append(f[1])
    lo.append(f[0])
    hi.append(f[2])
p = numpy.array(p)
lo = numpy.array(lo)
hi = numpy.array(hi)

errlev = 0.05

print(lo)
print(p)
print(hi)

lcurv.mockdata(p,errlev)

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)