def __init__(self, *args, **kwargs): super(TestHMF, self).__init__(*args, **kwargs) iniFile = "tests/unitTests.ini" Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) self.testname = Config.get('general', 'testName') ms = listFromConfig(Config, self.testname, 'mexp') self.marray = np.arange(ms[0], ms[1], ms[2]) self.zs = listFromConfig(Config, self.testname, 'zs')
#expList = ['S4-1.0-0.4','S4-1.5-0.4','S4-1.5-0.7','S4-1.5-0.3','S4-1.5-0.2','S4-1.5-0.1','S4-1.5-0.05','S4-2.0-0.4','S4-2.5-0.4','S4-3.0-0.4'] #expList = ['S4-1.5-0.3','S4-1.5-0.2','S4-1.5-0.1'] expList = ['SO-v2'] #'S4-1.5-0.3','S4-1.5-0.2','S4-1.5-0.1'] calList = ['CMB_all', 'CMB_pol', 'CMB_all_miscentered', 'CMB_pol_miscentered'] gridName = "grid-default" from configparser import SafeConfigParser iniFile = "input/pipeline.ini" Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) bigDataDir = Config.get('general', 'bigDataDirectory') version = Config.get('general', 'version') zs = listFromConfig(Config, gridName, 'zrange') z_edges = np.arange(zs[0], zs[1] + zs[2], zs[2]) numCores = z_edges.size for exp in expList: for cal in calList: massGridName = bigDataDir + "lensgrid_" + exp + "_" + gridName + "_" + cal + "_v" + version + ".pkl" cmd = "nohup wq sub -r \"mode:bycore;N:" + str( numCores ) + ";hostfile: auto;job_name: " + exp + "_" + cal + ";priority:med\" -c \"source ~/.bash_profile ; source ~/.bashrc ; cd ~/repos/szar ; mpirun -hostfile %hostfile% python bin/makeS8Derivs.py " + exp + " " + gridName + " " + cal + " " + massGridName + " \" > output" + str( time.time()) + "_cmbderiv_" + exp + "_" + cal + ".log &"
',') # Load other Fisher matrices to add otherFisher = loadFishers(Config.get('fisher', 'otherFishers').split(',')) # Get CMB noise functions and ell ranges. Note that the same overriding is possible but here the beams and noises have to be lists for the different frequencies. fnTT, fnEE = noiseFromConfig(Config, expName, TCMB=TCMB, beamsOverride=None, noisesOverride=None, lkneeTOverride=None, lkneePOverride=None, alphaTOverride=None, alphaPOverride=None) tellmin, tellmax = listFromConfig(Config, expName, 'tellrange') pellmin, pellmax = listFromConfig(Config, expName, 'pellrange') # Pad CMB lensing noise with infinity outside L ranges kellmin, kellmax = listFromConfig(Config, 'lensing', 'Lrange') fnKK = cmb.noise_pad_infinity( interp1d(ls, Nls, fill_value=np.inf, bounds_error=False), kellmin, kellmax) # Decide on what ell range to calculate the Fisher matrix ellrange = np.arange(min(tellmin, pellmin, kellmin), max(tellmax, pellmax, kellmax)).astype(int) # Get fsky fsky = Config.getfloat(expName, 'fsky') # Calculate the Fisher matrix and add to other Fishers # Fisher = otherFisher+calcFisher(paramList,ellrange,fidCls,dCls,fnTT,fnEE,fnKK,fsky,verbose=True)
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") cf = 1 constraint_tag = ['', '_constrained'] #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)
import pickle as pickle from orphics.tools.io import Plotter from orphics.analysis.flatMaps import interpolateGrid clusterParams = 'LACluster' # from ini file cosmologyName = 'LACosmology' # from ini file experimentName = "LATest" iniFile = "input/params.ini" Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) outDir = os.environ['WWW'] 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, clTTFixFile="data/cltt_lensed_Feb18.txt") #,skipCls=True) mfile = "data/S4-7mCMB_all.pkl"
clusterParams = 'cluster_params' # from ini file cosmologyName = 'params' # from ini file iniFile = "../szar/input/pipeline.ini" Config = SafeConfigParser() Config.optionxform = str Config.read(iniFile) cosmoDict = dictFromSection(Config, cosmologyName) constDict = dictFromSection(Config, 'constants') clusterDict = dictFromSection(Config, clusterParams) bigDataDir = Config.get('general', 'bigDataDirectory') beam = listFromConfig(Config, expName, 'beams') noise = listFromConfig(Config, expName, 'noises') freq = listFromConfig(Config, expName, 'freqs') lkneeT, lkneeP = listFromConfig(Config, expName, 'lknee') alphaT, alphaP = listFromConfig(Config, expName, 'alpha') tellmin, tellmax = listFromConfig(Config, expName, 'halo_tellrange') pellmin, pellmax = listFromConfig(Config, expName, 'halo_pellrange') try: doFg = Config.getboolean(expName, 'do_foregrounds') except: print("NO FG OPTION FOUND IN INI. ASSUMING TRUE.") doFg = True ind = np.where(np.isclose(freq, freq_to_use)) beamFind = np.array(beam)[ind] noiseFind = np.array(noise)[ind]
fparams = {} for (key, val) in Config.items('params'): if ',' in val: param, step = val.split(',') if key=='sigR': rayFid = float(param) rayStep = float(step) fparams[key] = float(param) else: fparams[key] = float(val) constDict = dictFromSection(Config,'constants') clusterDict = dictFromSection(Config,'cluster_params') 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] clttfile = Config.get('general','clttfile') # get s/n q-bins 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:
#pl = Plotter(labelX="$z$",labelY="$N(z)$",ftsize=12) colList = ['C0', 'C1', 'C2', 'C3', 'C4'] Ndict = {} for expName, col, labres in zip(expList, colList, labList): mgrid, zgrid, siggrid = pickle.load( open( bigDataDir + "szgrid_" + expName + "_" + gridName + "_v" + version + ".pkl", 'rb')) z_edges = zgrid zrange = old_div((z_edges[1:] + z_edges[:-1]), 2.) mexp_edges = mgrid 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] 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)
alphaTOverride=None, alphaPOverride=None) efficiencies.append(efficiency) printC("Delensing efficiency: " + str(efficiency) + " %", color="green", bold=True) # File root name for Fisher derivatives # CLKK S/N ============================================ # Calculate Clkk S/N #Clkk = fidCls[:,4] kellmin, kellmax = listFromConfig(Config, 'lensing', 'Lrange') fsky = fskyNow #Config.getfloat(expName,'fsky') frange = np.arange(0, kellmax) #np.array(range(len(Clkk))) Clkk = cc.theory.gCl("kk", frange) snrange = np.arange(kellmin, kellmax) LF = LensForecast() LF.loadKK(frange, Clkk, ls, Nls) sn, errs = LF.sn(snrange, fsky, "kk") printC("Lensing autopower S/N: " + str(sn), color="green", bold=True) # pl = Plotter(scaleY='log',scaleX='log') # pl.add(frange,Clkk) # pl.add(ls,Nls) # pl._ax.set_ylim(-max(Clkk),max(Clkk)) # pl.done("clkk.png")
ells = np.arange(2, 8000, 1) cltt = theory.lCl('TT', ells) TCMB = 2.7255e6 out_dir = os.environ['WWW'] pl = io.Plotter(scaleY='log', labelX="$\ell$", labelY="$\ell^2 C_{\ell}$", ftsize=20) for expName, lab in zip(['S4-1.0-0.4-noatm', 'S4-1.0-0.4'], ['S4 1arc no atm', 'S4 1arc lknee=5500 (in paper)']): beam = listFromConfig(Config, expName, 'beams') noise = listFromConfig(Config, expName, 'noises') freq = listFromConfig(Config, expName, 'freqs') lkneeT, lkneeP = listFromConfig(Config, expName, 'lknee') alphaT, alphaP = listFromConfig(Config, expName, 'alpha') print((expName, beam, noise, lkneeT, lkneeP, alphaT, alphaP)) ind = np.where(np.isclose(freq, freq_to_use)) beamFind = np.array(beam)[ind] noiseFind = np.array(noise)[ind] nls = cmb.noise_func(ells, beamFind, noiseFind, lknee=lkneeT,