Esempio n. 1
0
def fit2pttoy(xn_bstraps):

	xnfunc = lambda p,x: p[0]*(np.exp(-x*p[1])+np.exp(-(T-x)*p[1]))

	xn_bstraps_mean = np.mean(xn_bstraps,axis=0)

	_effmass, effmass_error, effmass_nans = a.effmass(xn_bstraps)

	_effmasswerr = np.zeros((2,_effmass.shape[0]))
	_effmasswerr[0] = _effmass
	_effmasswerr[1] = effmass_error
	
	tt = []
	for t in range(0,T/2+1):
		tt.append(t)
	
	tt = np.asarray(tt)
	
	xnup = T/2+1
	for xnlo in range(0,T/2-3):
		result,chi2,pvalue = fits(xnfunc,tt[xnlo:xnup],xn_bstraps[:,xnlo:xnup],[xn_bstraps_mean[xnlo]/(np.exp(-_effmass[xnlo]*xnlo)+np.exp(-(T-xnlo)*_effmass[xnlo])),_effmass[xnlo]])
		print "xnlo "+str(xnlo)
		for b in range(0,numBootstraps):
			xn_result[xnlo][b][0] = result[b][0]
			xn_result[xnlo][b][1] = result[b][1]
			xn_result[xnlo][b][2] = chi2[b]
			xn_result[xnlo][b][3] = pvalue[b]
	
	xn_result_mean = np.mean(xn_result,axis=1)
	xn_result_std = np.std(xn_result,axis=1)
	
	xn_hist = np.zeros((numBootstraps,T/2-3,3))
	
	for i in range(0,T/2-3):
		W = (1-2*abs(xn_result_mean[i][3]-0.5))**2/(xn_result_std[i][1]**2)
		for b in range(0,numBootstraps):
			xn_hist[b][i][0] = xn_result[i][b][1]
			xn_hist[b][i][1] = xn_result[i][b][0]
			xn_hist[b][i][2] = W
		print str(xn_result[i][0][1])+" "+str(W)
	
	cut = 0.158655254
	xnmedian, index = histpercentile2_index(xn_hist,0.5)
	xnlow = histpercentile2(xn_hist,cut)
	xnup = histpercentile2(xn_hist,1-cut)
	x_bstraps = a.boot(x,1500)

	np.save(os.path.join(destdir,correlator+"_x_bstraps50.npy"),x_bstraps)
else:
	x_bstraps = np.load(os.path.join(destdir,correlator+"_x_bstraps50.npy"))

if correlator == "corr1":
	for t in range(0,48):
		x_bstraps[:,t] = -x_bstraps[:,t]

if correlator == "corr2":
	for t in range(24,48):
		x_bstraps[:,t] = -x_bstraps[:,t]


_effmass, effmass_error, effmass_nans = a.effmass(x_bstraps)

_effmass2, effmass_error2, effmass_nans2 = a.effmass2(x_bstraps)

_effmasswerr = np.zeros((2,_effmass.shape[0]))
_effmasswerr[0] = _effmass
_effmasswerr[1] = effmass_error
	
np.save(os.path.join(destdir,correlator+"_effmass_50.npy"),_effmasswerr)

a.nsettofile2(x_bstraps[0],np.std(x_bstraps,axis=0),os.path.join(destdir,correlator+"_mean_50"))
a.nsettofile2(_effmass,effmass_error,os.path.join(destdir,correlator+"_effmass_50"))

# plot corr log

path = os.path.join(destdir,correlator+"_log_50.pdf")