def testAgainstKSmith(pmax, beamFWHMArcmin, dCls, lclbb, rExp, rInFid, fCls, fsky): from orphics.io import Plotter pl = Plotter(scaleX='log', scaleY='log') pnoiserange = np.logspace(np.log10(0.5), np.log10(50.), num=100) for pmin in [2, 5, 10, 40]: sigs = [] for deltaP in pnoiserange: ellBBRange = range(pmin, pmax) sigs.append( rSigma(fsky, ellBBRange, beamFWHMArcmin, deltaP, dCls[:, 2], lclbb, rExp * fCls[:, 2] / rInFid)) kn, kr = np.loadtxt("data/k" + str(pmin) + ".csv", delimiter=',', unpack=True) pl.add(kn, kr, ls='--') pl.add(pnoiserange, sigs, label="$\\ell_{\mathrm{min}}=" + str(pmin) + "$") pl.legendOn() pl._ax.set_xlim(0.5, 50.) pl._ax.set_ylim(1.e-5, 1.e-1) pl.done("kenplot.png")
def PlotcmbWeights(self,outfile): #plot weights pl = Plotter() for ii in range(len(self.freq)): pl.add(self.evalells,self.W_ll_cmb[:,ii],label=str(self.freq[ii])+' GHz') pl.legend(loc='lower left',labsize=10) pl.done(outfile)
zbins = z_edges #np.arange(0.,3.5,0.5) for zleft, zright in zip(zbins[:-1], zbins[1:]): zcent = (zleft + zright) / 2. xerr = (zright - zleft) / 2. N = Nofzs[np.logical_and(zrange > zleft, zrange <= zright)].sum() print(zcent, N) testcount += N N2 = Nz[np.logical_and(zrange > zleft, zrange <= zright)].sum() currentAxis.add_patch( Rectangle((zcent - xerr + pad, 0), 2 * xerr - pad / 2., N, facecolor=col)) #,alpha=0.5)) #currentAxis.add_patch(Rectangle((zcent - xerr+pad+pad/3., 0), 2*xerr-pad/2., N2, facecolor=col)) pl.add([0, 0], [0, 0], ls='-', linewidth=4, label=expName, color=col) massSense = lndM #*100./np.sqrt(Nmz) massSense = interpolate_grid( massSense, masses, zrange, 10**mexp_new, z_new, regular=True) #,kind="cubic",bounds_error=False,fill_value=np.inf) print((massSense.shape), testcount) fsense = massSense / np.sqrt(rn) pl.legend(labsize=9, loc='upper right') pl._ax.set_ylim(1, 5.e4) # fsky pl._ax.set_xlim(0., 3.) pl.done(outDir + "clNofz.pdf") fsense[fsense > 10.] = np.nan from orphics.io import Plotter import os
totAllInputPower = totAllInputPower + rcvTotInputPower for i,polComb in enumerate(polCombList): print(("Waiting for ", job ," ", polComb," cross")) comm.Recv(rcvInputPowerMat, source=job, tag=i) listAllCrossPower[polComb] = np.vstack((listAllCrossPower[polComb],rcvInputPowerMat)) print(("Waiting for ", job ," ", polComb," auto")) comm.Recv(rcvInputPowerMat, source=job, tag=i+80) listAllReconPower[polComb] = np.vstack((listAllReconPower[polComb],rcvInputPowerMat)) statsCross = {} statsRecon = {} pl = Plotter(scaleY='log') pl.add(ellkk,Clkk,color='black',lw=2) for polComb,col in zip(polCombList,colorList): statsCross[polComb] = get_stats(listAllCrossPower[polComb]) pl.addErr(centers,statsCross[polComb]['mean'],yerr=statsCross[polComb]['errmean'],ls="none",marker="o",markersize=8,label="recon x input "+polComb,color=col,mew=2,elinewidth=2) statsRecon[polComb] = get_stats(listAllReconPower[polComb]) fp = interp1d(centers,statsRecon[polComb]['mean'],fill_value='extrapolate') pl.add(ellkk,(fp(ellkk))-Clkk,color=col,lw=2) Nlkk2d = qest.N.Nlkk[polComb] ncents, npow = stats.bin_in_annuli(Nlkk2d, p2d.modLMap, bin_edges) pl.add(ncents,npow,color=col,lw=2,ls="--")
for step,col in zip(stepList,colList): dRoot = cambRoot+"forDerivsStep"+step for z in zrange: khup,Pup = np.loadtxt(dRoot+"Up_matterpower_"+str(z)+".dat",unpack=True) khdn,Pdn = np.loadtxt(dRoot+"Dn_matterpower_"+str(z)+".dat",unpack=True) assert np.all(np.isclose(khup,khdn)) stepF = float(step) dP = old_div((Pup-Pdn),stepF) #if z<2.5: continue if z>0.2: continue #alph = 1.-z/3.0 alph = 1. pl.add(khup,-dP,color=col,alpha=alph) pl.add(khup,-dP*0.,color=col,alpha=1.,ls="-",label=step) pl.legendOn() pl.done(os.environ['WWW']+"dps.png") 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)
mmins.append(mmin) mmaxes.append(mmax) zmins.append(zmin) zmaxes.append(zmax) dms.append(min(np.diff(mexpgrid))) dzs.append(min(np.diff(zgrid))) sngrid = old_div(1.,errgrid) print(sngrid.shape) for ind in mindicesList: if "CMB" in lab: labadd = '{:02.1f}'.format(old_div(10**(mexpgrid[ind]),1e14))+" $10^{14} M_{\odot}/h$" else: labadd = None pl.add(zgrid,sngrid[ind,:].ravel(),ls=ls,label=labadd) print(mexpgrid[ind]) rtol = 1.e-3 plt.gca().set_color_cycle(None) print(outmgrid[0],outmgrid[-1],outmgrid.shape) print(outzgrid[0],outzgrid[-1],outzgrid.shape) from orphics.maps import interpolateGrid jointgridsqinv = 0. for key in grids: inmgrid,inzgrid,inerrgrid = grids[key] outerrgrid = interpolateGrid(inerrgrid,inmgrid,inzgrid,outmgrid,outzgrid,regular=False,kind="cubic",bounds_error=False,fill_value=np.inf)
xerrs.append(xerr) s8now = np.mean(s81zs[np.logical_and(zrange >= zleft, zrange < zright)]) print(lab, zleft, zright, yerr, s8now, yerr * 100. / s8now, "%") #s8now = np.mean(s81zs[np.logical_and(zrange>=zleft,zrange<zright)])/s81 #yerrsq = (1./sum([1/x**2. for x in errselect])) #yerr = (s8now/s80mean)*np.sqrt(yerrsq/s8now**2. + yerrsq0/s80mean**2.) errcents.append(yerr) ms8.append(s8now) currentAxis.add_patch( Rectangle((zcent - xerr + pad, 1. - old_div(yerr, s8now)), 2 * xerr - old_div(pad, 2.), 2. * yerr / s8now, facecolor=col)) print("=====================") pl._ax.fill_between(zrange, 1., 1., label=lab, alpha=0.75, color=col) #pl.add(zrange,s82zs/s81zs,label="$w=-0.97$",color='red',alpha=0.5) pl.add(zrange, old_div(s81zs, s81zs), color='black', alpha=0.5, ls="--") #,label="$w=-1$") # pl.add(zrange,s82zs/s81zs/s82*s81,label="$w=-0.97$",color='red',alpha=0.5) # pl.add(zrange,s81zs*0.+1.,label="$w=-1$",color='black',alpha=0.5,ls="--") pl.legendOn(labsize=9) #pl._ax.set_ylim(0.9,1.1) # res #pl._ax.set_ylim(0.95,1.05) # fsky #pl._ax.text(0.8,.82,"Madhavacheril et. al. in prep") pl.done(outDir + "S4_" + cal + "_fsky.png") #pl.done(outDir+"s8SO.png")
pad_width=((0, numLeft), (0, numLeft)), mode="constant", constant_values=0.) FisherTot = Fisher + fisherPlanck FisherTot += fisherBAO Finv = np.linalg.inv(FisherTot) errs = np.sqrt(np.diagonal(Finv)) errDict = {} for i, param in enumerate(paramList): errDict[param] = errs[i] if fishName == 'mnu': constraint = errDict[fishName] * 1000 elif fishName == 'w0': constraint = errDict[fishName] * 100 sigs.append(constraint) if (np.abs(preVal - constraint) * 100. / constraint) < pertol: print((constraint - preVal) * 100. / constraint) if k > mink: break preVal = constraint print(prior, val, constraint) k += 1 priorLabel = paramLatexList[paramList.index(prior)] pl.add(xs, sigs, label="$" + priorLabel + "$") pl.legendOn(loc='upper right', labsize=8) pl.done(os.environ['WWW'] + "plots/priors_" + fishName + ".pdf")
# pl.add(ellBBRange,clbbnow*ellBBRange**2.) # pl.add(ellbb,dlbb*ellbb**2.) # # pl._ax.set_ylim(-max(Clkk),max(Clkk)) # pl.done("clbb.png") fflbb = interp1d(range(len(fCls[:,2])),rExp*fCls[:,2]/rInFid,bounds_error=False,fill_value=np.inf) fdCls = interp1d(range(len(dCls[:,2])),dCls[:,2],bounds_error=False,fill_value=np.inf) from orphics.io import Plotter ells = np.arange(0,len(fidCls[:,0]),1) clee = fidCls[:,1] clbb = fidCls[:,2] nlbbsmall = fnBBSmall(ells) pl = Plotter(yscale='log') pl.add(ells,clee*ells*(ells+1.)/2./np.pi) pl.add(ells,clbb*ells*(ells+1.)/2./np.pi) pl.add(ells,nlbbsmall*ells*(ells+1.)/2./np.pi) pl.done("cls.png") fclbbTot = lambda x: fclbb(x)*(1.+fgPer/100.) r0 = rSigma(fsky,ellBBRange,fnBBSmall,fdCls,fclbbTot,fflbb) cprint("sigma(r) without delensing: "+ str(r0*1e4)+"e-4",color="green",bold=True) rs.append(r0) fdlbb = cosmology.noise_pad_infinity(interp1d(ellbb,dlbb*TCMB**2.,fill_value=np.inf,bounds_error=False),spellmin,spellmax) fclbbTot = lambda x: fdlbb(x)+fclbb(x)*fgPer/100. r = rSigma(fsky,ellBBRange,fnBBSmall,fdCls,fclbbTot,fflbb) cprint("sigma(r) with delensing: "+ str(r*1e4)+"e-4",color="green",bold=True)