def _get_response(comp,param_override=None): if bandpasses: if no_act_color_correction: r = tfg.get_mix_bandpassed(bps, comp, bandpass_shifts=shifts, param_dict_override=param_override) else: r = tfg.get_mix_bandpassed(bps, comp, bandpass_shifts=shifts, ccor_cen_nus=cfreqs, ccor_beams=lbeams, ccor_exps = [ccor_exp] * narrays, param_dict_override=param_override) else: r = tfg.get_mix(bps, comp,param_dict_override=param_override) return r
def ffunc(nu,comp): if comp=='tSZ' or comp=='CIB': return tfg.get_mix(nu,comp)[0] elif comp=='rad': return sfg.rad_ps_nu(nu)
from soapack import interfaces as sints fg = 'tSZ' def ffunc(nu,comp): if comp=='tSZ' or comp=='CIB': return tfg.get_mix(nu,comp)[0] elif comp=='rad': return sfg.rad_ps_nu(nu) nus = np.geomspace(25,600,1000) srad = sfg.rad_ps_nu(nus) tsz = tfg.get_mix(nus,'tSZ')/1e6 tdust = tfg.get_mix(nus,'CIB')/tfg.get_mix(150,'CIB') sdust = sfg.cib_nu(nus)/sfg.cib_nu(150) ssz = sfg.ffunc(nus)*2.725 pl = io.Plotter(xyscale='loglog',xlabel='$\\nu$ (GHz)',ylabel='$f(\\nu)$',figsize=(6,3)) pl.add(nus,srad,label='Synchrotron',color='C0') nnus = nus[tsz<=0] ntsz = tsz[tsz<=0] pnus = nus[tsz>0] ptsz = tsz[tsz>0]
def __init__(self,qids,fg_res_version=None,ellmax=8101,bandpassed=True,no_act_color_correction=False,ccor_exp=-1): self.qids = qids self.alms = {} ells = np.arange(ellmax) self.ellmax = ellmax self.cyy = fgs.power_y(ells)[None,None] self.cyy[0,0][ells<2] = 0 narrays = len(qids) if fg_res_version is not None: fpath = sints.dconfig['actsims']['fg_res_path'] + "/" + fg_res_version + "/" self.cfgres = np.zeros((narrays,narrays,ellmax)) for i in range(narrays): for j in range(i,narrays): qid1 = qids[i] qid2 = qids[j] clfilename = "%shfgcov_%s_%s.txt" % (fpath,qid1,qid2) #!!!! Changed fgcov to hfgcov # !!!! clfilename_alt = "%shfgcov_%s_%s.txt" % (fpath,qid2,qid1) #!!!! Changed fgcov to hfgcov try: ls,cls = np.loadtxt(clfilename,unpack=True) except: ls,cls = np.loadtxt(clfilename_alt,unpack=True) assert np.all(np.isclose(ls,ells)) self.cfgres[i,j] = cls.copy() if i!=j: self.cfgres[j,i] = cls.copy() # self.cfgres[j,i] = self.cfgres[i,j] = cls.copy()*0 # !!!! REMOVED CORR #if (qid1 in ['p01','p02']) or (qid2 in ['p01','p02']): self.cfgres[j,i] = self.cfgres[i,j] = 0 # !!!! # self.cfgres[j,i][ls<300] = self.cfgres[i,j][ls<300] = 0 # !!!! else: self.cfgres = None # get tSZ response, and also zero out parts of map that are not observed aspecs = tutils.ASpecs().get_specs bps = [] cfreqs = [] lbeams = [] ells = np.arange(0,35000) for qid in qids: dm = sints.models[sints.arrays(qid,'data_model')]() if dm.name=='act_mr3': season,array1,array2 = sints.arrays(qid,'season'),sints.arrays(qid,'array'),sints.arrays(qid,'freq') array = '_'.join([array1,array2]) lbeam = tutils.get_kbeam(qid,ells,sanitize=True,planck_pixwin=False) # note no pixwin but doesnt matter since no ccorr for planck elif dm.name=='planck_hybrid': season,patch,array = None,None,sints.arrays(qid,'freq') lbeam = None else: raise ValueError lbeams.append(lbeam) lmin,lmax,hybrid,radial,friend,cfreq,fgroup,wrfit = aspecs(qid) if bandpassed: bps.append("data/"+dm.get_bandpass_file_name(array)) else: bps.append(cfreq) cfreqs.append(cfreq) if bandpassed: if no_act_color_correction: self.tsz_fnu = tfg.get_mix_bandpassed(bps, 'tSZ') else: self.tsz_fnu = tfg.get_mix_bandpassed(bps, 'tSZ', ccor_cen_nus=cfreqs, ccor_beams=lbeams, ccor_exps = [ccor_exp] * narrays) else: self.tsz_fnu = tfg.get_mix(bps, 'tSZ')
bnus = bnus / bnus[:,:1] pl = io.Plotter(xlabel='l',ylabel='b') for i in range(bnus.shape[0]): if trans[i]>1e-1: pl.add(ells,bnus[i]/lbeam) pl.hline(y=1) pl._ax.set_ylim(0.8,1.2) pl.done("abeams_%s.png" % qid) mixc = tfg.get_mix(cfreq, comp) mix = tfg.get_mix(nu_ghz, comp) mix2 = np.trapz(trans * tfg.dBnudT(nu_ghz) * mix, nu_ghz) / np.trapz(trans * tfg.dBnudT(nu_ghz), nu_ghz) mix3 = np.trapz(trans * tfg.dBnudT(nu_ghz) * bnus.swapaxes(0,1) * mix, nu_ghz) / np.trapz(trans * tfg.dBnudT(nu_ghz), nu_ghz) / lbeam print(qid,mixc,mix2,mix3[300]) if qid in ['p01','p02']: lmax = 300 elif 'p' in qid: lmax = 3000 else: lmax = 10000 pl = io.Plotter(xyscale='linlin',xlabel='l',ylabel='r') pl.add(ells[ells<lmax],(mixc/mix2+0*ells)[ells<lmax],label='cfreq approx') pl.add(ells[ells<lmax],(mix3/mix2)[ells<lmax],label='color corrected')
def build_and_save_ilc(arrays,region,version,cov_version,beam_version, solutions,beams,chunk_size, effective_freq,overwrite,maxval,unsanitized_beam=False,do_weights=False, pa1_shift = None, pa2_shift = None, pa3_150_shift = None, pa3_090_shift = None, no_act_color_correction=False, ccor_exp = -1, isotropize=False, isotropize_width=20): print("Chunk size is ", chunk_size*64./8./1024./1024./1024., " GB.") def warn(): print("WARNING: no bandpass file found. Assuming array ",dm.c['id']," has no response to CMB, tSZ and CIB.") aspecs = tutils.ASpecs().get_specs bandpasses = not(effective_freq) savedir = tutils.get_save_path(version,region) covdir = tutils.get_save_path(cov_version,region) assert os.path.exists(covdir) if not(overwrite): assert not(os.path.exists(savedir)), \ "This version already exists on disk. Please use a different version identifier." try: os.makedirs(savedir) except: if overwrite: pass else: raise mask = enmap.read_map(covdir+"tilec_mask.fits") shape,wcs = mask.shape,mask.wcs Ny,Nx = shape modlmap = enmap.modlmap(shape,wcs) arrays = arrays.split(',') narrays = len(arrays) kcoadds = [] kbeams = [] bps = [] names = [] lmins = [] lmaxs = [] shifts = [] cfreqs = [] lbeams = [] ells = np.arange(0,modlmap.max()) for i,qid in enumerate(arrays): dm = sints.models[sints.arrays(qid,'data_model')](region=mask,calibrated=True) lmin,lmax,hybrid,radial,friend,cfreq,fgroup,wrfit = aspecs(qid) cfreqs.append(cfreq) lmins.append(lmin) lmaxs.append(lmax) names.append(qid) if dm.name=='act_mr3': season,array1,array2 = sints.arrays(qid,'season'),sints.arrays(qid,'array'),sints.arrays(qid,'freq') array = '_'.join([array1,array2]) elif dm.name=='planck_hybrid': season,patch,array = None,None,sints.arrays(qid,'freq') else: raise ValueError kcoadd_name = covdir + "kcoadd_%s.npy" % qid kmask = maps.mask_kspace(shape,wcs,lmin=lmin,lmax=lmax) kcoadd = enmap.enmap(np.load(kcoadd_name),wcs) dtype = kcoadd.dtype kcoadds.append(kcoadd.copy()*kmask) kbeam = tutils.get_kbeam(qid,modlmap,sanitize=not(unsanitized_beam),version=beam_version,planck_pixwin=True) if dm.name=='act_mr3': lbeam = tutils.get_kbeam(qid,ells,sanitize=not(unsanitized_beam),version=beam_version,planck_pixwin=False) # note no pixwin but doesnt matter since no ccorr for planck elif dm.name=='planck_hybrid': lbeam = None else: raise ValueError lbeams.append(lbeam) kbeams.append(kbeam.copy()) if bandpasses: try: fname = dm.get_bandpass_file_name(array) bps.append("data/"+fname) if (pa1_shift is not None) and 'PA1' in fname: shifts.append(pa1_shift) elif (pa2_shift is not None) and 'PA2' in fname: shifts.append(pa2_shift) elif (pa3_150_shift is not None) and ('PA3' in fname) and ('150' in fname): shifts.append(pa3_150_shift) elif (pa3_090_shift is not None) and ('PA3' in fname) and ('090' in fname): shifts.append(pa3_90_shift) else: shifts.append(0) except: warn() bps.append(None) else: try: bps.append(cfreq) except: warn() bps.append(None) kcoadds = enmap.enmap(np.stack(kcoadds),wcs) # Read Covmat cov = maps.SymMat(narrays,shape[-2:]) for aindex1 in range(narrays): for aindex2 in range(aindex1,narrays): icov = enmap.enmap(np.load(covdir+"tilec_hybrid_covariance_%s_%s.npy" % (names[aindex1],names[aindex2])),wcs) if isotropize: bin_edges = np.append([0.],np.arange(min(lmins),modlmap.max(),isotropize_width)) binner = stats.bin2D(modlmap,bin_edges) ls,c1d = binner.bin(icov) icov = maps.interp(ls,c1d)(modlmap) if aindex1==aindex2: icov[modlmap<lmins[aindex1]] = maxval icov[modlmap>lmaxs[aindex1]] = maxval cov[aindex1,aindex2] = icov cov.data = enmap.enmap(cov.data,wcs,copy=False) covfunc = lambda sel: cov.to_array(sel,flatten=True) assert cov.data.shape[0]==((narrays*(narrays+1))/2) # FIXME: generalize assert np.all(np.isfinite(cov.data)) # Make responses responses = {} for comp in ['tSZ','CMB','CIB']: if bandpasses: if no_act_color_correction: responses[comp] = tfg.get_mix_bandpassed(bps, comp, bandpass_shifts=shifts) else: responses[comp] = tfg.get_mix_bandpassed(bps, comp, bandpass_shifts=shifts, ccor_cen_nus=cfreqs, ccor_beams=lbeams, ccor_exps = [ccor_exp] * narrays) else: responses[comp] = tfg.get_mix(bps, comp) ilcgen = ilc.chunked_ilc(modlmap,np.stack(kbeams),covfunc,chunk_size,responses=responses,invert=True) # Initialize containers solutions = solutions.split(',') data = {} kcoadds = kcoadds.reshape((narrays,Ny*Nx)) for solution in solutions: data[solution] = {} comps = solution.split('-') data[solution]['comps'] = comps if len(comps)<=2: data[solution]['noise'] = enmap.zeros((Ny*Nx),wcs) if len(comps)==2: data[solution]['cnoise'] = enmap.zeros((Ny*Nx),wcs) data[solution]['kmap'] = enmap.zeros((Ny*Nx),wcs,dtype=dtype) # FIXME: reduce dtype? if do_weights and len(comps)<=2: for qid in arrays: data[solution]['weight_%s' % qid] = enmap.zeros((Ny*Nx),wcs) for chunknum,(hilc,selchunk) in enumerate(ilcgen): print("ILC on chunk ", chunknum+1, " / ",int(modlmap.size/chunk_size)+1," ...") for solution in solutions: comps = data[solution]['comps'] if len(comps)==1: # GENERALIZE data[solution]['noise'][selchunk] = hilc.standard_noise(comps[0]) if do_weights: weight = hilc.standard_weight(comps[0]) data[solution]['kmap'][selchunk] = hilc.standard_map(kcoadds[...,selchunk],comps[0]) elif len(comps)==2: data[solution]['noise'][selchunk] = hilc.constrained_noise(comps[0],comps[1]) data[solution]['cnoise'][selchunk] = hilc.cross_noise(comps[0],comps[1]) ret = hilc.constrained_map(kcoadds[...,selchunk],comps[0],comps[1],return_weight=do_weights) if do_weights: data[solution]['kmap'][selchunk],weight = ret else: data[solution]['kmap'][selchunk] = ret elif len(comps)>2: data[solution]['kmap'][selchunk] = np.nan_to_num(hilc.multi_constrained_map(kcoadds[...,selchunk],comps[0],*comps[1:])) if len(comps)<=2 and do_weights: for qind,qid in enumerate(arrays): data[solution]['weight_%s' % qid][selchunk] = weight[qind] del ilcgen,cov # Reshape into maps name_map = {'CMB':'cmb','tSZ':'comptony','CIB':'cib'} beams = beams.split(',') for solution,beam in zip(solutions,beams): comps = "tilec_single_tile_"+region+"_" comps = comps + name_map[data[solution]['comps'][0]]+"_" if len(data[solution]['comps'])>1: comps = comps + "deprojects_"+ '_'.join([name_map[x] for x in data[solution]['comps'][1:]]) + "_" comps = comps + version if do_weights and len(data[solution]['comps'])<=2: for qind,qid in enumerate(arrays): enmap.write_map("%s/%s_%s_weight.fits" % (savedir,comps,qid), enmap.enmap(data[solution]['weight_%s' % qid].reshape((Ny,Nx)),wcs)) try: noise = enmap.enmap(data[solution]['noise'].reshape((Ny,Nx)),wcs) enmap.write_map("%s/%s_noise.fits" % (savedir,comps),noise) except: pass try: cnoise = enmap.enmap(data[solution]['cnoise'].reshape((Ny,Nx)),wcs) enmap.write_map("%s/%s_cross_noise.fits" % (savedir,comps),cnoise) except: pass ells = np.arange(0,modlmap.max(),1) try: fbeam = float(beam) kbeam = maps.gauss_beam(modlmap,fbeam) lbeam = maps.gauss_beam(ells,fbeam) except: qid = beam bfunc = lambda x: tutils.get_kbeam(qid,x,version=beam_version,sanitize=not(unsanitized_beam),planck_pixwin=False) kbeam = bfunc(modlmap) lbeam = bfunc(ells) kmap = enmap.enmap(data[solution]['kmap'].reshape((Ny,Nx)),wcs) smap = enmap.ifft(kbeam*kmap,normalize='phys').real enmap.write_map("%s/%s.fits" % (savedir,comps),smap) io.save_cols("%s/%s_beam.txt" % (savedir,comps),(ells,lbeam),header="ell beam") enmap.write_map(savedir+"/tilec_mask.fits",mask)
fout = fs fout[fs <= 0] = np.nan pl.add(nu, fout, color=col, label=comp + " or kSZ" if comp == 'CMB' else comp, alpha=alpha, zorder=0) pl._ax.xaxis.grid(True, which='both', alpha=0.3) pl._ax.yaxis.grid(True, which='both', alpha=0.5) pl._ax.set_axisbelow(True) for i, comp in enumerate(comps): fs = tfg.get_mix(nu, comp=comp) f0 = np.abs(tfg.get_mix(nu0, comp=comp)) col = "C%d" % i add_pl(i, fs, f0, alpha=1) if comp in ['tSZ', 'CIB']: qids = "boss_01,boss_02,boss_03,boss_04,p01,p02,p03,p04,p05,p06,p07,p08".split( ',') for qid in qids: lmin, lmax, hybrid, radial, friend, cfreq, fgroup, wrfit = aspecs( qid) dm = sints.models[sints.arrays(qid, 'data_model')]() if dm.name == 'act_mr3': season, array1, array2 = sints.arrays( qid, 'season'), sints.arrays(qid, 'array'), sints.arrays(
f0 = 100 acls = [] monos = {} ms = [] freqs = [] for i,f in enumerate(fs): freq = int(f.split('_')[1].split('.')[0]) # r = tfg.get_mix(f0, 'CIB_Jysr')/tfg.get_mix(freq, 'CIB_Jysr') imap = hp.read_map(f) _,mono = hp.remove_monopole(imap,fitval=True) monos[freq] = mono ms.append(mono) freqs.append(freq) io.save_cols("cib_monopoles.txt",(freqs,ms)) pl = io.Plotter(xyscale='loglin',xlabel='f',ylabel='m/m0') for freq in monos.keys(): r = tfg.get_mix(f0, 'CIB_Jysr')/tfg.get_mix(freq, 'CIB_Jysr')/monos[f0] pl._ax.scatter(freq,monos[freq]*r,color="C0") pl.hline(y=1) pl.done("mono_webskycib.png")
freqs = [] kcoadds = [] for i, array in enumerate(c.arrays): freqs.append(c.darrays[array]['freq']) kbeams.append(c.get_beam(modlmap, array)) kcoadds.append(c.load(i, skip_splits=True)[1].copy()) kcoadds = enmap.enmap(np.stack(kcoadds), c.wcs) chunk_size = 1000000 theory = cosmology.default_theory() cov = enmap.read_map("output/datacov.hdf") cov = maps.symmat_from_data(cov) tcmb = 2.726e6 yresponses = tfg.get_mix(freqs, "tSZ") cresponses = tfg.get_mix(freqs, "CMB") dresponses = tfg.get_mix(freqs, "CIB") responses = {'tsz': yresponses, 'cmb': cresponses, 'dust': dresponses} ilcgen = ilc.chunked_ilc(modlmap, np.stack(kbeams), cov, chunk_size, responses=responses, invert=True) snoise = enmap.empty((Ny * Nx), wcs) cnoise = enmap.empty((Ny * Nx), wcs) smap = enmap.empty((Ny * Nx), wcs, dtype=np.complex128) cmap = enmap.empty((Ny * Nx), wcs, dtype=np.complex128)
for i in xrange(N_freqs): print("----------") print(LFI_freqs[i]) LFI_files.append('../data/LFI_BANDPASS_F' + LFI_freqs[i] + '_reformat.txt') LFI_loc = np.loadtxt(LFI_files[i]) # check norm, i.e., make sure response is unity for CMB LFI_loc_GHz = LFI_loc[:, 0] LFI_loc_trans = LFI_loc[:, 1] print("CMB norm = ", np.trapz(LFI_loc_trans, LFI_loc_GHz)) # compute K_CMB -> y_SZ conversion print( "K_CMB -> y_SZ conversion: ", np.trapz(LFI_loc_trans * dBnudT(LFI_loc_GHz) * 1.e6, LFI_loc_GHz) / np.trapz( LFI_loc_trans * dBnudT(LFI_loc_GHz) * 1.e6 * get_mix(LFI_loc_GHz, 'tSZ') / TCMB_uK, LFI_loc_GHz) / TCMB) # compute K_CMB -> MJy/sr conversion [IRAS convention, alpha=-1 power-law SED] print( "K_CMB -> MJy/sr conversion [IRAS convention, alpha=-1 power-law SED]: ", np.trapz(LFI_loc_trans * dBnudT(LFI_loc_GHz) * 1.e6, LFI_loc_GHz) / np.trapz(LFI_loc_trans * (LFI_freqs_GHz[i] / LFI_loc_GHz), LFI_loc_GHz) * 1.e20) # compute color correction from IRAS to "dust" (power-law with alpha=4) print( "MJy/sr color correction (power-law, alpha=-1 to alpha=4): ", np.trapz(LFI_loc_trans * (LFI_freqs_GHz[i] / LFI_loc_GHz), LFI_loc_GHz) / np.trapz(LFI_loc_trans * (LFI_loc_GHz / LFI_freqs_GHz[i])**4.0, LFI_loc_GHz)) # compute color correction from IRAS to modified blackbody with T=13.6 K, beta=1.4 (to compare to results at https://wiki.cosmos.esa.int/planckpla2015/index.php/UC_CC_Tables ) print(
# effective frequency for CMB -- following Rahul's notebook nu_be_CMB = dBnudT(ACT_loc_GHz) * TCMB_uK nu_eff_CMB1 = np.sum( nu * fnu * nu**(-2. * (1. + al_1)) * nu_be_CMB * dnu) / np.sum( fnu * nu**(-2. * (1. + al_1)) * nu_be_CMB * dnu) nu_eff_CMB2 = np.sum( nu * fnu * nu**(-2. * (1. + al_2)) * nu_be_CMB * dnu) / np.sum( fnu * nu**(-2. * (1. + al_2)) * nu_be_CMB * dnu) nu_eff_CMB = 0.5 * (nu_eff_CMB1 + nu_eff_CMB2) print('nu_eff_CMB1 =', "{0:.1f}".format(nu_eff_CMB1 / 1.e9)) print('nu_eff_CMB2 =', "{0:.1f}".format(nu_eff_CMB2 / 1.e9)) print('nu_eff_CMB =', "{0:.1f}".format(nu_eff_CMB / 1.e9), '+/-', 2.4, 'GHz' ) #uncertainty is due to systematic uncertainty in FTS measurements # effective frequency for tSZ -- following Rahul's notebook nu_be_SZ = nu_be_CMB * get_mix(ACT_loc_GHz, 'tSZ') / TCMB_uK nu_eff_SZ1 = np.sum(nu * fnu * nu**(-2. * (1. + al_1)) * nu_be_SZ * dnu) / np.sum(fnu * nu**(-2. * (1. + al_1)) * nu_be_SZ * dnu) nu_eff_SZ2 = np.sum(nu * fnu * nu**(-2. * (1. + al_2)) * nu_be_SZ * dnu) / np.sum(fnu * nu**(-2. * (1. + al_2)) * nu_be_SZ * dnu) nu_eff_SZ = 0.5 * (nu_eff_SZ1 + nu_eff_SZ2) print('nu_eff_SZ1 =', "{0:.1f}".format(nu_eff_SZ1 / 1.e9)) print('nu_eff_SZ2 =', "{0:.1f}".format(nu_eff_SZ2 / 1.e9)) print('nu_eff_SZ =', "{0:.1f}".format(nu_eff_SZ / 1.e9), '+/-', 2.4, 'GHz') # compute K_CMB -> y_SZ conversion print( "K_CMB -> y_SZ conversion: ", np.trapz(ACT_loc_trans * dBnudT(ACT_loc_GHz) * 1.e6, ACT_loc_GHz) / np.trapz(
from orphics import maps, io, cosmology from pixell import enmap import numpy as np import os, sys from soapack import interfaces as sints import healpy as hp from tilec import fg as tfg import glob for freq in [30, 44, 70, 100, 143, 217, 353, 545, 857]: v1 = tfg.get_mix_bandpassed([ glob.glob('data/*_BANDPASS_F%s_reformat.txt' % str(freq).zfill(3))[0] ], 'CIB', normalize_cib=False) v2 = tfg.get_mix(freq, 'CIB_Jysr') v3 = tfg.get_mix(freq, 'CIB') print(v1 / 1e26, v2 / 1e26, v3 / 1e26) sys.exit() # print(tfg.ItoDeltaT(545)) # sys.exit() lmax = 6000 #8192*3 cmb_set = 0 nu_ghz = 92 def get_cls(alms): calm = maps.change_alm_lmax(alms, lmax) cls = hp.alm2cl(calm) ls = np.arange(len(cls))
from soapack import interfaces as sints import healpy as hp from tilec import fg as tfg afreqs, anis = np.loadtxt(os.environ['WORK'] + "/cib_anis.txt", unpack=True) mfreqs, ms = np.loadtxt("cib_monopoles.txt", unpack=True) #afreqs,ms,anis = np.loadtxt(os.environ['WORK'] + "/new_cib.txt",unpack=True) #mfreqs = afreqs anis = np.sqrt(anis) / np.sqrt(anis[np.isclose(afreqs, 100)]) ms = ms / ms[np.isclose(mfreqs, 100)] print(anis) print(ms) fs = np.geomspace(10, 2000, 1000) th = tfg.get_mix(fs, 'CIB_Jysr') / tfg.get_mix(100, 'CIB_Jysr') p = {'Tdust_CIB': 13.6, 'beta_CIB': 1.4, 'nu0_CIB_ghz': 353.0} th2 = tfg.get_mix(fs, 'CIB_Jysr', param_dict_override=p) / tfg.get_mix( 100, 'CIB_Jysr', param_dict_override=p) pl = io.Plotter(xyscale='loglog', xlabel='f', ylabel='m/m0') pl._ax.scatter(afreqs, anis, color="C0", label='anis') pl._ax.scatter(mfreqs, ms, color="C1", label='mono') pl.add(fs, th, color="C2") pl.add(fs, th2, color="C3") pl.legend() pl._ax.set_xlim(10, 2000) pl.done("comp_webskycib.png")
print(HFI_freqs[i]) HFI_files.append('../data/HFI_BANDPASS_F' + HFI_freqs[i] + '_reformat.txt') HFI_loc = np.loadtxt(HFI_files[i]) # check norm, i.e., make sure response is unity for CMB HFI_loc_GHz = HFI_loc[:, 0] HFI_loc_trans = HFI_loc[:, 1] print("CMB norm = ", np.trapz(HFI_loc_trans, HFI_loc_GHz)) # check various conversions against Table 6 of https://arxiv.org/pdf/1303.5070.pdf # N.B.: uncertainties on these conversions are ~<0.1% for 100/143/217/353/545, and ~1% for 857 GHz (larger uncertainty for 857 is because the conversions strongly depend on low-freq tail of the bandpass in this case, which is less well-measured) # compute K_CMB -> y_SZ conversion print( "K_CMB -> y_SZ conversion: ", np.trapz(HFI_loc_trans * dBnudT(HFI_loc_GHz) * 1.e6, HFI_loc_GHz) / np.trapz( HFI_loc_trans * dBnudT(HFI_loc_GHz) * 1.e6 * get_mix(HFI_loc_GHz, 'tSZ') / TCMB_uK, HFI_loc_GHz) / TCMB) # compute K_CMB -> MJy/sr conversion [IRAS convention, alpha=-1 power-law SED] print( "K_CMB -> MJy/sr conversion [IRAS convention, alpha=-1 power-law SED]: ", np.trapz(HFI_loc_trans * dBnudT(HFI_loc_GHz) * 1.e6, HFI_loc_GHz) / np.trapz(HFI_loc_trans * (HFI_freqs_GHz[i] / HFI_loc_GHz), HFI_loc_GHz) * 1.e20) # compute color correction from IRAS to "dust" (power-law with alpha=4) print( "MJy/sr color correction (power-law, alpha=-1 to alpha=4): ", np.trapz(HFI_loc_trans * (HFI_freqs_GHz[i] / HFI_loc_GHz), HFI_loc_GHz) / np.trapz(HFI_loc_trans * (HFI_loc_GHz / HFI_freqs_GHz[i])**4.0, HFI_loc_GHz)) # compute color correction from IRAS to modified blackbody with T=13.6 K, beta=1.4 (to compare to results at https://wiki.cosmos.esa.int/planckpla2015/index.php/UC_CC_Tables ) print(
cov.data = enmap.enmap(cov.data, ewcs, copy=False) covfunc = lambda sel: cov.to_array(sel, flatten=True) assert cov.data.shape[0] == ( (narrays * (narrays + 1)) / 2) # FIXME: generalize assert np.all(np.isfinite(cov.data)) # bps, kbeams, # Make responses responses = {} for comp in ['tSZ', 'CMB', 'CIB']: if bandpasses: responses[comp] = tfg.get_mix_bandpassed(bps, comp) else: responses[comp] = tfg.get_mix(bps, comp) ilcgen = ilc.chunked_ilc(modlmap, np.stack(kbeams), covfunc, chunk_size, responses=responses, invert=True) Ny, Nx = eshape[-2:] # Initialize containers data = {} for qind, qid in enumerate(aids): lmin = lmins[qind] lmax = lmaxs[qind] kmask = maps.mask_kspace(eshape, ewcs, lmin=lmin, lmax=lmax)
nu_fid_ghz = [148.] T_fid_uK = [1.] # evaluate components over a range of frequencies nu_min_ghz = 10. nu_max_ghz = 1000. nu_step = 1. nu_ghz = np.arange(nu_min_ghz, nu_max_ghz + nu_step / 10., nu_step) # plot examples # CMB temperature units plt.clf() plt.xlim(nu_min_ghz, nu_max_ghz) plt.ylim(1.e-2, 1.e3) plt.loglog(nu_ghz, T_fid_uK * get_mix(nu_ghz, 'CMB') / get_mix(nu_fid_ghz, 'CMB'), label='CMB', lw=2., ls='-') plt.loglog(nu_ghz, np.absolute(T_fid_uK * get_mix(nu_ghz, 'tSZ') / get_mix(nu_fid_ghz, 'tSZ')), label='tSZ', lw=2., ls='--') # need absolute value due to negative values at nu<217 GHz plt.loglog( nu_ghz, np.absolute(T_fid_uK * get_mix(nu_ghz, 'rSZ') / get_mix(nu_fid_ghz, 'rSZ')), label=r'rSZ ($kT_e = 5$ keV)', lw=2.,
lmaxs=lmaxs, atmosphere=atmosphere, lensing=lensing, dust=dust, do_fgs=fgs, lpass=lpass, aseed=aseed) modlmap = tsim.modlmap fc = maps.FourierCalc(tsim.shape, tsim.wcs) narrays = len(tsim.arrays) iells = modlmap[modlmap < lmax1].reshape(-1) # unraveled disk nells = iells.size Ny, Nx = shape[-2:] tcmb = 2.726e6 yresponses = tfg.get_mix(tsim.freqs, "tSZ") cresponses = tfg.get_mix(tsim.freqs, "CMB") minell = maps.minimum_ell(tsim.shape, tsim.wcs) bin_edges = np.arange(np.min(lmins), lmax - 50, 8 * minell) binner = stats.bin2D(modlmap, bin_edges) cents = binner.centers # Only do hybrid treatment for arrays with more than 2 splits (ACT) -- now doing for Planck as well anisotropic_pairs = [] if not (noise_isotropic): for aindex1 in range(narrays): nsplits1 = tsim.nsplits[aindex1] if True: anisotropic_pairs.append((aindex1, aindex1)) if analytic: