Esempio n. 1
0
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")
Esempio n. 2
0
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")
Esempio n. 3
0
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)
Esempio n. 4
0
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")
Esempio n. 5
0
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")
Esempio n. 6
0
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)
Esempio n. 7
0
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")
Esempio n. 8
0
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")
Esempio n. 9
0
def plot1():
    print "Comparing: " + flag1 + " and "+ flag2    
    minmax = "min"
    #load temperature means
    data1 = plot_1D.mean('temp_igm','data_'+flag1+'/',redshifts1)
    data2 = plot_1D.mean('temp_igm','data_'+flag2+'/',redshifts2)
    print data1
   
    #load xfrac means
    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(data1),len(data2))
    if minmax=="max":
        length = min(len(data1),len(data2))
    #print redshifts2 
    meantemp = np.zeros(2*length).reshape(length,2)
    meanxfrac = np.zeros(6*length).reshape(length,6)
    if minmax=="max":
        for i in range(len(data1)):
            meantemp[i,0] = data1[i]
            meanxfrac[i,3] = wstars_xfrac[i]
            meanxfrac[i,4] = wstars_xfracHe1[i]
            meanxfrac[i,5] = wstars_xfracHe2[i]

        for i in range(len(data2)):
            meanxfrac[i,0] = wpls_xfrac[i]
            meanxfrac[i,1] = wpls_xfracHe1[i]
            meanxfrac[i,2] = wpls_xfracHe2[i]
            meantemp[i,1] = data2[i]
        #print means[i,1]
    #print redshifts_wstars[i], redshifts_wpls[i]
#        plot_1D.plot_mean(means,"Temperature","Temperature (K)",'compare_'+flag1+'_'+flag2+'/',redshifts1,redshifts1,label1,label2)

    elif minmax=="min":
        for i in range(length):
            meantemp[i,0] = data1[i]
            meantemp[i,1] = data2[i]

            meanxfrac[i,0] = wpls_xfrac[i]
            meanxfrac[i,1] = wpls_xfracHe1[i]
            meanxfrac[i,2] = wpls_xfracHe2[i]
            meanxfrac[i,3] = wstars_xfrac[i]
            meanxfrac[i,4] = wstars_xfracHe1[i]
            meanxfrac[i,5] = wstars_xfracHe2[i]
    meanxfrac[0,5]=meanxfrac[0,4]
    meanxfrac[0,2]=meanxfrac[0,1]
   
    #print len(redshifts2), len(meantemp[:,1])
    print meantemp[:,1]
    print meantemp[:,0]


    T0=2.725
    Tcmb = np.zeros(len(redshifts1))
    for z in range(len(redshifts1)):
        Tcmb[z] = T0*(1.0+redshifts1[z])

    size=26
    lw = 2.5

    #print np.log10(meanxfrac[:,5])
    f, (ax1, ax2) = plt.subplots(2, figsize=(14,14),sharex=True)
    #ax1.set_xlim(redshifts2[0],redshifts2[len(redshifts2)-1])
    ax1.plot(redshifts2[0:length],np.log10(meanxfrac[:,0]),color="Red",label="HII",linewidth=lw)
    ax1.plot(redshifts2[0:length],np.log10(meanxfrac[:,1]),color="Red",label="HeII",linewidth=lw,linestyle='--')
    ax1.plot(redshifts2[0:length],np.log10(meanxfrac[:,2]),color="Red",label="HeIII",linewidth=lw,linestyle=':')
    ax1.plot(redshifts1[0:length],np.log10(meanxfrac[:,3]),color="Blue",label="HII",linewidth=lw)
    ax1.plot(redshifts1[0:length],np.log10(meanxfrac[:,4]),color="Blue",label="HeII",linewidth=lw,linestyle='--')
    ax1.plot(redshifts1[0:length],np.log10(meanxfrac[:,5]),color="Blue",label="HeIII",linewidth=lw,linestyle=':')
    ax1.set_ylabel(r'Ionised Fraction',size=size)
    ax1.set_ylim(-13.5,0)
    
    ax2.set_ylim(0,800)
    ax2.plot(redshifts1,Tcmb,label='$T_{cmb}$',color='black',linestyle='--',linewidth=lw)
    ax2.plot(redshifts1[0:length],meantemp[:,0],color='Blue',label=label1,linewidth=lw)
    ax2.plot(redshifts2[0:length],meantemp[:,1],color='Red',label=label2,linewidth=lw)
    ax2.set_ylabel("Temperature [K]",size=size)
    ax2.set_xlabel("Redshifts",size=size)
    #ax2.set_ylim(-250,80)

    ax1.tick_params(axis='both', which='major', labelsize=numberfontsize, width = tickwidth, length = 11, direction='in',pad=14.0,top='off',right='off')
    ax1.tick_params(axis='both', which='minor', labelsize=numberfontsize, width = tickwidth, length = 5.5, direction='in',pad=14.0,top='off',right='off')
    ax2.tick_params(axis='both', which='major', width = tickwidth, length = 11,direction='in',top='off',right='off')
    ax2.tick_params(axis='both', which='minor', width = tickwidth, length = 5.5,direction='in',top='off',right='off')


   # lg1 = ax1.legend(bbox_to_anchor=(0.04, 0.65), loc=2, borderaxespad=0.,prop={'size':size})
   # lg1.draw_frame(False)
    lg = ax2.legend(bbox_to_anchor=(0.04, 0.8), loc=2, borderaxespad=0.,prop={'size':size})
    lg.draw_frame(False)

    plt.gcf().subplots_adjust(left=0.2,bottom=0.15)
    #plt.tight_layout()
    f.subplots_adjust(hspace=0)


#    fig = plt.figure(figsize=(12,10))
#    ax = fig.add_subplot(111)
#    ax.plot(redshifts2,meantemp[:,0],color='Blue',label=label1,linewidth=lw)
#    ax.plot(redshifts2,meantemp[:,1],color='Red',label=label2,linewidth=lw)
#    ax.plot(redshifts1,Tcmb,label='$T_{cmb}$',color='black',linestyle='--',linewidth=lw)
#    ax.set_ylabel("Temperature [K]",fontsize=size)
#    ax.set_xlabel("Redshift",fontsize=size)
#    ax.xaxis.set_tick_params(labelsize=size)
#    ax.yaxis.set_tick_params(labelsize=size)
    #lg = plt.legend(bbox_to_anchor=(0.55, 0.97), loc=2,prop={'size':size-1})
    #lg.draw_frame(False)
    plt.xlim(redshifts2[0],redshifts1[len(redshifts1)-1])
  #  ax.text(22.7,1100,"(b)",fontsize=size)
#
#    rect = [0.15,0.2,0.55,0.55]
#    ax1 = add_subplot_axes(ax,rect)
#    ax1.set_ylabel("log$_{10}$(xfrac)",fontsize=size-2)
##    ax1.set_xlabel("z",fontsize=size-2)
#    ax1.xaxis.set_tick_params(labelsize=size-2)
#    ax1.yaxis.set_tick_params(labelsize=size-2)  
#    ax1.plot(redshifts2,np.log10(meanxfrac[:,0]),color="Red",label="HII",linewidth=lw)
#    ax1.plot(redshifts2,np.log10(meanxfrac[:,1]),color="Red",label="HeII",linewidth=lw,linestyle='--')
#    ax1.plot(redshifts2,np.log10(meanxfrac[:,2]),color="Red",label="HeIII",linewidth=lw,linestyle=':')
#    ax1.plot(redshifts2,np.log10(meanxfrac[:,3]),color="Blue",label="HII",linewidth=lw)
#    ax1.plot(redshifts2,np.log10(meanxfrac[:,4]),color="Blue",label="HeII",linewidth=lw,linestyle='--')
#    ax1.plot(redshifts2,np.log10(meanxfrac[:,5]),color="Blue",label="HeIII",linewidth=lw,linestyle=':')
    ax1.text(22,-2,"(a)",fontsize=size-2)
    ax2.text(22,700,"(b)",fontsize=size-2)
#    lg =plt.legend(loc=4,ncol=2,prop={'size':size-3})
#    lg.draw_frame(False)
#    plt.ylim(-16,0)
#    plt.xlim(redshifts2[0],redshifts2[len(redshifts2)-1])
 


    print "saving as paperplots/plot1.png"
    #plt.tight_layout()
    plt.savefig("paperplots/plot1.png")
Esempio n. 10
0
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