Ejemplo n.º 1
0
def counts_from_config(Config,bigDataDir,version,expName,gridName,mexp_edges,z_edges,lkneeTOverride=None,alphaTOverride=None):
    suffix = ""
    if lkneeTOverride is not None:
        suffix += "_"+str(lkneeTOverride)
    if alphaTOverride is not None:
        suffix += "_"+str(alphaTOverride)
    mgrid,zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+suffix+".pkl",'rb'))
    #mgrid,zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+suffix+".pkl",'rb'),encoding='latin1')
    experimentName = expName
    cosmoDict = dict_from_section(Config,"params")
    constDict = dict_from_section(Config,'constants')
    clusterDict = dict_from_section(Config,'cluster_params')
    clttfile = Config.get("general","clttfile")
    cc = ClusterCosmology(cosmoDict,constDict,clTTFixFile = clttfile)

    beam = list_from_config(Config,experimentName,'beams')
    noise = list_from_config(Config,experimentName,'noises')
    freq = list_from_config(Config,experimentName,'freqs')
    lmax = int(Config.getfloat(experimentName,'lmax'))
    lknee = float(Config.get(experimentName,'lknee').split(',')[0])
    alpha = float(Config.get(experimentName,'alpha').split(',')[0])
    fsky = Config.getfloat(experimentName,'fsky')
    SZProf = SZ_Cluster_Model(cc,clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lknee=lknee,alpha=alpha)

    hmf = Halo_MF(cc,mexp_edges,z_edges)

    hmf.sigN = siggrid.copy()
    Ns = np.multiply(hmf.N_of_z_SZ(fsky,SZProf),np.diff(z_edges).reshape(1,z_edges.size-1))
    return Ns.ravel().sum()
Ejemplo n.º 2
0
Archivo: testV3.py Proyecto: mntw/szar

# HMF

zbin = np.arange(0.,3.0,0.1)
#zbin = np.insert(zbin_temp,0,0.0)
#print zbin

Mexp = np.arange(13.5,15.71,0.01)

start3 = time.time()
SZProf = SZ_Cluster_Model(cc,clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lknee=lknee,alpha=alpha)

HMF = Halo_MF(cc,Mexp,zbin)
dvdz = HMF.dVdz#(zbin)
dndm = HMF.N_of_z_SZ(fsky,SZProf)

sys.exit()
print(("Time for N of z " , time.time() - start3))


# pl = Plotter()
# pl.add(zbin[1:], dndm * dvdz[1:])
# pl.done("output/dndm.png")

print(("Total number of clusters ", np.trapz(dndm ,zbin[:],np.diff(zbin[:]))*fsky))

#np.savetxt('output/dndm_dVdz_1muK_3_0arc.txt',np.transpose([zbin[1:],dndm,dvdz[1:]]))

mfile = "data/S4-7mCMB_all.pkl"
minrange, zinrange, lndM = pickle.load(open(mfile,'rb'))
Ejemplo n.º 3
0
    noise = list_from_config(Config, expName, 'noises')
    freq = list_from_config(Config, expName, 'freqs')
    lknee = list_from_config(Config, expName, 'lknee')[0]
    alpha = list_from_config(Config, expName, 'alpha')[0]
    fsky = Config.getfloat(expName, 'fsky')
    HMF = Halo_MF(cc, mexp_edges, z_edges)
    HMF.sigN = siggrid.copy()

    SZProf = SZ_Cluster_Model(cc,
                              clusterDict,
                              rms_noises=noise,
                              fwhms=beam,
                              freqs=freq,
                              lknee=lknee,
                              alpha=alpha)
    Nofzs = np.multiply(HMF.N_of_z_SZ(fsky, SZProf),
                        np.diff(z_edges).reshape(1, z_edges.size - 1)).ravel()
    print(Nofzs.sum())
    #sys.exit()

    saveId = expName + "_" + gridName + "_" + cal + "_v" + ver
    Nmzq = np.load(bigDataDir + "N_mzq_" + saveId + "_fid.npy") * fsky
    Nmz = Nmzq.sum(axis=-1)
    Nz = Nmzq.sum(axis=0).sum(axis=-1)
    print(Nz.shape)

    m_edges = 10**mexp_edges
    masses = (m_edges[1:] + m_edges[:-1]) / 2.
    mexp_new = np.log10(np.linspace(masses[0], masses[-1], 10))
    z_new = np.linspace(0.25, 2.75, 10)
    print(Nmz.sum())
Ejemplo n.º 4
0
                          clusterDict,
                          rms_noises=noise,
                          fwhms=beam,
                          freqs=freq,
                          lknee=lknee,
                          alpha=alpha)

fsky = 0.4

N1 = hmf.N_of_z() * fsky

#hmf.sigN = np.loadtxt("temp.txt")

try:
    hmf.sigN = np.loadtxt("tempSigN.txt")
    N2 = hmf.N_of_z_SZ(SZProf) * fsky
except:
    N2 = hmf.N_of_z_SZ(SZProf) * fsky
    np.savetxt("tempSigN.txt", hmf.sigN)

pl = Plotter()
pl.plot2d(hmf.sigN)
pl.done(outDir + "signRefactor.png")

pl = Plotter(scaleY='log')
pl.add(zs, N1)
pl.add(zs, N2)

Ntot1 = np.trapz(N2, zs)
print(Ntot1)
Ejemplo n.º 5
0

# HMF

zbin = np.arange(0.,3.0,0.1)
#zbin = np.insert(zbin_temp,0,0.0)
#print zbin

Mexp = np.arange(13.5,15.71,0.01)

start3 = time.time()
SZProf = SZ_Cluster_Model(cc,clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lknee=lknee,alpha=alpha)

HMF = Halo_MF(cc,Mexp,zbin)
dvdz = HMF.dVdz#(zbin)
dndm = HMF.N_of_z_SZ(SZProf)

sys.exit()
print(("Time for N of z " , time.time() - start3))


# pl = Plotter()
# pl.add(zbin[1:], dndm * dvdz[1:])
# pl.done("output/dndm.png")

print(("Total number of clusters ", np.trapz(dndm ,zbin[:],np.diff(zbin[:]))*fsky))

#np.savetxt('output/dndm_dVdz_1muK_3_0arc.txt',np.transpose([zbin[1:],dndm,dvdz[1:]]))

mfile = "data/S4-7mCMB_all.pkl"
minrange, zinrange, lndM = pickle.load(open(mfile,'rb'))
Ejemplo n.º 6
0
    #mbin = np.arange(12.5,15.5,0.05)+0.05
    #zbin_temp = np.arange(0.05,2.05,0.05)

    #zbin = np.insert(zbin_temp,0,0.0)
    #qbin = np.arange(np.log(5),np.log(500),0.08)
    zbin_temp = np.arange(0.05,3.0,0.05)
    zbin = np.insert(zbin_temp,0,0.0)
    #qbin = np.arange(np.log(6),np.log(500),0.08)
    qbin = np.arange(np.log(6),np.log(500),0.08)
    mbin = np.arange(13.5, 15.71, .10)
    start3 = time.time()

    HMF = Halo_MF(clusterCosmology=cc)
    dvdz = HMF.dVdz(zbin)
    dndm = HMF.N_of_z_SZ(zbin,beam,noise,freq,clusterDict,lknee,alpha,fileFunc)
    #dndm2 = HMF.N_of_z(zbin)
    #dNdmdz,dm = HMF.N_of_mz_SZ(zbin,beam,noise,freq,clusterDict,lknee,alpha,fileFunc)
    #ans = HMF.N_of_mqz_SZ(mass_err,zbin,mbin,np.exp(qbin),beam,noise,freq,clusterDict,lknee,alpha,fileFunc)

    print(("Time for N of z " , time.time() - start3))

    #np.save('output/dN_dzmq'+experimentName[ii]+cosmologyName,ans)
    #print np.max(ans)

    #pl = Plotter()
    #pl.add(zbin[1:], dndm * dvdz[1:])
    #pl.done("output/dndm"+experimentName[ii]+".png")

    #print "Total number of clusters ", np.trapz(dndm * dvdz[1:],zbin[1:],np.diff(zbin[1:]))*4.*np.pi*fsky
    #print "Total number of clusters possible", np.trapz(dndm2,zbin[1:],np.diff(zbin[1:]))*4.*np.pi*fsky
Ejemplo n.º 7
0
    mexp_edges, z_edges, lndM = pickle.load(open(massGridName,"rb"),encoding='latin1')

    zrange = (z_edges[1:]+z_edges[:-1])/2.

    beam = list_from_config(Config,expName,'beams')
    noise = list_from_config(Config,expName,'noises')
    freq = list_from_config(Config,expName,'freqs')
    lknee = list_from_config(Config,expName,'lknee')[0]
    alpha = list_from_config(Config,expName,'alpha')[0]
    fsky = Config.getfloat(expName,'fsky')
    HMF = Halo_MF(cc,mexp_edges,z_edges)
    HMF.sigN = siggrid.copy()

    
    SZProf = SZ_Cluster_Model(cc,clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lknee=lknee,alpha=alpha)
    Nofzs = np.multiply(HMF.N_of_z_SZ(fsky,SZProf),np.diff(z_edges).reshape(1,z_edges.size-1)).ravel()
    print(Nofzs.sum())
    print(Nofzs,zrange)
    #sys.exit()

    saveId = expName + "_" + gridName + "_" + cal + "_v" + ver
    Nmzq = np.load(bigDataDir+"N_mzq_"+saveId+"_fid.npy")*fsky
    Nmz = Nmzq.sum(axis=-1)
    Nz = Nmzq.sum(axis=0).sum(axis=-1)
    print(Nz.shape)
    print(Nz[10:],zrange[10:],np.sum(Nz[10:]))
    

    m_edges = 10**mexp_edges
    masses = (m_edges[1:]+m_edges[:-1])/2.
    mexp_new = np.log10(np.linspace(masses[0],masses[-1],10))
Ejemplo n.º 8
0
mgrid,zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+".pkl",'rb'))

Mexp_edges, z_edges, lndM = pickle.load(open(calFile,"rb"))

HMF = Halo_MF(cc,Mexp_edges,z_edges)
HMF.sigN = siggrid.copy()
#MM = 10**np.linspace(13.,14.,5)
#print SZProfExample.quickVar(MM,zz,tmaxN=tmaxN,numts=numts)

#sys.exit()

#print z_edges
#print HMF.N_of_z()

Nzs =  HMF.N_of_z_SZ(fsky,SZProfExample)*np.diff(z_edges)
zcents = old_div((z_edges[1:]+z_edges[:-1]),2.)
pl = Plotter()
pl.add(zcents,Nzs)
pl.done("nz.png")


print((HMF.Mass_err(fsky,lndM*24.0,SZProfExample)))

#print "quickvar " , np.sqrt(SZProfExample.quickVar(MM,zz,tmaxN=tmaxN,numts=numts))
#print "filtvar " , np.sqrt(SZProfExample.filter_variance(MM,zz))