def apply_cmb_foreground_block(dc, dm, dt, dk=None): """ Apply the CMB x (Monopole + TSZ + KSZ) terms in one block: (A^T N^-1 A T) x_mono (A^T N^-1 A F) x_tsz (A^T N^-1 A K) x_ksz (T^T A^T N^-1 A) x_cmb (F^T A^T N^-1 A) x_cmb (K^T A^T N^-1 A) x_cmb """ ksz = False if dk is not None: ksz = True # (A^T N^-1 A T) x_mono; (A^T N^-1 A F) x_tsz; (A^T N^-1 A K) x_ksz b_lt = 0; b_lk = 0; b_lm = 0 for f in range(nFreq): mct = 0; mck = 0 for ic in range(nCluster): mct += dt[ic] * ninvs[f] * clumaps[0][ic][f] * g_nu[f] if ksz: mck += dk[ic] * ninvs[f] * clumaps[1][ic][f] b_lm += fft.rfft(dm * ninvs[f],axes=[-2,-1]) * beam_prec[f] b_lt += fft.rfft(mct,axes=[-2,-1]) * beam_prec[f] if ksz: b_lk += fft.rfft(mck,axes=[-2,-1]) * beam_prec[f] mcm = fft.irfft(b_lm,axes=[-2,-1],normalize=True).reshape((nx*ny,)) mct = fft.irfft(b_lt,axes=[-2,-1],normalize=True).reshape((nx*ny,)) if ksz: mck = fft.irfft(b_lk,axes=[-2,-1],normalize=True).reshape((nx*ny,)) # (T^T A^T N^-1 A) x_cmb; (F^T A^T N^-1 A) x_cmb; (K^T A^T N^-1 A) x_cmb mc = dc.copy().reshape((nx,ny)) a_l = fft.rfft(mc,axes=[-2,-1]) mtc = numpy.zeros(nCluster) mkc = numpy.zeros(nCluster) mmc = 0 for f in range(nFreq): b_l = a_l * beam_prec[f] mc = fft.irfft(b_l,axes=[-2,-1],normalize=True) mmc += numpy.sum(mc * ninvs[f]) for ic in range(nCluster): mtc[ic] += numpy.sum(mc * ninvs[f] * clumaps[0][ic][f] * g_nu[f]) if ksz: mkc[ic] += numpy.sum(mc * ninvs[f] * clumaps[1][ic][f]) if ksz: return mct, mcm, mck, mtc, mmc, mkc return mct, mcm, mtc, mmc
def apply_cmb_cmb(d0): """ Apply (S^-1 + A N^-1 A) x """ d1 = d0.copy() d1 = numpy.reshape(d1,(nx,ny)) a_l = fft.rfft(d1,axes=[-2,-1]) c_l = 0 for f in range(nFreq): b_l = a_l * beam_prec[f] d2 = fft.irfft(b_l,axes=[-2,-1],normalize=True) d2 *= ninvs[f] b_l = fft.rfft(d2,axes=[-2,-1]) c_l += b_l * beam_prec[f] d2 = fft.irfft(c_l,axes=[-2,-1],normalize=True) d1 = fft.irfft(precond_2d**2 * a_l/power_2d,axes=[-2,-1],normalize=True) d2 += d1 return d2.reshape((nx*ny,))
import experiment p = experiment.p cosmo = experiment.cosmo mapDir = experiment.mapDir nsims = p['nsims'] nsamp = p['nsamp'] # Load data and instrumental specifications template, power_2d, beams, ninvs, freqs = fist.experiment_settings(p) # Speed up FFT by measuring #t=time.time() fft.rfft(ninvs[0].copy(),axes=[-2,-1],flags=['FFTW_MEASURE']) template_l = fft.fft(ninvs[0],axes=[-2,-1]) fft.irfft(template_l,axes=[-2,-1],flags=['FFTW_MEASURE']) #Create a directory for the results of the chain resultDir = fist.check_dir_exists('results') for n in range(nsims): datamaps=[] count=0 for k in freqs: datamaps+=[fist.litemap_from_fits(mapDir+'/data_%03d_%d.fits'%(n,k))] mask=fist.litemap_from_fits(mapDir+'/mask_%d.fits'%(k))