示例#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 __init__(self,iniFile,expName,gridName,version,ClusterCosmology):
        Config = SafeConfigParser()
        Config.optionxform=str
        Config.read(iniFile)

        self.cc = ClusterCosmology

        bigDataDir = Config.get('general','bigDataDirectory')
        self.clttfile = Config.get('general','clttfile')
        self.constDict = dict_from_section(Config,'constants')
        self.clusterDict = dict_from_section(Config,'cluster_params')
        #version = Config.get('general','version')
        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]
        self.fsky = Config.getfloat(expName,'fsky')

        self.mgrid,self.zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+".pkl",'rb'))

        #self.cc = ClusterCosmology(self.fparams,self.constDict,clTTFixFile=self.clttfile)
        self.SZProp = SZ_Cluster_Model(self.cc,self.clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lknee=lknee,alpha=alpha)
        self.HMF = Halo_MF(self.cc,self.mgrid,self.zgrid)
        self.HMF.sigN = siggrid.copy()
示例#3
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()
示例#4
0
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))

origPk = HMF.pk.copy()

print("Calculating derivatives for overall power ...")
示例#5
0
文件: testV3.py 项目: mntw/szar
# numts=10000





cosmoDict = dict_from_section(Config,cosmologyName)
#cosmoDict = dict_from_section(Config,'WMAP9')
constDict = dict_from_section(Config,'constants')
clusterDict = dict_from_section(Config,clusterParams)
cc = ClusterCosmology(cosmoDict,constDict,pickling=True,clTTFixFile = "data/cltt_lensed_Feb18.txt")

# make an SZ profile example


SZProfExample = SZ_Cluster_Model(clusterCosmology=cc,clusterDict=clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lmax=lmax,lknee=lknee,alpha=alpha,dell=dell,pmaxN=pmaxN,numps=numps,v3mode=2,fsky=0.4)


#MM = 10**np.linspace(13.,14.,5)
#print SZProfExample.quickVar(MM,zz,tmaxN=tmaxN,numts=numts)

#sys.exit()


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




示例#6
0
#experimentName = "CMB-Probe-50cm"
experimentName = "CCATP-MSIP"
#experimentName = "CCATP-SO-MSIP"
beams = listFromConfig(Config, experimentName, 'beams')
noises = listFromConfig(Config, experimentName, 'noises')
freqs = listFromConfig(Config, experimentName, 'freqs')
lmax = int(Config.getfloat(experimentName, 'lmax'))
lknee = listFromConfig(Config, experimentName, 'lknee')[0]
alpha = listFromConfig(Config, experimentName, 'alpha')[0]
fsky = Config.getfloat(experimentName, 'fsky')

SZProfExample = SZ_Cluster_Model(clusterCosmology=cc,
                                 clusterDict=clusterDict,
                                 rms_noises=noises,
                                 fwhms=beams,
                                 freqs=freqs,
                                 lmax=lmax,
                                 lknee=lknee,
                                 alpha=alpha)

ILC = ILC_simple(clusterCosmology=cc,
                 rms_noises=noises,
                 fwhms=beams,
                 freqs=freqs,
                 lmax=lmax,
                 lknee=lknee,
                 alpha=alpha)

experimentName = "CCATP-SO-MSIP"
beams = listFromConfig(Config, experimentName, 'beams')
noises = listFromConfig(Config, experimentName, 'noises')
fsky = Config.getfloat(expName, 'fsky')
try:
    v3mode = Config.getint(expName, 'V3mode')
except:
    v3mode = -1

fparams = {}
for (key, val) in Config.items('params'):
    if ',' in val:
        param, step = val.split(',')
        fparams[key] = float(param)
    else:
        fparams[key] = float(val)

cc = ClusterCosmology(fparams, constDict, clTTFixFile=clttfile)
HMF = Halo_MF(cc, mexp_edges, z_edges)
SZCluster = SZ_Cluster_Model(cc,
                             clusterDict,
                             rms_noises=noise,
                             fwhms=beam,
                             freqs=freq,
                             lknee=lknee,
                             alpha=alpha,
                             v3mode=v3mode,
                             fsky=fsky)

HMF.updateSigN(SZCluster)
HMF.updatePfunc(SZCluster)

np.save(bigDataDir + "Sel_func" + saveId, HMF.Pfunc)
示例#8
0
# numts=10000





cosmoDict = dictFromSection(Config,cosmologyName)
#cosmoDict = dictFromSection(Config,'WMAP9')
constDict = dictFromSection(Config,'constants')
clusterDict = dictFromSection(Config,clusterParams)
cc = ClusterCosmology(cosmoDict,constDict,pickling=True,clTTFixFile = "data/cltt_lensed_Feb18.txt")

# make an SZ profile example


SZProfExample = SZ_Cluster_Model(clusterCosmology=cc,clusterDict=clusterDict,rms_noises = noise,fwhms=beam,freqs=freq,lmax=lmax,lknee=lknee,alpha=alpha,dell=dell,pmaxN=pmaxN,numps=numps,qmin=6)

version = Config.get('general','version')
bigDataDir = Config.get('general','bigDataDirectory')

calFile = bigDataDir+"lensgrid_"+gridName+"_"+calName+".pkl"

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)
示例#9
0
alphaT = comm.bcast(alphaT, root=0)
kh = comm.bcast(kh, root=0)
pk = comm.bcast(pk, root=0)
Mexp_edges = comm.bcast(Mexp_edges, root=0)
z_edges = comm.bcast(z_edges, root=0)
if rank == 0: print("Broadcasted.")

cc = ClusterCosmology(fparams, constDict, clTTFixFile=clttfile)
if doSZ:
    HMF = Halo_MF(cc, mgrid, zgrid, kh=kh, powerZK=pk)
    SZCluster = SZ_Cluster_Model(cc,
                                 clusterDict,
                                 rms_noises=noise,
                                 fwhms=beam,
                                 freqs=freq,
                                 lknee=lkneeT,
                                 alpha=alphaT,
                                 fg=doFg,
                                 tsz_cib=dotsz_cib,
                                 v3mode=v3mode,
                                 fsky=fsky)

numms = mgrid.size
numzs = zgrid.size
if doLens:
    MerrGrid = np.zeros((numms, numzs))
    if True:  #doRayDeriv:
        MerrGridUp = np.zeros((numms, numzs))
        MerrGridDn = np.zeros((numms, numzs))

if doSZ: siggrid = np.zeros((numms, numzs))
示例#10
0
文件: testHMF.py 项目: mntw/szar
assert np.all(mgrid==mexp_edges)
assert np.all(z_edges==zgrid)

cc = ClusterCosmology(fparams,constDict,clTTFixFile=clttfile)
HMF = Halo_MF(cc,mgrid,zgrid)

qs = listFromConfig(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

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

Mwl = 10**HMF.Mexp
z_arr = HMF.zarr
M_arr =  np.outer(HMF.M,np.ones([len(z_arr)]))

if HMF.sigN is None: HMF.updateSigN(SZProp)
sigN = HMF.sigN


q_arr = old_div((qbin_edges[1:]+qbin_edges[:-1]),2.)

blah = SZProp.P_of_qn_corr(SZProp.lnY,M_arr,z_arr,sigN,q_arr,Mwl)#,lndM)

#dN_dmqz_corr = HMF.N_of_mqz_SZ_corr(lndM,qbin_edges,SZProp)
#dN_dmqz = HMF.N_of_mqz_SZ(lndM,qbin_edges,SZProp)