Commit 0b11daae authored by Henrot-Versille's avatar Henrot-Versille
Browse files

to make the profile plot for each component bao/spt/...

parent a0278e24
from ROOT import *
from array import array
myfile=open("prof","r")
lines=myfile.readlines()
chi2ForEachComponent=[]
listofcomponents=["jla.out","hlp.out","boss.out","bao1d.out","sptlow.out","spthigh.out","actsouth.out","actequat.out"]
fileForEachComponent=[]
linesForEachComponent=[]
chi2ForEachComponent=[]
finalchi2ForEachComponent=[]
for compo in range(0,len(listofcomponents)):
myfile=open(listofcomponents[compo],"r")
fileForEachComponent.append(myfile)
linesForEachComponent.append(myfile.readlines())
chi2ForEachComponent.append([])
chi2=[]
profiledX=[]
#chi2JLA=[]
#chi2HLP=[]
# read the prof file and create the histograms
chi2min=1e10
Xmin=1e10
nforTGraph=0
for line in lines:
if line != '\n':
split_line=line.split()
# the X you want to profile it's here => index_Of_X
index_Of_X=len(split_line)-5
val_chi2=float(split_line[len(split_line)-4])
keep=float(split_line[len(split_line)-1])
X=float(split_line[index_Of_X])
if keep>1e-5: #keep>0.00001 and keep< 100:
chi2.append(val_chi2)
profiledX.append(X)
nforTGraph+=1
#print X,keep
for compo in range(0,len(listofcomponents)):
#print 'compo',compo
for line2 in linesForEachComponent[compo]:
split_line2=line2.split()
ssplit=split_line[0]
ssplit2=split_line2[0]
if ssplit[:-7]==ssplit2[:-5]:
resplit=split_line2[len(split_line2)-1]
rr=resplit.split("=")
chi2temp=float(rr[1])
chi2ForEachComponent[compo].append(chi2temp)
if val_chi2<chi2min:
chi2min=val_chi2
Xmin=X
myfile.close()
print chi2
finalprofiledX=[]
finalchi2=[]
for index in range(0,len(profiledX)):
lookup=0
for testindex in range(0,len(finalprofiledX)):
if profiledX[index]==finalprofiledX[testindex]:
lookup=1
if chi2[index]<finalchi2[testindex]:
finalchi2[testindex]=chi2[index]
for compo in range(0,len(listofcomponents)):
finalchi2ForEachComponent[compo][testindex]=chi2ForEachComponent[compo][index]
if lookup==0 :
finalprofiledX.append(profiledX[index])
finalchi2.append(chi2[index])
for compo in range(0,len(listofcomponents)):
finalchi2ForEachComponent.append([])
finalchi2ForEachComponent[compo].append(chi2ForEachComponent[compo][index])
fileout=TFile("histoProfile.root","recreate")
tempx=array("f",finalprofiledX)
tempy=array("f",finalchi2)
for compo in range(0,len(listofcomponents)):
tempz=array("f",finalchi2ForEachComponent[compo])
profile=TGraph(len(finalprofiledX),tempx,tempz)
profname=listofcomponents[compo].split(".")
profile.SetTitle(profname[0])
profile.SetMarkerStyle(20)
profile.Write(profname[0])
profile.SetMarkerStyle(20)
profile.Write()
fileout.Write()
grep Profile */*.o* > prof
grep "JLA.par:" */*.o* > jla.out
grep "lowl_SMW_70_dx11d_2014_10_03_v5c_Ap.clik: chi2" */*.o* > lowl.out
grep "HiLLiPOP:DX11dHM_superExt_CO_TT.lal: chi2" */*.o* > hlp.out
grep "SPT_low.par: chi2" */*.o* > sptlow.out
grep "SPT_high.par: chi2" */*.o* > spthigh.out
grep "ACT_south.par: chi2" */*.o* > actsouth.out
grep "ACT_equat.par: chi2" */*.o* > actequat.out
grep "BAO1D_new.par: chi2" */*.o* > bao1d.out
grep "Boss_anderson_dr11.par: chi2" */*.o* > boss.out
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment