Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_delensed_amanda(tt_unlen, te_unlen, ee_unlen, lpp_theo, clpp_theo, L, N_L, klmin, klmax, load_dls=True, unit='uk', lmax_ret=8000):
- import camb.correlations
- import numpy as np
- kappa_lmin = int(klmin)
- kappa_lmax = int(klmax)
- reload(np) # necessary to call this function multiple times (?)
- # want theory to start at l = 0
- lpp_th = np.zeros(len(lpp_theo)+int(lpp_theo[0]))
- lpp_th[0] = 0.
- lpp_th[1] = 1.
- lpp_th[int(lpp_theo[0]):] = np.array(lpp_theo)
- # fill in unlensed theory and lensing potential
- clpp_th = np.zeros(len(lpp_th))
- tt_th = np.zeros(len(lpp_th))
- te_th = np.zeros(len(lpp_th))
- ee_th = np.zeros(len(lpp_th))
- idx = int(lpp_theo[0])
- clpp_th[idx:] = np.array(clpp_theo)
- tt_th[idx:] = np.array(tt_unlen)
- te_th[idx:] = np.array(te_unlen)
- ee_th[idx:] = np.array(ee_unlen)
- # fill in the noise curve so it also starts at L=0 and is same size as theory
- NL = np.zeros(lpp_th.shape)
- idx = int(L[0])
- NL[:idx] = np.inf
- if len(N_L) >= len(NL) + idx:
- NL[idx:] = np.array(N_L[:len(NL)+idx])
- else:
- NL[idx:len(N_L)+idx] = np.array(N_L)
- NL[len(N_L)+idx:] = np.inf
- L = lpp_th.copy()
- def _weiner1d_filter(signal, noise):
- return (signal/(signal+noise))*signal
- # get residual lensing potential
- clkk = clpp_th*(2*np.pi/4)
- clkk_filt = _weiner1d_filter(clkk, NL)
- clpp_filt = clkk_filt*4/(2*np.pi)
- loc = np.where(L > kappa_lmax)
- if len(loc[0]) > 0:
- if loc[0][0] > len(clpp_filt):
- clpp_filt[loc[0][0]:] = 0.
- loc = np.where(L < kappa_lmin)
- clpp_filt[loc] = 0.
- clpp_res = clpp_th-clpp_filt
- # create array to hold delensed spectra
- dls = np.zeros((len(lpp_th),4))
- dls[:,0] = tt_th
- dls[:,1] = ee_th
- dls[:,2] = np.zeros(len(tt_th))
- dls[:,3] = te_th
- reload(camb)
- reload(camb.correlations)
- camb_ret = camb.correlations.lensed_cls(dls, clpp_res, delta_cls=False, sampling_factor=2.)
- ret = {}
- ret['dltt'] = camb_ret[:,0]
- ret['dlee'] = camb_ret[:,1]
- ret['dlbb'] = camb_ret[:,2]
- ret['dlte'] = camb_ret[:,3]
- return ret['dltt'][1:], ret['dlte'][1:], ret['dlee'][1:]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement