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()
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()
def __init__(self,iniFile,test_cat_file,fix_params,mmin=14.3): self.fix_params = fix_params Config = SafeConfigParser() Config.optionxform=str Config.read(iniFile) self.fparams = {} for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') self.fparams[key] = float(param) else: self.fparams[key] = float(val) bigDataDir = Config.get('general','bigDataDirectory') self.clttfile = Config.get('general','clttfile') self.constDict = dict_from_section(Config,'constants') logm_min = 14.0 logm_max = 15.702 logm_spacing = 0.01 self.mgrid = np.arange(logm_min,logm_max,logm_spacing) self.zgrid = np.arange(0.1,2.001,0.05) self.cc = ClusterCosmology(self.fparams,self.constDict,clTTFixFile=self.clttfile) self.HMF = Halo_MF(self.cc,self.mgrid,self.zgrid) self.fsky = old_div(987.5,41252.9612) self.mmin = mmin clust_cat = test_cat_file + '.fits' self.clst_z,self.clst_zerr,self.clst_m,self.clst_merr = read_test_mock_cat(clust_cat,self.mmin)
def __init__(self, inifile, expname, gridname, version): self.params = None self.inifile = inifile self.config = ConfigParser() self.config.optionxform = str self.config.read(self.inifile) self.constdict = dict_from_section(self.config, 'constants') self.clttfile = self.config.get('general', 'clttfile') self.expname = expname self.gridname = gridname self.version = version self.saveid = self.expname + "_" + self.gridname + "_v" + self.version
def get_cc(ini): Config = ConfigParser() Config.optionxform = str Config.read(ini) clttfile = Config.get('general', 'clttfile') constDict = dict_from_section(Config, 'constants') 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) return cc
def __init__(self, iniFile, kmin=1e-4, kmax=5., knum=200): Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) self.fparams = {} for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') self.fparams[key] = float(param) else: self.fparams[key] = float(val) bigDataDir = Config.get('general', 'bigDataDirectory') self.clttfile = Config.get('general', 'clttfile') self.constDict = dict_from_section(Config, 'constants') self.clusterDict = dictFromSection(Config, 'cluster_params') version = Config.get('general', 'version') beam = listFromConfig(Config, expName, 'beams') noise = listFromConfig(Config, expName, 'noises') freq = listFromConfig(Config, expName, 'freqs') lknee = listFromConfig(Config, expName, 'lknee')[0] alpha = listFromConfig(Config, expName, 'alpha')[0] 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.HMF = Halo_MF(self.cc, self.mgrid, self.zgrid) if powerZK is None: self.kh, self.pk = self._pk_lin(self.HMF.zarr, kmin, kmax, knum) else: assert kh is not None self.kh = kh self.pk = powerZK
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()
frac = npfact / (1. + npfact) ans = np.multiply(frac**2, V0) return ans INIFILE = "input/pipeline.ini" expName = 'S4-1.0-CDT' gridName = 'grid-owl2' version = '0.6' Config = ConfigParser() Config.optionxform = str Config.read(INIFILE) clttfile = Config.get('general', 'clttfile') constDict = dict_from_section(Config, 'constants') fparams = {} for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') fparams[key] = float(param) else: fparams[key] = float(val) expName = 'S4-1.0-CDT' gridName = 'grid-owl2' version = '0.6' cc = ClusterCosmology(fparams, constDict, clTTFixFile=clttfile) clst = Clustering(INIFILE, expName, gridName, version, cc)
bigDataDir = Config.get('general', 'bigDataDirectory') pzcutoff = Config.getfloat('general', 'photoZCutOff') mgrid, zgrid, siggrid = pickle.load(open( bigDataDir + "szgrid_" + expName + "_" + gridName + "_v" + version + ".pkl", 'rb'), encoding='latin1') assert np.all(mgrid == mexprange) assert np.all(zrange == zgrid) saveId = expName + "_" + gridName + "_" + calName + "_v" + version from orphics.io import dict_from_section, list_from_config constDict = dict_from_section(Config, 'constants') clusterDict = dict_from_section(Config, 'cluster_params') 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') massMultiplier = Config.getfloat('general', 'mass_calib_factor') clttfile = Config.get('general', 'clttfile') # get s/n q-bins qs = list_from_config(Config, 'general', 'qbins') qspacing = Config.get('general', 'qbins_spacing')
def __init__(self,iniFile,parDict,nemoOutputDir,noiseFile,fix_params,fitsfile,test=False,simtest=False,simpars=False): self.fix_params = fix_params self.test = test self.simtest = simtest self.simpars = simpars Config = SafeConfigParser() Config.optionxform=str Config.read(iniFile) self.fparams = {} for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') self.fparams[key] = float(param) else: self.fparams[key] = float(val) bigDataDir = Config.get('general','bigDataDirectory') self.clttfile = Config.get('general','clttfile') self.constDict = dict_from_section(Config,'constants') #version = Config.get('general','version') #self.mgrid,self.zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+".pkl",'rb')) logm_min = 13.7 logm_max = 15.72 logm_spacing = 0.02 self.mgrid = np.arange(logm_min,logm_max,logm_spacing) self.zgrid = np.arange(0.1,2.01,0.1) #print self.mgrid #print self.zgrid self.qmin = 5.6 self.cc = ClusterCosmology(self.fparams,self.constDict,clTTFixFile=self.clttfile) self.HMF = Halo_MF(self.cc,self.mgrid,self.zgrid) self.diagnosticsDir=nemoOutputDir+"diagnostics" self.filteredMapsDir=nemoOutputDir+"filteredMaps" self.tckQFit=simsTools.fitQ(parDict, self.diagnosticsDir, self.filteredMapsDir) FilterNoiseMapFile = nemoOutputDir + noiseFile MaskMapFile = self.diagnosticsDir + '/areaMask.fits' #if self.simtest or self.simpars: # print "mock catalog" #clust_cat = nemoOutputDir + 'mockCatalog_equD56.fits' #'ACTPol_mjh_cluster_cat.fits' # clust_cat = nemoOutputDir + 'mockCat_D56equ_v22.fits' #'ACTPol_mjh_cluster_cat.fits' # self.clst_z,self.clst_zerr,self.clst_y0,self.clst_y0err = read_mock_cat(clust_cat,self.qmin) #else: # print "real catalog" # clust_cat = nemoOutputDir + 'E-D56Clusters.fits' #'ACTPol_mjh_cluster_cat.fits' # self.clst_z,self.clst_zerr,self.clst_y0,self.clst_y0err = read_clust_cat(clust_cat,self.qmin) clust_cat = nemoOutputDir + fitsfile if self.simtest or self.simpars: print("mock catalog") self.clst_z,self.clst_zerr,self.clst_y0,self.clst_y0err = read_mock_cat(clust_cat,self.qmin) else: print("real catalog") self.clst_z,self.clst_zerr,self.clst_y0,self.clst_y0err = read_clust_cat(clust_cat,self.qmin) self.rms_noise_map = read_MJH_noisemap(FilterNoiseMapFile,MaskMapFile) print ('Number of clusters',len(self.clst_zerr)) #self.wcs=astWCS.WCS(FilterNoiseMapFile) #self.clst_RA,self.clst_DEC, #self.clst_xmapInd,self.clst_ymapInd = self.Find_nearest_pixel_ind(self.clst_RA,self.clst_DEC) self.num_noise_bins = 10 self.area_rads = old_div(987.5,41252.9612) # fraction of sky - ACTPol D56-equ specific self.LgY = np.arange(-6,-3,0.01) count_temp,bin_edge =np.histogram(np.log10(self.rms_noise_map[self.rms_noise_map>0]),bins=self.num_noise_bins) self.frac_of_survey = count_temp*1.0 / np.sum(count_temp) self.thresh_bin = 10**(old_div((bin_edge[:-1] + bin_edge[1:]),2.))
def __init__(self,iniFile,parDict,nemoOutputDir,noiseFile,params,parlist,mass_grid_log=None,z_grid=None,randoms=False): Config = SafeConfigParser() Config.optionxform=str Config.read(iniFile) if mass_grid_log: logm_min,logm_max,logm_spacing = mass_grid_log else: logm_min = 12.7 logm_max = 15.72 logm_spacing = 0.04 if z_grid: zmin,zmax,zdel = z_grid else: zmin = 0.0 zmax = 2.01 zdel = 0.1 self.fparams = {} for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') self.fparams[key] = float(param) else: self.fparams[key] = float(val) self.param_vals = alter_fparams(self.fparams,parlist,params) bigDataDir = Config.get('general','bigDataDirectory') self.clttfile = Config.get('general','clttfile') self.constDict = dict_from_section(Config,'constants') if mass_grid_log: logm_min,logm_max,logm_spacing = mass_grid_log else: logm_min = 12.7 logm_max = 15.72 logm_spacing = 0.04 if z_grid: zmin,zmax,zdel = z_grid else: zmin = 0.0 zmax = 2.01 zdel = 0.1 if randoms: self.rand = 1 else: self.rand = 0 self.mgrid = np.arange(logm_min,logm_max,logm_spacing) self.zgrid = np.arange(zmin,zmax,zdel) self.Medges = 10.**self.mgrid self.Mcents = (self.Medges[1:]+self.Medges[:-1])/2. self.Mexpcents = np.log10(self.Mcents) self.zcents = (self.zgrid[1:]+self.zgrid[:-1])/2. self.cc = ClusterCosmology(self.param_vals,self.constDict,clTTFixFile=self.clttfile) self.HMF = Halo_MF(self.cc,self.mgrid,self.zgrid) self.diagnosticsDir=nemoOutputDir+"diagnostics" self.filteredMapsDir=nemoOutputDir+"filteredMaps" self.tckQFit=simsTools.fitQ(parDict, self.diagnosticsDir, self.filteredMapsDir) FilterNoiseMapFile = nemoOutputDir + noiseFile MaskMapFile = self.diagnosticsDir + '/areaMask.fits' self.rms_noise_map = read_MJH_noisemap(FilterNoiseMapFile,MaskMapFile) self.wcs=astWCS.WCS(FilterNoiseMapFile) self.fsky = 987.5/41252.9612 # in rads ACTPol D56-equ specific self.scat_val = 0.2 self.seedval = np.int(np.round(time.time())) #1
pmaxN=5 numps=1000 tmaxN=5 numts=1000 # dell=1 # pmaxN=25 # numps=10000 # tmaxN=25 # 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()