if (args.printtest): parvals2 = [ 3.46419819e-01, 2.34697120e-02, 6.50170056e+01, 1.33398673e-09, 9.36305025e-01, 2.53310030e-01, 1.93661978e-01, 1.74839544e-01 ] #parvals2 = [1.194e-01,2.34697120e-02,6.50170056e+01,1.33398673e-09,9.36305025e-01,2.53310030e-01,1.93661978e-01,1.74839544e-01] param_vals = lk.alter_fparams(fparams, parlist, parvals) cluster_props = np.array( [CL.clst_z, CL.clst_zerr, CL.clst_y0 * 1e-4, CL.clst_y0err * 1e-4]) start = time.time() int_cc = ClusterCosmology(param_vals, CL.constDict, clTTFixFile=CL.clttfile) print('CC', time.time() - start) start = time.time() int_HMF = Halo_MF(int_cc, CL.mgrid, CL.zgrid) print('HMF', time.time() - start) dn_dzdm_int = int_HMF.inter_dndmLogm(200.) zbins = 10 LgYa = np.outer(np.ones(len(int_HMF.M.copy())), CL.LgY) Y = 10**LgYa Ma = np.outer(int_HMF.M.copy(), np.ones(len(LgYa[0, :]))) clustind = 1
Config = SafeConfigParser() Config.optionxform=str Config.read(iniFile) constDict = dictFromSection(Config,'constants') clusterDict = dictFromSection(Config,'cluster_params') fparams = {} # the for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') fparams[key] = float(param) else: fparams[key] = float(val) clttfile = Config.get('general','clttfile') cc = ClusterCosmology(fparams,constDict,lmax=8000,pickling=True)#clTTFixFile=clttfile) fgs = fgNoises(cc.c,ksz_battaglia_test_csv="data/ksz_template_battaglia.csv",tsz_battaglia_template_csv="data/sz_template_battaglia.csv") experimentName = "SO-v2-6m" 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,tsz_cib=True)
noise_P_uK_arcmin = 1. #0.001 #1.0 #0.01 lmax = 6500 tellmax = 6000 pellmax = 6000 tellmin = 200 pellmin = 200 kellmax = min(tellmax, pellmax) kellmin = 200 gradCut = 2000 #pol_list = ['TT','EB','EE','ET','TE'] pol_list = ['TT'] #,'EB'] out_dir = os.environ['WWW'] + "plots/halotest/lensorder5_" # === COSMOLOGY === cc = ClusterCosmology(lmax=lmax, pickling=True) TCMB = 2.7255e6 theory = cc.theory ps = cmb.enmap_power_from_orphics_theory(theory, lmax, lensed=False) patch_width_arcmin = 40. sim_pixel_scale = 0.1 pol = False shape_sim, wcs_sim = enmap.get_enmap_patch(patch_width_arcmin, sim_pixel_scale, proj="car", pol=pol) modr_sim = enmap.modrmap(shape_sim, wcs_sim) * 180. * 60. / np.pi lxmap_sim, lymap_sim, modlmap_sim, angmap_sim, lx_sim, ly_sim = fmaps.get_ft_attributes_enmap( shape_sim, wcs_sim)
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()
from orphics.theory.cosmology import Cosmology cc = Cosmology(lmax=int(kellmax), pickling=True) theory = cc.theory bin_edges = np.arange(kellmin, kellmax, dell) myNls = NlGenerator(lmap, theory, bin_edges, gradCut=gradCut) from scipy.interpolate import interp1d from orphics.tools.io import Plotter ellkk = np.arange(2, 9000, 1) Clkk = theory.gCl("kk", ellkk) clfunc = interp1d(ellkk, Clkk, bounds_error=False, fill_value="extrapolate") kellmax = 8000 cc = ClusterCosmology(cosmoDict, constDict, kellmax, pickling=True) theory = cc.theory pl = Plotter(labelX="Beam (arcmin)", labelY="$\\sigma(M)/M$ for $N=1000$", ftsize=16) for miscenter in [False, True]: for lensName, linestyle in zip(["CMB_all", "CMB_pol"], ["-", "--"]): for doFg in [False, True]: if lensName == "CMB_pol" and not (doFg): continue if lensName == "CMB_all" and not (doFg) and miscenter: continue sns = [] for beamNow in beamList:
def theory_from_config(Config, theory_section, dimensionless=True): sec_type = Config.get(theory_section, "cosmo_type") lmax = Config.getint(theory_section, "lmax") cc = None if sec_type == "pycamb_params": raise NotImplementedError elif sec_type == "cluster": from szar.counts import ClusterCosmology with oio.nostdout(): with warnings.catch_warnings(): warnings.simplefilter("ignore") logger.disabled = True cc = ClusterCosmology(lmax=lmax, pickling=True, dimensionless=dimensionless) theory = cc.theory logger.disabled = False elif sec_type == "default": from orphics.theory.cosmology import Cosmology with oio.nostdout(): with warnings.catch_warnings(): warnings.simplefilter("ignore") logger.disabled = True cc = Cosmology(lmax=lmax, pickling=True, dimensionless=dimensionless) theory = cc.theory logger.disabled = False elif sec_type == "camb_file": cc = None import orphics.tools.cmb as cmb file_root = Config.get(theory_section, "camb_file_root") theory = cmb.loadTheorySpectraFromCAMB(file_root, unlensedEqualsLensed=False, useTotal=False, TCMB=2.7255e6, lpad=lmax, get_dimensionless=dimensionless) try: cforce = Config.getboolean(theory_section, "cluster_force") except: cforce = False if cforce: from szar.counts import ClusterCosmology cc = ClusterCosmology(skipCls=True, dimensionless=dimensionless) cc.theory = theory elif sec_type == "enlib_file": import orphics.tools.cmb as cmb file_root = Config.get(theory_section, "enlib_file_root") theory = cmb.load_theory_spectra_from_enlib( file_root, lpad=lmax, get_dimensionless=dimensionless) cc = None else: print(sec_type) raise ValueError return theory, cc, lmax
#cal = "CMB_pol_miscentered" from orphics.io import dict_from_section, list_from_config constDict = dict_from_section(Config,'constants') clusterDict = dict_from_section(Config,'cluster_params') fparams = {} # the 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) from matplotlib.patches import Rectangle #expList = ['CMB-Probe-v3-1'] #expList = ['S4-1.0-CDT','S4-1.5-CDT']#,'S4-2.0-0.4','S4-2.5-0.4','S4-3.0-0.4'] #expList = ['S4-1.0-0.4','S4-1.5-0.4','S4-2.0-0.4','S4-2.5-0.4','S4-3.0-0.4'] #expList = ['S4-2.0-0.4']#,'S4-1.5-0.4','S4-1.5-0.3','S4-1.5-0.2','S4-1.5-0.1','S4-1.5-0.05'] #expList = ['S4-1.0-0.4','S4-1.5-0.4','S4-2.0-0.4','S4-2.5-0.4','S4-3.0-0.4'] #expList = ['SO-v3-goal-40','SO-v3-base-40']#,'SO-v3-goal-20','SO-v3-base-20','SO-v3-goal-10','SO-v3-base-10'] #expList = ['CMB-Probe-v4-CBE','CMB-Probe-v4-REQ'] expList = ['SO-v3-goal-40','SO-v3-goal-40'] pad = 0.05
if True: yNzs[key] = [] vals = stepdict[key][:maxSteps] vals.sort() for val in vals: print((key, val)) uppassparams = fparams.copy() dnpassparams = fparams.copy() uppassparams[key] = fparams[key]+old_div(val,2.) dnpassparams[key] = fparams[key]-old_div(val,2.) cc = ClusterCosmology(uppassparams,constDict,clTTFixFile=clttfile) 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) Nup = HMF.N_of_mqz_SZ(lndM*massMultiplier,qbin_edges,SZProf) cc = ClusterCosmology(dnpassparams,constDict,clTTFixFile=clttfile) 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) Ndn = HMF.N_of_mqz_SZ(lndM*massMultiplier,qbin_edges,SZProf) dNdp = old_div((getNmzq(Nup,mexp_edges,z_edges,qbin_edges)-getNmzq(Ndn,mexp_edges,z_edges,qbin_edges)),val)
# dell=1 # pmaxN=25 # numps=10000 # tmaxN=25 # 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"))
exp = experimentName expName = experimentName beam = listFromConfig(Config,experimentName,'beams') noise = listFromConfig(Config,experimentName,'noises') freq = 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') cosmoDict = dictFromSection(Config,cosmologyName) constDict = dictFromSection(Config,'constants') clusterDict = dictFromSection(Config,clusterParams) cc = ClusterCosmology(cosmoDict,constDict,clTTFixFile = "data/cltt_lensed_Feb18.txt")#,skipCls=True) if "owl" in calName: calFile = bigDataDir+"lensgrid_"+gridName+"_"+cal+".pkl" #calFile = bigDataDir+"lensgrid_grid-"+cal+"_"+cal+".pkl" else: 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)
from szar.counts import ClusterCosmology, SZ_Cluster_Model, Halo_MF, sampleVarianceOverNsquareOverBsquare, haloBias, getTotN from orphics.tools.io import Plotter, dictFromSection, listFromConfig from configparser import SafeConfigParser clusterParams = 'LACluster' # from ini file cosmologyName = 'LACosmology' # from ini file iniFile = "input/params.ini" Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) lmax = 3000 cosmoDict = dictFromSection(Config, cosmologyName) constDict = dictFromSection(Config, 'constants') clusterDict = dictFromSection(Config, clusterParams) cc = ClusterCosmology(cosmoDict, constDict, skipCls=True) # mrange = np.arange(13.5,15.71,0.3) # zrange = np.arange(0.05,3.0,0.3) mrange = np.arange(13.5, 15.71, 0.05) zrange = np.arange(0.05, 3.0, 0.1) # mrange = np.arange(13.5,15.71,0.02) # zrange = np.arange(0.02,3.0,0.02) fsky = 0.4 hmf = Halo_MF(cc, mrange, zrange) import os
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
frac_of_survey = count_temp * 1.0 / np.sum(count_temp) thresh_bin = 10**(old_div((bin_edge[:-1] + bin_edge[1:]), 2.)) parlist = [ 'omch2', 'ombh2', 'H0', 'As', 'ns', 'tau', 'massbias', 'yslope', 'scat' ] parvals = [0.1194, 0.022, 67.0, 2.2e-09, 0.96, 0.06, 0.80, 0.08, 0.2] #print fparams params = CL.alter_fparams(fparams, parlist, parvals) #print params start = time.time() int_cc = ClusterCosmology(params, CL.constDict, clTTFixFile=CL.clttfile) # internal HMF call print(('CC', time.time() - start)) start = time.time() int_HMF = Halo_MF(int_cc, CL.mgrid, CL.zgrid) print(('HMF', time.time() - start)) cluster_prop = np.array([CL.clst_z, CL.clst_zerr, CL.clst_y0, CL.clst_y0err]) cluster_prop2 = np.array( [CL.clst_z, CL.clst_zerr, CL.clst_y0 * 1e-4, CL.clst_y0err * 1e-4]) print(cluster_prop.shape) dndm_int = int_HMF.inter_dndm(200.) start = time.time() print( np.log(CL.Prob_per_cluster(int_HMF, cluster_prop2[:, 0], dndm_int,
print((upDict[key])) print((dnDict[key])) beam = io.listFromConfig(Config,experimentName,'beams') noise = io.listFromConfig(Config,experimentName,'noises') freq = io.listFromConfig(Config,experimentName,'freqs') lmax = int(Config.getfloat(experimentName,'lmax')) lknee = Config.getfloat(experimentName,'lknee') alpha = Config.getfloat(experimentName,'alpha') fsky = Config.getfloat(experimentName,'fsky') mass_err_file = Config.get(experimentName,'mass_err') mass_err = np.loadtxt(mass_err_file) ccUp = ClusterCosmology(upDict,constDict,clTTFixFile=clttfile) ccDn = ClusterCosmology(dnDict,constDict,clTTFixFile=clttfile) #mbin = np.arange(12.5,15.5,0.05)+0.05 #zbin_temp = np.arange(0.05,2.05,0.05) zbin_temp = np.arange(0.05,2.0,0.05) zbin = np.insert(zbin_temp,0,0.0) qbin = np.arange(np.log(6),np.log(500),0.08) mbin = np.arange(13.5, 15.71, 0.1) start3 = time.time() mgrid,zgrid,siggrid = pickle.load(open(bigDataDir+"szgrid_"+expName+"_"+gridName+ "_v" + version+".pkl",'rb')) #cc = ClusterCosmology(passParams,constDict,clTTFixFile=clttfile)
Config.optionxform=str Config.read(iniFile) bigDataDir = Config.get('general','bigDataDirectory') version = Config.get('general','version') fparams = {} # the for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') fparams[key] = float(param) else: fparams[key] = float(val) constDict = dict_from_section(Config,'constants') clusterDict = dict_from_section(Config,'cluster_params') cc = ClusterCosmology(fparams,constDict,skipCls=True) fsky = Config.getfloat(expName,'fsky') saveId = expName + "_" + gridName + "_v" + version ms = list_from_config(Config,gridName,'mexprange') mrange = np.arange(ms[0],ms[1]+ms[2],ms[2]) zs = list_from_config(Config,gridName,'zrange') zrange = np.arange(zs[0],zs[1]+zs[2],zs[2]) hmf = Halo_MF(cc,mrange,zrange) zcents, hb = haloBias(mrange,zrange,cc.rhoc0om,hmf.kh,hmf.pk) powers = sampleVarianceOverNsquareOverBsquare(cc,hmf.kh,hmf.pk,zrange,fsky,lmax=lmax)
Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) beam = listFromConfig(Config, experimentName, 'beams') noise = listFromConfig(Config, experimentName, 'noises') freq = listFromConfig(Config, experimentName, 'freqs') lmax = int(Config.getfloat(experimentName, 'lmax')) lknee = Config.getfloat(experimentName, 'lknee') alpha = Config.getfloat(experimentName, 'alpha') fsky = Config.getfloat(experimentName, 'fsky') cosmoDict = dictFromSection(Config, cosmologyName) constDict = dictFromSection(Config, 'constants') clusterDict = dictFromSection(Config, clusterParams) cc = ClusterCosmology(cosmoDict, constDict, lmax) mass_err_file = Config.get(experimentName, 'mass_err') mass_err = np.loadtxt(mass_err_file) zbin_temp = np.arange(0.1, 2.01, 0.05) zbin = np.insert(zbin_temp, 0, 0.0) HMF = Halo_MF(clusterCosmology=cc) errs, Ntot = HMF.Mass_err(mass_err, zbin, beam, noise, freq, clusterDict, lknee, alpha, fileFunc) print((np.sqrt(errs))) print(Ntot)
print('sample time',time.time() - start) sys.exit(0) CL = lk.clusterLike(iniFile,pardict,nemoOutputDir,noise_file,fix_params,fixvals,fixlist,fitsfile,test=args.test,simtest=simtst,simpars=args.simpars,y0thresh=args.y0test) if (args.printtest): parvals2 = [3.46419819e-01,2.34697120e-02,6.50170056e+01,1.33398673e-09,9.36305025e-01,2.53310030e-01,1.93661978e-01,1.74839544e-01] #parvals2 = [1.194e-01,2.34697120e-02,6.50170056e+01,1.33398673e-09,9.36305025e-01,2.53310030e-01,1.93661978e-01,1.74839544e-01] param_vals= lk.alter_fparams(fparams,parlist,parvals) cluster_props = np.array([CL.clst_z,CL.clst_zerr,CL.clst_y0*1e-4,CL.clst_y0err*1e-4]) start = time.time() int_cc = ClusterCosmology(param_vals,CL.constDict,clTTFixFile=CL.clttfile) print('CC',time.time() - start) start = time.time() int_HMF = Halo_MF(int_cc,CL.mgrid,CL.zgrid) print('HMF',time.time() - start) dn_dzdm_int = int_HMF.inter_dndmLogm(200.) zbins = 10 LgYa = np.outer(np.ones(len(int_HMF.M.copy())),CL.LgY) Y = 10**LgYa Ma = np.outer(int_HMF.M.copy(),np.ones(len(LgYa[0,:]))) Marr = np.outer(int_HMF.M.copy(),np.ones([len(int_HMF.zarr)])) z_arr = np.outer(np.ones([len(int_HMF.M.copy())]),int_HMF.zarr) ii = 1