def compare_mean_xfrac(): wstars_xfrac = plot_1D.mean('xfrac','data_'+flag1+'/',redshifts1) wpls_xfrac = plot_1D.mean('xfrac','data_'+flag2+'/',redshifts2) wstars_xfracHe1 = plot_1D.mean('xfracHe1','data_'+flag1+'/',redshifts1) wpls_xfracHe1 = plot_1D.mean('xfracHe1','data_'+flag2+'/',redshifts2) wstars_xfracHe2 = plot_1D.mean('xfracHe2','data_'+flag1+'/',redshifts1) wpls_xfracHe2 = plot_1D.mean('xfracHe2','data_'+flag2+'/',redshifts2) length = min(len(wstars_xfrac),len(wpls_xfrac)) means = np.zeros(6*length).reshape(length,6) for i in range(length): if i<len(wpls_xfrac): means[i,0] = wpls_xfrac[i] means[i,1] = wpls_xfracHe1[i] means[i,2] = wpls_xfracHe2[i] means[i,3] = wstars_xfrac[i] means[i,4] = wstars_xfracHe1[i] means[i,5] = wstars_xfracHe2[i] means[0,2] = means[1,2] means[0,5] = means[1,5] #print means[:,2], means[:,5] #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"xfrac","log$_{10}$ (Ionised Fraction)",'compare_'+flag1+'_'+flag2+'/',redshifts1,redshifts2,"Stellar & X-ray binaries","Stellar only")
def compare_mean_temp(): minmax = "min" data1 = plot_1D.mean('temp','tests/data_10/',redshifts) data2 = plot_1D.mean('temp','tests/data_200/',redshifts) # data3 = plot_1D.mean('temp','tests/data_121/',redshifts) # data4 = plot_1D.mean('temp','tests/data_201/',redshifts) length = max(len(data1),len(data2)) means = np.zeros(2*length).reshape(length,2) for i in range(len(data1)): means[i,0] = data1[i] means[i,1] = data2[i] # means[i,2] = data3[i] # means[i,3] = data4[i] print means[:,0] print means[:,1] # print data3 # print data4 #print means[i,1] #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"Temperature","Temperature (K)",'tests/',redshifts,redshifts,"11","501")
def compare_rms(): rmsdata=numpy.zeros(len(wpls)**2).reshape(len(wpls),len(wpls)) for i in range(redshifts_wstars): fr_wstars=np.loadtxt("../generate_data/data_wstars/powerSpectraFrequencies_dbt_"+str('%.3f' % redshifts[i])) data_wstars = np.loadtxt("../generate_data/data_wstars/powerSpectra_"+str('%.3f' % redshifts[i]))*1.0e-3 rmsdata[0,i]=sci.simps(data_wstars,fr_wstars)/1.0e-3 fr_wpls=np.loadtxt("../generate_data/data_wstars/powerSpectraFrequencies_dbt_"+str('%.3f' % redshifts[i])) data_wpls = np.loadtxt("../generate_data/data_wstars/powerSpectra_"+str('%.3f' % redshifts[i]))*1.0e-3 rmsdata[1,i]=sci.simps(data_pls,fr_wpls)/1.0e-3 plot_1D.plot_mean(rmsdata,"rms","rms (mK)",'compare_wstars_wpls/',redshifts_wpls,redshifts_wpls,"Stellar only","Stellar and X-ray") wstars_temp = plot_1D.mean('temp','data_wstars/',redshifts_wstars) wpls_temp = plot_1D.mean('temp','data_wpls/',redshifts_wpls) length = min(len(wstars_temp),len(wpls_temp)) print length means = np.zeros(2*length).reshape(length,2) for i in range(length): means[i,0] = wstars_temp[i] for i in range(length): means[i,1] = wpls_temp[i] #print means[i,1] #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"Temperature","Temperature (K)",'compare_wstars_wpls/',redshifts_wpls,redshifts_wpls,"Stellar only","Stellar and X-ray")
def compare_mean_dbt(): wstars_temp = plot_1D.mean('dbt','data_'+flag1+'/',redshifts1) wpls_temp = plot_1D.mean('dbt','data_'+flag2+'/',redshifts2) print wstars_temp print wpls_temp print "--------------" length = min(len(wstars_temp),len(wpls_temp))/2 if (length%2!=0): length=length-1 means = np.zeros(2*length).reshape(length,2) redshifts3 = np.zeros(length) redshifts4 = np.zeros(len(wpls_temp)/2) for i in range(length*2): if i%2==0: means[i/2,0] = wstars_temp[i] if (i<len(wpls_temp)): means[i/2,1] = wpls_temp[i] redshifts3[i/2]=redshifts1[i] for i in range(length): redshifts4[i/2]=redshifts2[i] print means[:,1] print means[:,0] print "-----------" #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"dbt","$\delta T_b$",'compare_'+flag1+'_'+flag2+'/',redshifts3,redshifts4,label1,label2)
def compare_rms(): length=min(len(redshifts1),len(redshifts2)) if length%2!=0: length=length-1 rmsdata=np.zeros(length).reshape(length/2,2) redshifts_short=np.zeros((length)/2) for i in range(0,length,2): redshifts_short[i/2]=redshifts2[i] print "opening ../generate_data/data_"+flag1+"/map_dbt_"+str('%.3f' % redshifts1[i])+".bin and ../generate_data/data_"+flag2+"/map_dbt_"+str('%.3f' % redshifts2[i])+".bin" data1=np.load("../generate_data/data_"+flag1+"/map_dbt_"+str('%.3f' % redshifts1[i])+".bin") data2=np.load("../generate_data/data_"+flag2+"/map_dbt_"+str('%.3f' % redshifts2[i])+".bin") mean1=np.mean(data1) mean2=np.mean(data2) # length=len(data) sum=0.0 print "summing..." for x in range(length): for y in range(length): for z in range(length): rmsdata[i/2,0]=rmsdata[i/2,0]+(data1[x,y,z]-mean1)**2 rmsdata[i/2,1]=rmsdata[i/2,1]+(data2[x,y,z]-mean2)**2 rmsdata[i/2,:]=np.sqrt(rmsdata[i/2,:]/(length**3)/2.0) # rmsdata[:,i]=np.sqrt(rmsdata[:,i]/(length**3)/2.0) plot_1D.plot_mean(rmsdata,"rms_100b","rms (mK)","compare_"+flag1+"_"+flag2+"/",redshifts_short,redshifts_short,label1,label2)
def compare_mean_temp(): wstars_temp = plot_1D.mean('temp','data_wstars/',redshifts_wstars) wpls_temp = plot_1D.mean('temp','data_wpls/',redshifts_wpls) length = min(len(wstars_temp),len(wpls_temp)) means = np.zeros(2*length).reshape(length,2) for i in range(length): means[i,0] = wstars_temp[i] for i in range(length): means[i,1] = wpls_temp[i] #print means[i,1] #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"Temperature","Temperature (K)",'compare_wstars_wpls/',redshifts_wpls,"Stellar only","Stellar and X-ray")
def compare_mean_dbt(): wstars_temp = plot_1D.mean('dbt','data_wstars/',redshifts_wstars) wpls_temp = plot_1D.mean('dbt','data_wpls/',redshifts_wpls) length = max(len(wstars_temp),len(wpls_temp))/2 means = np.zeros(2*length).reshape(length,2) redshifts2 = np.zeros(length) for i in range(length*2): if i%2==0: means[i/2,0] = wstars_temp[i] if (i<len(wpls_temp)): means[i/2,1] = wpls_temp[i] redshifts2[i/2]=redshifts_wstars[i] #print means[i,1] #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"dbt","$\delta T_b$",'compare_wstars_wpls/',redshifts2,"Stellar only","Stellar and X-ray")
def compare_mean_temp(): minmax = "min" # print redshifts1 # print '-----------------------------' # print redshifts2 data1 = plot_1D.mean('temp','data_'+flag1+'/',redshifts1) data2 = plot_1D.mean('temp','data_'+flag2+'/',redshifts2) #print redshifts1 #print '-----------------------------' #print redshifts2 if minmax=="max": length = max(len(data1),len(data2)) means = np.zeros(2*length).reshape(length,2) for i in range(len(data1)): means[i,0] = data1[i] for i in range(len(data2)): means[i,1] = data2[i] print redshifts1 print '-----------------------------' print redshifts2 #print means[i,1] #print redshifts_wstars[i], redshifts_wpls[i] print np.shape(means) # print len(redshifts1), len(redshifts2) # print redshifts2 # print len(redshifts2) # plot_1D.plot_mean(means,"Temperature","Temperature (K)",'compare_'+flag1+'_'+flag2+'/',redshifts2,redshifts2,label1,label2) elif minmax=="min": length = min(len(data1),len(data2)) means = np.zeros(2*length).reshape(length,2) for i in range(length): means[i,0] = data1[i] for i in range(length): means[i,1] = data2[i] print means[i,1] print means[i,0] #prin redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"Temperature","Temperature (K)",'compare_'+flag1+'_'+flag2+'/',redshifts2,redshifts2,label1,label2)
def compare_mean_test(): wstars_temp = plot_1D.mean('temp','data_wstars/',redshifts_wstars) wpls_temp = plot_1D.mean('temp','data_wpls/',redshifts_wpls) length = max(len(wstars_temp),len(wpls_temp)) wstars_tcmb = 2.725*(np.ones(len(redshifts_wstars))+redshifts_wstars) wpls_tcmb = 2.725*(np.ones(len(redshifts_wpls))+redshifts_wpls) wstars_test = (wstars_temp-wstars_tcmb)/wstars_temp wpls_test = (wpls_temp-wpls_tcmb)/wpls_temp means = np.zeros(2*length).reshape(length,2) for i in range(length): means[i,0] = wstars_test[i] for i in range(length): if (i<len(wpls_temp)): means[i,1] = wpls_test[i] #print means[i,1] #print redshifts_wstars[i], redshifts_wpls[i] plot_1D.plot_mean(means,"Test","$(T_S - T_{CMB}) / T_S$",'compare_wstars_wpls/',redshifts_wstars,redshifts_wpls,"Stellar only","Stellar and X-ray")
def compare_rms(): length=min(len(redshifts1),len(redshifts2)) if length%2!=0: length=length-1 #rmsdata=np.zeros(length).reshape(length/2,2) rmsdata=np.zeros((length/2,2))#length**2).reshape(length,2) #redshifts_short=np.zeros((length)/2) redshifts_short=np.zeros(length/2) # for i in range(0,length,2): # redshifts_short[i/2]=redshifts2[i] # print "opening ../generate_data/data_"+flag1+"/map_dbt_"+str('%.3f' % redshifts1[i])+".bin and ../generate_data/data_"+flag2+"/map_dbt_"+str('%.3f' % redshifts2[i])+".bin" data1=IO.readoned("rms",path="../generate_data/data_"+flag1+"/")#"../generate_data/data_"+flag1+"/rms.dat") data2=IO.readoned("rms",path="../generate_data/data_"+flag2+"/")#"../generate_data/data_"+flag2+"/rms.da") for i in range(0,length/2): print i rmsdata[i,0]=data1[i*2] rmsdata[i,1]=data2[i*2] # for i in range(length/2): redshifts_short[i] = redshifts1[i*2] # mean1=np.mean(data1) # mean2=np.mean(data2) # # length=len(data) # sum=0.0 # print "summing..." # for x in range(length): # for y in range(length): # for z in range(length): # rmsdata[i/2,0]=rmsdata[i/2,0]+(data1[x,y,z]-mean1)**2 # rmsdata[i/2,1]=rmsdata[i/2,1]+(data2[x,y,z]-mean2)**2 # rmsdata[i/2,:]=np.sqrt(rmsdata[i/2,:]/(length**3)/2.0) # rmsdata[:,i]=np.sqrt(rmsdata[:,i]/(length**3)/2.0) print rmsdata[:,0] print '-----------------------------------' print rmsdata[:,1] plot_1D.plot_mean(rmsdata,"rms_100b","rms (mK)","compare_"+flag1+"_"+flag2+"/",redshifts_short,redshifts_short,label1,label2)
plot_2D.plottemp() plot_2D.plotxfrac('') plot_2D.plotxfrac('He1') plot_2D.plotxfrac('He2') plot_2D.equation_of_state() ##these need information from generate_data so leave until last plot_2D.plotdbt() plot_2D.plot_smoothed_dbt() # plot_2D.lightcone_temp() plot_2D.lightcone_xfrac() plot_2D.lightcone_xfrac(rsd='rsd') plot_2D.lightcone_temp('rsd') # plot_1D.plot_mean(plot_1D.mean("temp"),"Tempererature","Temperature (K)") means = np.zeros(len(redshifts)*3).reshape(len(redshifts),3) means[:,0] = plot_1D.mean('xfrac') means[:,1] = plot_1D.mean('xfracHe1') means[:,2] = plot_1D.mean('xfracHe2') plot_1D.plot_mean(np.log10(means),"x-frac","Log (Ionised Fraction)") ## meantemp=plot_1D.mean('temp') plot_1D.plot_mean(meantemp,"Temper","Temperature (K)") #meantemp_igm=plot_1D.mean('temp_igm') #plot_1D.plot_mean(meantemp_igm,"igm_temper","Temperature (K)") ###CMBtemp=2.725*(np.ones(len(redshifts))+redshifts) ###meantest=(meantemp-CMBtemp)/meantemp