예제 #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()
예제 #2
0
def sel_counts_from_config(Config,bigDataDir,version,expName,gridName,calName,mexp_edges,z_edges,lkneeTOverride=None,alphaTOverride=None,zmin=-np.inf,zmax=np.inf,mmin=-np.inf,mmax=np.inf,recalculate=False,override_params=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'),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")
    if override_params is not None:
        for key in override_params.keys():
            cosmoDict[key] = override_params[key]
    # print(cosmoDict)
    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()

    saveId = save_id(expName,gridName,calName,version)
    # Fiducial number counts

    if recalculate:
        from . import counts
        # get s/n q-bins
        qs = list_from_config(Config,'general','qbins')
        qspacing = Config.get('general','qbins_spacing')
        if qspacing=="log":
            qbin_edges = np.logspace(np.log10(qs[0]),np.log10(qs[1]),int(qs[2])+1)
        elif qspacing=="linear":
            qbin_edges = np.linspace(qs[0],qs[1],int(qs[2])+1)
        else:
            raise ValueError
        calFile = mass_grid_name_owl(bigDataDir,calName)        
        mexp_edges, z_edges, lndM = pickle.load(open(calFile,"rb"))
        dN_dmqz = hmf.N_of_mqz_SZ(lndM,qbin_edges,SZProf)
        nmzq = counts.getNmzq(dN_dmqz,mexp_edges,z_edges,qbin_edges)
    else:
        nmzq = np.load(fid_file(bigDataDir,saveId))
    nmzq = nmzq*fsky

    zs = (z_edges[1:]+z_edges[:-1])/2.
    zsel = np.logical_and(zs>zmin,zs<=zmax)

    M_edges = 10**mexp_edges
    M = (M_edges[1:]+M_edges[:-1])/2.
    Mexp = np.log10(M)
    msel = np.logical_and(Mexp>mmin,Mexp<=mmax)
    
    Ns = nmzq.sum(axis=-1)[msel,:][:,zsel]
    return Ns #.ravel().sum()
예제 #3
0
파일: testRefactor.py 프로젝트: mntw/szar
SZProf = SZ_Cluster_Model(cc,
                          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)
예제 #4
0
clttfile = Config.get('general', 'clttfile')

# get s/n q-bins
qs = list_from_config(Config, 'general', 'qbins')
qspacing = Config.get('general', 'qbins_spacing')
if qspacing == "log":
    qbins = np.logspace(np.log10(qs[0]), np.log10(qs[1]), int(qs[2]) + 1)
elif qspacing == "linear":
    qbins = np.linspace(qs[0], qs[1], int(qs[2]) + 1)
else:
    raise ValueError

cc = ClusterCosmology(fparams, constDict, clTTFixFile=clttfile)
HMF = Halo_MF(cc, mexprange, zrange)

HMF.sigN = siggrid.copy()
SZProf = SZ_Cluster_Model(cc,
                          clusterDict,
                          rms_noises=noise,
                          fwhms=beam,
                          freqs=freq,
                          lknee=lknee,
                          alpha=alpha)

h = 0.05
# s80, As = getA(fparams,constDict,zrange,kmax=11.)
# s8zs = As*s80

dNFid_dmzq = HMF.N_of_mqz_SZ(lndM * massMultiplier, qbins, SZProf)
np.save(bigDataDir + "N_mzq_" + saveId + "_fid_sigma8",
        getNmzq(dNFid_dmzq, mgrid, zrange, qbins))
예제 #5
0
    calFile = bigDataDir+"lensgrid_"+exp+"_"+gridName+"_"+calName+ "_v" + version+".pkl"


Mexp_edges, z_edges, lndM = pickle.load(open(calFile,"rb"))
mgrid,zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+".pkl",'rb'))
zs = old_div((z_edges[1:]+z_edges[:-1]),2.)


hmf = Halo_MF(cc,Mexp_edges,z_edges)


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


N1 = hmf.N_of_z()*fsky
hmf.sigN = siggrid
N2 = hmf.N_of_z_SZ(SZProf)*fsky

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

Ntot0 = np.dot(N1,np.diff(z_edges))
Ntot1 = np.dot(N2,np.diff(z_edges))
print(("All clusters in the Universe  ",Ntot0))
print(("All clusters detectable at qmin ",SZProf.qmin," is ",Ntot1))


sn,ntot = hmf.Mass_err(fsky,lndM,SZProf)
outmerr = lndM