Exemple #1
0
def get_fiducial_sim_lib(path_to_libs = None):
    from fslens.sims import sims
    import sims_generic
    import covmatrices
    import likelihoods
    import displacements as dp
    from fslens.misc import jc_camb as camb
    # Needs about 748 sim to 4pi surface with this params.
    # Let's do twice as much.

    """
    There is a trade-off between high resolution and number of iteration in the conjugate gradient.
    If the resolution is lower each step is  much faster but the inacuracy in the inverse maping drives the erros
    and make it need a higher number of iterates.
    E.g. for PL2015 params, with res 8 I need 50 iterate , done in 5 sec total.
    with res 9 I ned 20 iterates, done in 10 sec total.
    """
    LD_res = 8
    HD_res = 8
    beam_FWHM_amin = 5.
    sN_uKamin = 35.
    nsims = 100

    HD_shape = (2**HD_res,2**HD_res) # resolution for CMB and lensing operation done at
    LD_shape = (2**LD_res,2**LD_res) # resolution of the dat map
    lcell_side_amin = 1.7 # length of lcell of the data resolution
    lside = lcell_side_amin / 60./180.*np.pi * LD_shape[0]*np.ones(2) # pixel res always the same always at 1.7 amin.

    cl_unl = camb.spectra_fromcambfile('/Users/jcarron/SpyderProjects/jpipe/inputs'
                                       '/cls/base_plikHM_TT_lowTEB_lensing_lenspotentialCls.dat')['tt'][:]
    cl_len = camb.spectra_fromcambfile('/Users/jcarron/SpyderProjects/jpipe/inputs'
                                       '/cls/base_plikHM_TT_lowTEB_lensing_lensedCls.dat')['tt'][:]
    cl_pp = camb.spectra_fromcambfile('/Users/jcarron/SpyderProjects/jpipe/inputs'
                                      '/cls/base_plikHM_TT_lowTEB_lensing_lenspotentialCls.dat')['pp'][:]
    cl_noise = (sN_uKamin * np.pi / 180. / 60.) ** 2*np.ones(20000)  # simple flat noise Cls
    cl_pp[0:2] = cl_pp[2]
    path_to_libs = '/Users/jcarron/data/flatsky_lens_simlibs/test_wPL2015' if path_to_libs is None else path_to_libs
    lib_cmb_unl = sims_generic.Gauss_sim_generic(path_to_libs + '/unl_cmb', cl_unl, HD_shape, lside, nsims_max=nsims)
    lib_noise = sims_generic.Gauss_sim_generic(path_to_libs + '/noise', cl_noise, LD_shape, lside, nsims_max=nsims)
    lib_pp = sims_generic.Gauss_sim_generic(path_to_libs + '/pp', cl_pp, LD_shape, lside, nsims_max=nsims)
    lib_OO = None
    lib_displ = sims.displ_2dsim(lib_pp, lib_OO)
    lib_displ_sim0 = sims_generic.sim_lib_shuffle(lib_displ, shuffle=lambda idx : 0)


    lib_cmb_len = sims.lencmb_sim_lib(lib_cmb_unl, lib_displ) # Library for lensed CMB
    lib_cmb_len_displ0 = sims.lencmb_sim_lib(lib_cmb_unl, lib_displ_sim0) # Library for lensed CMB's by identical potential

    sim_lib = sims.flatsky_sim_lib(lib_cmb_len, lib_noise, lib_dir=path_to_libs + '/full_sims',
                                   beam_FWHM_amin=beam_FWHM_amin, cache_sims=True, mask_map = None)
    fixedphi_sim_lib = sims.flatsky_sim_lib(lib_cmb_len_displ0, lib_noise, beam_FWHM_amin=beam_FWHM_amin,
                                            lib_dir=path_to_libs+'/fxp_sims', cache_sims=True, mask_map = None)
    unl_cov = covmatrices.flatsky_unlcov(cl_unl, (HD_res, HD_res), lside, sN_uKamin=sN_uKamin, Beam_FWHM_amin=beam_FWHM_amin, verbose=False)
    len_cov = covmatrices.flatsky_lencov(cl_unl, cl_len, LD_res, HD_res, lside,
                                         f = dp.identity_displacement(HD_shape), f_inv = dp.identity_displacement(HD_shape),
                                         verbose=False, sN_uKamin=sN_uKamin, Beam_FWHM_amin =beam_FWHM_amin)
    Fisher_lib = likelihoods.flatsky_Fisher_lib(cl_unl, (HD_res, HD_res), lside, sN_uKamin, beam_FWHM_amin, verbose=False)
    return [sim_lib,fixedphi_sim_lib,LD_res,HD_res,lside,sN_uKamin,beam_FWHM_amin,cl_unl,cl_len,cl_pp,cl_noise,unl_cov,len_cov,Fisher_lib]
Exemple #2
0
from fslens.sims import sims,sims_generic

lib_dir = './temp/test_ffs13'
prefix = 'ffs13'
sN_uKamin = 35.
HD_res = 13
LD_res = 13
nsims = 100
Beam_FWHM_amin =  5.

lmax_cl = 10000
base_path = './inputs/planck_lensing_wp_highL_bestFit_20130627_'
#base_path = '/Users/jcarron/SpyderProjects/jpipe/inputs/cls/base_plikHM_TT_lowTEB_lensing_'
if not os.path.exists(lib_dir):
    try : os.mkdir(lib_dir)
    except : print " ** unable to creat lib_dir ",lib_dir

cl_unl = camb.spectra_fromcambfile(base_path+'lenspotentialCls.dat',lmax = lmax_cl)['tt'][:]
cl_len = camb.spectra_fromcambfile(base_path+'lensedCls.dat',lmax = lmax_cl)['tt'][:]
cl_pp =  camb.spectra_fromcambfile(base_path+'lenspotentialCls.dat',lmax = lmax_cl)['pp'][:]

cl_noise = (sN_uKamin * np.pi / 180. / 60.) ** 2 * np.ones(30000)  # simple flat noise Cls
lib_noise = sims.ffs_Gauss_simlib(lib_dir + '/noise', cl_noise, LD_res, nsims_max = nsims)
lib_cmb_unl = sims.ffs_Gauss_simlib(lib_dir + '/cmb_unl', cl_unl, HD_res, nsims_max = nsims)
lib_pp = sims.ffs_Gauss_simlib(lib_dir + '/pp', cl_pp, HD_res, nsims_max = nsims)
lib_OO = None
lib_displ = sims.ffs_displ_2dsim(lib_pp, lib_OO, lib_dir=lib_dir + '/displ', cache_sims = True)
lib_cmb_len = sims.lencmb_sim_lib(lib_cmb_unl, lib_displ, lib_dir =lib_dir + '/cmb_len', cache_sims=True)  # Library for lensed CMB
lib_sim = sims.ffs_sim_lib(lib_cmb_len,lib_noise,Beam_FWHM_amin, mask_map = None, cache_sims=True, lib_dir=lib_dir + '/ffs_sim')

base_libs = [lib_noise,lib_pp,lib_cmb_unl,lib_OO]
Exemple #3
0
bins_l = np.int64(np.logspace(1.5, 4.0, 50))
bins_u = bins_l[1:] - 1
bins_l = bins_l[0 : len(bins_l) - 1]
binner = jc_utils.binner(bins_l, bins_u)
del bins_l, bins_u


HD_shape = (2 ** HD_res, 2 ** HD_res)  # resolution for CMB and lensing operation done at
LD_shape = (2 ** LD_res, 2 ** LD_res)  # resolution of the dat map
lside = (
    lcell_side_amin / 60.0 / 180.0 * np.pi * LD_shape[0] * np.ones(2)
)  # pixel res always the same always at 1.7 amin.
lmax_cl = 10000
cl_unl = camb.spectra_fromcambfile(
    "/Users/jcarron/SpyderProjects/lenscov/additional_files/planck_lensing_wp_highL_bestFit_20130627_lenspotentialCls.dat",
    lmax=lmax_cl,
)["tt"][:]
cl_len = camb.spectra_fromcambfile(
    "/Users/jcarron/SpyderProjects/lenscov/additional_files/planck_lensing_wp_highL_bestFit_20130627_lensedCls.dat",
    lmax=lmax_cl,
)["tt"][:]
cl_pp = camb.spectra_fromcambfile(
    "/Users/jcarron/SpyderProjects/lenscov/additional_files/planck_lensing_wp_highL_bestFit_20130627_lenspotentialCls.dat",
    lmax=lmax_cl,
)["pp"][:]
cl_noise = (sN_uKamin * np.pi / 180.0 / 60.0) ** 2 * np.ones(20000)  # simple flat noise Cls


path_to_libs = "/Users/jcarron/data/flatsky_lens_simlibs/test_wPL2015" if path_to_libs is None else path_to_libs
path_to_figs = path_to_libs + "/figs"