datapipe/datapipe.py
def create_map_sets(SimSetupCMB_obj, cmbmaps, numbmaps, patchy_tau_vals=None , patchy_tau_ells=None,
                    beam_am=0, noise_uk_am=0, incl_tau=False, incl_cbfringe=False, kappa_ps_fac=1,
                    seed_kappa=None, seed_tau=None, seed_cbfringe=None, alpha_ps_vals=None, alpha_ps_ells=None):
    init_image_shape = (numbmaps,) + SimSetupCMB_obj.shape[-2:]
    """
    Creates an image data set of CMB simulations.

    Parameters
    ----------
    msett_obj :
        msett class object. Container for all information for creating CMB
        simulations.
    cmbmaps : list
        Python list of CMB maps that should be saved.
    number : int
        Number of simulations to run.
    beam_am :
        Experiment beam FWHM in arcmin
    noise_uk_arcmin :
        Temperature instrument noise in (\mu)K-arcmin
    incl_tau : boolean
        If True, patchy reionization map will be generated and used to modulate
        primoridial maps by e^{-\\tau} before being lensed.
    kappa_ps_fac :
        Factor that will be applied to the \kappa power spectrum.
    seed_kappa : int
        Lensing convergence map NumPy seed.
    seed_tau : int
        Patchy reionization map NumPy seed.

    Returns
    -------
    window_info.npz :
        Numpy array of applied taper information that is saved to the working
        directory. The taper applied to all maps is saved. A naive correction
        "w2" is also saved. The "w2" value is the mean of the squared cosine taper.
    map_sets32.npz :
        Numpy array of CMB maps that is saved to working directory. Maps saved
        are from the cmbmaps list and are float32.
    """

    poss_maps = (
            't_obs', 'q_obs', 'u_obs', 'e_obs', 'b_obs',
            't_prim', 'q_prim', 'u_prim', 'e_prim', 'b_prim',
            'tru_kappa', 'tru_phi', 'rec_kappa', 'rec_phi',
            'wf_rec_kappa', 'tru_tau', 'tru_cbfringe')

    final_maps = {}
    window_vals = {}
    for i in cmbmaps:
        if i not in poss_maps:
            raise Exception('Map {} is not available or in the incorrect format'.format(i))
        else:
            final_maps[i] = np.zeros(init_image_shape, dtype=np.float32)
    
    if not(incl_tau):
        assert 'tru_tau' not in final_maps, "Remove 'tru_tau' from list of maps to save."

    # generating maps and saving them
    for l in np.arange(0, numbmaps):
        # Including 'Null" in 20% of "numbmaps" set.
        if np.random.random() < 0.8:
            tau_ps_fac = 1.0
            finkappa_ps_fac = kappa_ps_fac
            alpha_ps_fac = 1.0
        else:
            tau_ps_fac = 1.0
            finkappa_ps_fac = 1.0
            alpha_ps_fac = 0.0

        if incl_tau:
            cltautau = SimSetupCMB_obj.tautauTheorycl(patchy_tau_vals * tau_ps_fac, patchy_tau_ells, 2, 9000)
        if incl_cbfringe:
            clalpha = SimSetupCMB_obj.cbfringeTheorycl(alpha_ps_vals * alpha_ps_fac, alpha_ps_ells, 2, 9000)
        flsims = SimSetupCMB_obj.flat_lens_sim(beam_arcmin=beam_am, noise_uk_arcmin=noise_uk_am, incl_tau=incl_tau, kappa_ps_fac=finkappa_ps_fac, incl_cbfringe=incl_cbfringe)
        gmaps = get_flsims_maps(SimSetupCMB_obj, flsims, incltau=incl_tau, inclcbfringe=incl_cbfringe, seed_kappa=seed_kappa, seed_tau=seed_tau, seed_cbf=seed_cbfringe)
        #recon = qest_recon_map(SimSetupCMB_obj, gmaps, est='EB')
        everymap = get_mlmaps(gmaps, qest_recon_map=None, incltau=incl_tau, inclcbfringe=incl_cbfringe)

        for i in cmbmaps:
            init_map = everymap[i]

            # saving first couple of maps to serve as a check on data quality
            if l < 3:
                np.save('map_{}_{}'.format(i,l), init_map)
    
            final_maps[i][l] = init_map.astype(np.float32)
    # saving taper and w2 for window correction
    window_vals['taper'] = np.asarray(SimSetupCMB_obj.taper)
    window_vals['w2'] = np.asarray(SimSetupCMB_obj.w2)

    np.savez('window_info', **window_vals)
    np.savez('map_sets32', **final_maps)

    Creates an image data set of CMB simulations.

    Parameters
    ----------
    msett_obj :
        msett class object. Container for all information for creating CMB
        simulations.
    cmbmaps : list
        Python list of CMB maps that should be saved.
    number : int
        Number of simulations to run.
    beam_am :
        Experiment beam FWHM in arcmin
    noise_uk_arcmin :
        Temperature instrument noise in (\mu)K-arcmin
    incl_tau : boolean
        If True, patchy reionization map will be generated and used to modulate
        primoridial maps by e^{-\\tau} before being lensed.
    kappa_ps_fac :
        Factor that will be applied to the \kappa power spectrum.
    seed_kappa : int
        Lensing convergence map NumPy seed.
    seed_tau : int
        Patchy reionization map NumPy seed.

    Returns
    -------
    window_info.npz :
        Numpy array of applied taper information that is saved to the working
        directory. The taper applied to all maps is saved. A naive correction
        "w2" is also saved. The "w2" value is the mean of the squared cosine taper.
    map_sets32.npz :
        Numpy array of CMB maps that is saved to working directory. Maps saved
        are from the cmbmaps list and are float32.
    
Creates an image data set of CMB simulations.
Parameters

msett_obj :
msett class object. Container for all information for creating CMB
simulations.
cmbmaps : list
Python list of CMB maps that should be saved.
number : int
Number of simulations to run.
beam_am :
Experiment beam FWHM in arcmin
noise_uk_arcmin :
Temperature instrument noise in (\mu)K-arcmin
incl_tau : boolean
If True, patchy reionization map will be generated and used to modulate
primoridial maps by e^{-\\tau} before being lensed.
kappa_ps_fac :
Factor that will be applied to the \kappa power spectrum.
seed_kappa : int
Lensing convergence map NumPy seed.
seed_tau : int
Patchy reionization map NumPy seed.

Returns

window_info.npz :
Numpy array of applied taper information that is saved to the working
directory. The taper applied to all maps is saved. A naive correction
"w2" is also saved. The "w2" value is the mean of the squared cosine taper.
map_sets32.npz :
Numpy array of CMB maps that is saved to working directory. Maps saved
are from the cmbmaps list and are float32.
Creates an image data set of CMB simulations . Parameters msett_obj : msett class object . Container for all information for creating CMB simulations . cmbmaps : list Python list of CMB maps that should be saved . number : int Number of simulations to run . beam_am : Experiment beam FWHM in arcmin noise_uk_arcmin : Temperature instrument noise in ( \ mu ) K - arcmin incl_tau : boolean If True patchy reionization map will be generated and used to modulate primoridial maps by e^ { - \\ tau } before being lensed . kappa_ps_fac : Factor that will be applied to the \ kappa power spectrum . seed_kappa : int Lensing convergence map NumPy seed . seed_tau : int Patchy reionization map NumPy seed . Returns window_info . npz : Numpy array of applied taper information that is saved to the working directory . The taper applied to all maps is saved . A naive correction " w2 " is also saved . The " w2 " value is the mean of the squared cosine taper . map_sets32 . npz : Numpy array of CMB maps that is saved to working directory . Maps saved are from the cmbmaps list and are float32 .
def create_map_sets(SimSetupCMB_obj, cmbmaps, numbmaps, patchy_tau_vals=None , patchy_tau_ells=None,
                    beam_am=0, noise_uk_am=0, incl_tau=False, incl_cbfringe=False, kappa_ps_fac=1,
                    seed_kappa=None, seed_tau=None, seed_cbfringe=None, alpha_ps_vals=None, alpha_ps_ells=None):
    init_image_shape = (numbmaps,) + SimSetupCMB_obj.shape[-2:]
    poss_maps = (
            't_obs', 'q_obs', 'u_obs', 'e_obs', 'b_obs',
            't_prim', 'q_prim', 'u_prim', 'e_prim', 'b_prim',
            'tru_kappa', 'tru_phi', 'rec_kappa', 'rec_phi',
            'wf_rec_kappa', 'tru_tau', 'tru_cbfringe')
    final_maps = {}
    window_vals = {}
    for i in cmbmaps:
        if i not in poss_maps:
            raise Exception('Map {} is not available or in the incorrect format'.format(i))
        else:
            final_maps[i] = np.zeros(init_image_shape, dtype=np.float32)
    if not(incl_tau):
        assert 'tru_tau' not in final_maps, "Remove 'tru_tau' from list of maps to save."
    for l in np.arange(0, numbmaps):
        if np.random.random() < 0.8:
            tau_ps_fac = 1.0
            finkappa_ps_fac = kappa_ps_fac
            alpha_ps_fac = 1.0
        else:
            tau_ps_fac = 1.0
            finkappa_ps_fac = 1.0
            alpha_ps_fac = 0.0
        if incl_tau:
            cltautau = SimSetupCMB_obj.tautauTheorycl(patchy_tau_vals * tau_ps_fac, patchy_tau_ells, 2, 9000)
        if incl_cbfringe:
            clalpha = SimSetupCMB_obj.cbfringeTheorycl(alpha_ps_vals * alpha_ps_fac, alpha_ps_ells, 2, 9000)
        flsims = SimSetupCMB_obj.flat_lens_sim(beam_arcmin=beam_am, noise_uk_arcmin=noise_uk_am, incl_tau=incl_tau, kappa_ps_fac=finkappa_ps_fac, incl_cbfringe=incl_cbfringe)
        gmaps = get_flsims_maps(SimSetupCMB_obj, flsims, incltau=incl_tau, inclcbfringe=incl_cbfringe, seed_kappa=seed_kappa, seed_tau=seed_tau, seed_cbf=seed_cbfringe)
        everymap = get_mlmaps(gmaps, qest_recon_map=None, incltau=incl_tau, inclcbfringe=incl_cbfringe)
        for i in cmbmaps:
            init_map = everymap[i]
            if l < 3:
                np.save('map_{}_{}'.format(i,l), init_map)
            final_maps[i][l] = init_map.astype(np.float32)
    window_vals['taper'] = np.asarray(SimSetupCMB_obj.taper)
    window_vals['w2'] = np.asarray(SimSetupCMB_obj.w2)
    np.savez('window_info', **window_vals)
    np.savez('map_sets32', **final_maps)
def create_map_sets ( SimSetupCMB_obj , cmbmaps , numbmaps , patchy_tau_vals = None , patchy_tau_ells = None , beam_am = 0 , noise_uk_am = 0 , incl_tau = False , incl_cbfringe = False , kappa_ps_fac = 1 , seed_kappa = None , seed_tau = None , seed_cbfringe = None , alpha_ps_vals = None , alpha_ps_ells = None ) : init_image_shape = ( numbmaps , ) + SimSetupCMB_obj . shape [ - 2 : ] poss_maps = ( 't_obs' , 'q_obs' , 'u_obs' , 'e_obs' , 'b_obs' , 't_prim' , 'q_prim' , 'u_prim' , 'e_prim' , 'b_prim' , 'tru_kappa' , 'tru_phi' , 'rec_kappa' , 'rec_phi' , 'wf_rec_kappa' , 'tru_tau' , 'tru_cbfringe' ) final_maps = { } window_vals = { } for i in cmbmaps : if i not in poss_maps : raise Exception ( 'Map {} is not available or in the incorrect format' . format ( i ) ) else : final_maps [ i ] = np . zeros ( init_image_shape , dtype = np . float32 ) if not ( incl_tau ) : assert 'tru_tau' not in final_maps , "Remove 'tru_tau' from list of maps to save." for l in np . arange ( 0 , numbmaps ) : if np . random . random ( ) < 0.8 : tau_ps_fac = 1.0 finkappa_ps_fac = kappa_ps_fac alpha_ps_fac = 1.0 else : tau_ps_fac = 1.0 finkappa_ps_fac = 1.0 alpha_ps_fac = 0.0 if incl_tau : cltautau = SimSetupCMB_obj . tautauTheorycl ( patchy_tau_vals * tau_ps_fac , patchy_tau_ells , 2 , 9000 ) if incl_cbfringe : clalpha = SimSetupCMB_obj . cbfringeTheorycl ( alpha_ps_vals * alpha_ps_fac , alpha_ps_ells , 2 , 9000 ) flsims = SimSetupCMB_obj . flat_lens_sim ( beam_arcmin = beam_am , noise_uk_arcmin = noise_uk_am , incl_tau = incl_tau , kappa_ps_fac = finkappa_ps_fac , incl_cbfringe = incl_cbfringe ) gmaps = get_flsims_maps ( SimSetupCMB_obj , flsims , incltau = incl_tau , inclcbfringe = incl_cbfringe , seed_kappa = seed_kappa , seed_tau = seed_tau , seed_cbf = seed_cbfringe ) everymap = get_mlmaps ( gmaps , qest_recon_map = None , incltau = incl_tau , inclcbfringe = incl_cbfringe ) for i in cmbmaps : init_map = everymap [ i ] if l < 3 : np . save ( 'map_{}_{}' . format ( i , l ) , init_map ) final_maps [ i ] [ l ] = init_map . astype ( np . float32 ) window_vals [ 'taper' ] = np . asarray ( SimSetupCMB_obj . taper ) window_vals [ 'w2' ] = np . asarray ( SimSetupCMB_obj . w2 ) np . savez ( 'window_info' , ** window_vals ) np . savez ( 'map_sets32' , ** final_maps )
Creates an image data set of CMB simulations.
Creates an image data set of CMB simulations .
"""
    Creates an image data set of CMB simulations.

    Parameters
    ----------
    msett_obj :
        msett class object. Container for all information for creating CMB
        simulations.
    cmbmaps : list
        Python list of CMB maps that should be saved.
    number : int
        Number of simulations to run.
    beam_am :
        Experiment beam FWHM in arcmin
    noise_uk_arcmin :
        Temperature instrument noise in (\mu)K-arcmin
    incl_tau : boolean
        If True, patchy reionization map will be generated and used to modulate
        primoridial maps by e^{-\\tau} before being lensed.
    kappa_ps_fac :
        Factor that will be applied to the \kappa power spectrum.
    seed_kappa : int
        Lensing convergence map NumPy seed.
    seed_tau : int
        Patchy reionization map NumPy seed.

    Returns
    -------
    window_info.npz :
        Numpy array of applied taper information that is saved to the working
        directory. The taper applied to all maps is saved. A naive correction
        "w2" is also saved. The "w2" value is the mean of the squared cosine taper.
    map_sets32.npz :
        Numpy array of CMB maps that is saved to working directory. Maps saved
        are from the cmbmaps list and are float32.
    """ # generating maps and saving them # Including 'Null" in 20% of "numbmaps" set. #recon = qest_recon_map(SimSetupCMB_obj, gmaps, est='EB') # saving first couple of maps to serve as a check on data quality # saving taper and w2 for window correction
SimSetupCMB_obj
cmbmaps
numbmaps
patchy_tau_vals
patchy_tau_ells
beam_am
noise_uk_am
incl_tau
incl_cbfringe
kappa_ps_fac
seed_kappa
seed_tau
seed_cbfringe
alpha_ps_vals
alpha_ps_ells