示例#1
0
def generate_noise_alms(nl_array_t, nl_array_pol, lmax, n_splits):
    """This function generates the alms corresponding to the noise power spectra matrices
    nl_array_t, nl_array_pol. The function returns a dictionnary nlms["T", i].
    The entry of the dictionnary are for example nlms["T", i] where i is the index of the split.
    note that nlms["T", i] is a (nfreqs, size(alm)) array, it is the harmonic transform of
    the noise realisation for the different frequencies.
        
    Parameters
    ----------
    nl_array_t : 3d array [nfreq, nfreq, lmax]
      noise power spectra matrix for temperature data
    nl_array_pol : 3d array [nfreq, nfreq, lmax]
      noise power spectra matrix for polarisation data

    lmax : integer
      the maximum multipole for the noise power spectra
    n_splits: integer
      the number of data splits we want to simulate

    """

    nlms = {}
    for k in range(n_splits):
        nlms["T", k] = curvedsky.rand_alm(nl_array_t, lmax=lmax)
        nlms["E", k] = curvedsky.rand_alm(nl_array_pol, lmax=lmax)
        nlms["B", k] = curvedsky.rand_alm(nl_array_pol, lmax=lmax)

    return nlms
示例#2
0
    def __init__(self,camb_file='./CMB_fiducial_totalCls.dat',seed=1,pixRes_arcmin=2.,lmax_sim=500,nside_pysm=512):

        cls_camb = np.loadtxt(camb_file,unpack=True)
        cl_tt = cls_camb[1]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_tt = np.append([0,0],cl_tt)
        cl_ee = cls_camb[2]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_ee = np.append([0,0],cl_ee)
        cl_bb = cls_camb[3]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_bb = np.append([0,0],cl_bb)
        cl_te = cls_camb[4]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_te = np.append([0,0],cl_te)
        ells = np.append([0,1],cls_camb[0])

        self.pixRes_arcmin=pixRes_arcmin/180./60*np.pi
        self.lmax_sim = lmax_sim

        shape,wcs = enmap.fullsky_geometry(self.pixRes_arcmin,dims=(2,))
        self.shape = shape
        self.wcs = wcs
        np.random.seed(seed)

        self.nside_pysm =nside_pysm

        self.alm_cmb_E = curvedsky.rand_alm(cl_ee,lmax=lmax_sim)#hp.synalm(cl_ee,lmax=3*nside-1,new=True)
        self.alm_cmb_B = curvedsky.rand_alm(cl_bb,lmax=lmax_sim)#hp.synalm(cl_bb,lmax=3*nside-1,new=True)
        tmp_empty = enmap.empty(shape,wcs)
        self.Q_cmb,self.U_cmb = curvedsky.alm2map(np.array([self.alm_cmb_E,self.alm_cmb_B]),tmp_empty,spin=[2])
示例#3
0
def generate_noise_alms(Nl_array_T, Nl_array_P, lmax, nSplits, ncomp):
    nlms = {}
    if ncomp == 1:
        for k in range(nSplits):
            nlms[k] = curvedsky.rand_alm(Nl_array_T, lmax=lmax)
    else:
        for k in range(nSplits):
            nlms['T', k] = curvedsky.rand_alm(Nl_array_T, lmax=lmax)
            nlms['E', k] = curvedsky.rand_alm(Nl_array_P, lmax=lmax)
            nlms['B', k] = curvedsky.rand_alm(Nl_array_P, lmax=lmax)

    return nlms
示例#4
0
    def __init__(self,camb_file='./CMB_fiducial_totalCls.dat',seed=1,pixRes_arcmin=4,lmax_sim=500):



        cls_camb = np.loadtxt(camb_file,unpack=True)
        cl_tt = cls_camb[1]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_tt = np.append([0,0],cl_tt)
        cl_ee = cls_camb[2]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_ee = np.append([0,0],cl_ee)
        cl_bb = cls_camb[3]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)*0.05
        cl_bb = np.append([0,0],cl_bb)
        cl_te = cls_camb[4]/(cls_camb[0]*(cls_camb[0]+1)/2/np.pi)
        cl_te = np.append([0,0],cl_te)
        ells = np.append([0,1],cls_camb[0])

        self.pixRes_arcmin=pixRes_arcmin/180./60*np.pi
        self.lmax_sim = lmax_sim

        shape,wcs = enmap.fullsky_geometry(self.pixRes_arcmin,dims=(2,))

        np.random.seed(seed)
        self.shape = shape
        self.wcs = wcs

        self.alm_cmb_E = curvedsky.rand_alm(cl_ee,lmax=lmax_sim)#hp.synalm(cl_ee,lmax=3*nside-1,new=True)
        self.alm_cmb_B = curvedsky.rand_alm(cl_bb,lmax=lmax_sim)#hp.synalm(cl_bb,lmax=3*nside-1,new=True)
        tmp_empty = enmap.empty(shape,wcs)
        self.Q_cmb,self.U_cmb = curvedsky.alm2map(np.array([self.alm_cmb_E,self.alm_cmb_B]),tmp_empty,spin=[2])

        ps = np.zeros([2,2,lmax_sim])
        ps[0,0] = synchrotron_Cl('E','E')[:lmax_sim]
        ps[1,1] = galaticDust_Cl('E','E')[:lmax_sim]
        ps[1,0] = syncxdust_Cls('E','E')[:lmax_sim]

        self.alm_sync_E,self.alm_dust_E = curvedsky.rand_alm(ps,lmax=lmax_sim)

        ps = np.zeros([2,2,lmax_sim])
        ps[0,0] = synchrotron_Cl('B','B')[:lmax_sim]
        ps[1,1] = galaticDust_Cl('B','B')[:lmax_sim]
        ps[1,0] = syncxdust_Cls('B','B')[:lmax_sim]

        self.alm_sync_B,self.alm_dust_B = curvedsky.rand_alm(ps,lmax=lmax_sim)


        tmp_empty = enmap.empty(shape,wcs)
        self.Q_dust,self.U_dust = curvedsky.alm2map(np.array([self.alm_dust_E,self.alm_dust_B]),tmp_empty,spin=[2])


        tmp_empty = enmap.empty(shape,wcs)
        self.Q_sync,self.U_sync = curvedsky.alm2map(np.array([self.alm_sync_E,self.alm_sync_B]),tmp_empty,spin=[2])
示例#5
0
def generate_noise_alms(nl_array_t,
                        lmax,
                        n_splits,
                        ncomp,
                        nl_array_pol=None,
                        dtype=np.complex128):
    """This function generates the alms corresponding to the noise power spectra matrices
    nl_array_t, nl_array_pol. The function returns a dictionnary nlms["T", i].
    The entry of the dictionnary are for example nlms["T", i] where i is the index of the split.
    note that nlms["T", i] is a (narrays, size(alm)) array, it is the harmonic transform of
    the noise realisation for the different frequencies.
    
    Parameters
    ----------
    nl_array_t : 3d array [narrays, narrays, lmax]
      noise power spectra matrix for temperature data
    
    lmax : integer
      the maximum multipole for the noise power spectra
    n_splits: integer
      the number of data splits we want to simulate
    ncomp: interger
      the number of components
      ncomp = 3 if T,Q,U
      ncomp = 1 if T only
    nl_array_pol : 3d array [narrays, narrays, lmax]
      noise power spectra matrix for polarisation data
      (in use if ncomp==3)
    """

    nlms = {}
    if ncomp == 1:
        for k in range(n_splits):
            nlms[k] = curvedsky.rand_alm(nl_array_t, lmax=lmax, dtype=dtype)
    else:
        for k in range(n_splits):
            nlms["T", k] = curvedsky.rand_alm(nl_array_t,
                                              lmax=lmax,
                                              dtype=dtype)
            nlms["E", k] = curvedsky.rand_alm(nl_array_pol,
                                              lmax=lmax,
                                              dtype=dtype)
            nlms["B", k] = curvedsky.rand_alm(nl_array_pol,
                                              lmax=lmax,
                                              dtype=dtype)

    return nlms
示例#6
0
def rand_map(shape, wcs, ps_lensinput, doRotation=False, ps_rot=None, lmax=None,
             maplmax=None, dtype=np.float64, seed=None, phi_seed=None,
             oversample=2.0, spin=[0,2], output="l", geodesic=True, verbose=False,
             delta_theta=None):
    from pixell import curvedsky, sharp
    ctype   = np.result_type(dtype,0j)

    # Restrict to target number of components
    oshape  = shape[-3:]
    if len(oshape) == 2: shape = (1,)+tuple(shape)
    ncomp   = shape[-3]
    ps_lensinput = ps_lensinput[:1+ncomp,:1+ncomp]
    # First draw a random lensing field, and use it to compute the undeflected positions
    if verbose: print("Generating alms")
    if phi_seed is None:
        alm, ainfo = curvedsky.rand_alm(ps_lensinput, lmax=lmax, seed=seed, dtype=ctype, return_ainfo=True)
    else:
        # We want separate seeds for cmb and phi. This means we have to do things a bit more manually
        wps, ainfo = curvedsky.prepare_ps(ps_lensinput, lmax=lmax)
        alm = np.empty([1+ncomp,ainfo.nelem],ctype)
        curvedsky.rand_alm_white(ainfo, alm=alm[:1], seed=phi_seed)
        curvedsky.rand_alm_white(ainfo, alm=alm[1:], seed=seed)
        ps12 = enmap.multi_pow(wps, 0.5)
        ainfo.lmul(alm, (ps12/2**0.5).astype(dtype), alm)
        alm[:,:ainfo.lmax].imag  = 0
        alm[:,:ainfo.lmax].real *= 2**0.5
        del wps, ps12

    phi_alm, cmb_alm = alm[0], alm[1:]

    if doRotation:
        # generate a gaussian random field of rotational field
        alpha_shape = (1, shape[-2], shape[-1])

        alpha_map = curvedsky.rand_map(alpha_shape, wcs, ps_rot, lmax=lmax)

        # convert alm to enmap object
        cmb_map = enmap.empty((3,shape[-2],shape[-1]), wcs)
        curvedsky.alm2map(cmb_alm, cmb_map)

        # rotate tqu map by a rotational field
        # Q_map = cmb_map[1]
        # U_map = cmb_map[2]
        cmb_map_rot = enmap.rotate_pol(cmb_map, alpha_map)

        # convert tqu map back to the alm
        cmb_alm = curvedsky.map2alm(cmb_map_rot, lmax=lmax)
        del alpha_map, cmb_map, cmb_map_rot

        del alm
        # Truncate alm if we want a smoother map. In taylens, it was necessary to truncate
        # to a lower lmax for the map than for phi, to avoid aliasing. The appropriate lmax
        # for the cmb was the one that fits the resolution. FIXME: Can't slice alm this way.
        #if maplmax: cmb_alm = cmb_alm[:,:maplmax]
        return lens_map_curved(shape=shape, wcs=wcs, phi_alm=phi_alm,
                               cmb_alm=cmb_alm, phi_ainfo=ainfo, maplmax=maplmax,
                               dtype=dtype, oversample=oversample, spin=spin,
                               output=output, geodesic=geodesic, verbose=verbose,
                               delta_theta=delta_theta)
示例#7
0
    def test_rand_alm(self):
        def nalm(lmax):
            return (lmax + 1) * (lmax + 2) / 2

        lmaxes = [50, 100, 150, 300]
        
        mypower = np.ones(50)
        for lmax in lmaxes:
            palm = curvedsky.rand_alm(mypower, lmax = lmax)
            halm = curvedsky.rand_alm_healpy(  mypower, lmax = lmax)
            
            print("nalm(%i) = %i, curvedsky.rand_alm gives %s, curvedsky.rand_alm_healpy gives %s "\
	              % (lmax, \
                     nalm(lmax),\
                     palm.shape, \
                     halm.shape)        )
            assert np.all(np.isclose(np.asarray(palm.shape),np.asarray(halm.shape)))
示例#8
0
    def update_signal_index(self,sim_idx,set_idx=0,cmb_type='LensedUnabberatedCMB'):
        signal_path = sints.dconfig['actsims']['signal_path']
        cmb_file   = os.path.join(signal_path, 'fullsky%s_alm_set%02d_%05d.fits' %(cmb_type, set_idx, sim_idx))
        self.alms['cmb'] = hp.fitsfunc.read_alm(cmb_file, hdu = (1,2,3))
        comptony_seed = seed_tracker.get_fg_seed(set_idx, sim_idx, 'comptony')
        fgres_seed = seed_tracker.get_fg_seed(set_idx, sim_idx, 'srcfree')
        #self.alms['comptony'] = curvedsky.rand_alm_healpy(self.cyy, seed = comptony_seed)
        self.alms['comptony'] = curvedsky.rand_alm(self.cyy, lmax=self.ellmax, seed = comptony_seed) #!!!!
        #self.alms['comptony'] = curvedsky.rand_alm(self.cyy, lmax=self.ellmax, seed = 1) #!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        if self.cfgres is not None: 
            self.alms['fgres'] = curvedsky.rand_alm_healpy(self.cfgres, seed = fgres_seed) # SWITCHED BACK!!!
            #self.alms['fgres'] = curvedsky.rand_alm(self.cfgres, lmax=self.ellmax, seed = fgres_seed)


        # 1. convert to maximum ellmax
        lmax = max([hp.Alm.getlmax(self.alms[comp].shape[1]) for comp in self.alms.keys()])
        for comp in self.alms.keys():
            if hp.Alm.getlmax(self.alms[comp].shape[1])!=lmax: self.alms[comp] = maps.change_alm_lmax(self.alms[comp], lmax)
        self.lmax = lmax
示例#9
0
def get_input(input_name,set_idx,sim_idx,shape,wcs):
    if input_name=='CMB':
        cmb_type = 'LensedUnabberatedCMB'
        signal_path = sints.dconfig['actsims']['signal_path']
        cmb_file   = os.path.join(signal_path, 'fullsky%s_alm_set%02d_%05d.fits' %(cmb_type, set_idx, sim_idx))
        alms = hp.fitsfunc.read_alm(cmb_file, hdu = 1)
    elif input_name=='tSZ':
        ellmax = 8101
        ells = np.arange(ellmax)
        cyy = fgs.power_y(ells)[None,None]
        cyy[0,0][ells<2] = 0
        comptony_seed = seed_tracker.get_fg_seed(set_idx, sim_idx, 'comptony')
        alms = curvedsky.rand_alm(cyy, seed = comptony_seed,lmax=ellmax)
    elif input_name=='kappa':
        signal_path = sints.dconfig['actsims']['signal_path']
        k_file   = os.path.join(signal_path, 'fullskyPhi_alm_%05d.fits' %(sim_idx))
        palms = hp.fitsfunc.read_alm(k_file)
        from pixell import lensing as plensing
        alms = plensing.phi_to_kappa(palms)
    omap = enmap.zeros((1,)+shape[-2:],wcs)
    omap = curvedsky.alm2map(np.complex128(alms),omap,spin=0)[0]
    return omap
示例#10
0
def getActpolCmbFgSim(beamfileDict,
                      shape, wcs,
                      iterationNum, cmbDir, freqs, psa,
                      cmbSet = 0, \
                      doBeam = True, applyWindow = True, verbose = True, cmbMaptype = 'LensedCMB',
                      foregroundSeed = 0, simType = 'cmb', foregroundPowerFile = None, applyModulation = True):

    nTQUs = len('TQU')
    firstTime = True

    output = enmap.empty((
        len(freqs),
        nTQUs,
    ) + shape[-2:], wcs)

    if simType == 'cmb':

        filename = cmbDir + "/fullsky%s_alm_set%02d_%05d.fits" % (
            cmbMaptype, cmbSet, iterationNum)
        if verbose:
            print('getActpolCmbFgSim(): loading CMB a_lms from %s' % filename)
        import healpy
        almTebFullskyOnecopy = np.complex128(
            healpy.fitsfunc.read_alm(filename, hdu=(1, 2, 3)))

        #Now tile the same for all the frequencies requested (i.e. CMB is same at all frequencies).
        #The beam convolution happens below.
        almTebFullsky = np.tile(almTebFullskyOnecopy, (len(freqs), 1, 1))

        if verbose:
            print('getActpolCmbFgSim(): done')

    elif simType == 'foregrounds':
        outputFreqs = ['f090', 'f150']

        foregroundPowers \
            = powspec.read_spectrum(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                                 '../data/',
                                                 foregroundPowerFile),
                                ncol = 3,
                                expand = 'row')

        if verbose:
            print('getActpolCmbFgSim(): getting foreground a_lms')
        almTFullsky90and150 = curvedsky.rand_alm(foregroundPowers,
                                                 seed=foregroundSeed)

        almTebFullsky = np.zeros((
            len(freqs),
            nTQUs,
        ) + (len(almTFullsky90and150[-1]), ),
                                 dtype=np.complex128)

        for fi, freq in enumerate(freqs):
            if freq in outputFreqs:
                almTebFullsky[fi, 'TQU'.index('T'), :]  \
                    = almTFullsky90and150[outputFreqs.index(freq), :]

    #Convolve with beam on full sky
    for fi, freq in enumerate(freqs):
        if doBeam:
            beamFile = beamfileDict[psa + '_' + freq]
            if verbose:
                print('getActpolCmbFgSim(): applying beam from %s' % beamFile)
            beamData = (np.loadtxt(beamFile))[:, 1]
        else:
            if verbose:
                print('getActpolCmbFgSim(): not convolving with beam')
            beamData = np.repeat(1., almTebFullsky.shape[-1])

        import healpy

        #couldn't quickly figure out how to vectorize this so loop from 0 to 2.
        for tqui in range(nTQUs):
            almTebFullsky[fi, tqui] = healpy.sphtfunc.almxfl(
                almTebFullsky[fi, tqui].copy(), beamData)

        #These lines stolen from curvedsky.rand_map
        #doing all freqs at once gives error:
        #sharp.pyx in sharp.execute_dp (cython/sharp.c:12118)()
        #ValueError: ndarray is not C-contiguous
        #so loop over all freqs once for now.

    curvedsky.alm2map(almTebFullsky, output, spin=[0, 2], verbose=True)

    # outputThisfreq   = enmap.empty(( nTQUs,)+shape[-2:], wcs)
    # curvedsky.alm2map(almTebFullsky[fi,:,:], outputThisfreq, spin = [0,2],  verbose = True)
    # output[fi,...] = outputThisfreq

    # curvedsky.alm2map(almTebFullsky[fi,:,:], output[fi,:,:,:], spin = [0,2],  verbose = True)

    if applyModulation:
        from pixell import aberration
        for fi, freq in enumerate(freqs):

            print('applying modulation for frequency %s' % freq)
            output, A = aberration.boost_map(output,
                                             aberration.dir_equ,
                                             aberration.beta,
                                             return_modulation=True,
                                             aberrate=False,
                                             freq=freqStrToValGhz[freq] * 1e9)

    if applyWindow:
        from pixell import fft

        #The axes along which to FFT
        axes = [-2, -1]
        if verbose:
            print('getActpolCmbFgSim(): applying pixel window function')

        nfreq = len(freqs)
        for idx in range(nfreq):
            fd = fft.fft(output[idx], axes=axes)
            wy, wx = enmap.calc_window(fd.shape)
            twoDWindow = wy[:, None]**1 * wx[None, :]**1

            #Careful, this is quietly multiplying an array with shape [N_freq, N_TQU, N_y, N_x] with one of shape [N_y, N_x]
            fd *= twoDWindow

            output[idx] = (fft.ifft(fd, axes=axes, normalize=True)).real
            del fd
        if verbose:
            print('getActpolCmbFgSim(): done')

    return enmap.ndmap(output, wcs)
示例#11
0
 def _generate_unlensed_cmb_alm(self, seed=None):
     seed = seed if seed is None else np.random.seed(seed_tracker.get_cmb_seed(seed))
     lmax = 10000
     ualm = curvedsky.rand_alm(self.cmb_spec[0], lmax=lmax, seed=seed)
     return ualm
示例#12
0
pixwin = hp.pixwin(nside)

bestfit = np.load("%s/bestfit_matrix.npy" % bestfit_dir)
l, nl_array_t, nl_array_pol = planck_utils.noise_matrix(
    noise_model_dir, exp, freqs, lmax, nsplits)

so_mpi.init(True)
subtasks = so_mpi.taskrange(imin=d["iStart"], imax=d["iStop"])

for iii in subtasks:

    t0 = time.time()

    alms = {}

    sim_alm = curvedsky.rand_alm(bestfit, lmax=lmax)

    if use_ffp10 == False:
        nlms = planck_utils.generate_noise_alms(nl_array_t, nl_array_pol, lmax,
                                                nsplits)

    for f_id, freq in enumerate(freqs):

        maps = d["map_%s" % freq]  # In use for the missing pixels

        freq_alm = np.zeros((3, sim_alm.shape[1]), dtype="complex")
        freq_alm[0] = sim_alm[0 + f_id * 3].copy()
        freq_alm[1] = sim_alm[1 + f_id * 3].copy()
        freq_alm[2] = sim_alm[2 + f_id * 3].copy()

        for hm, map, k in zip(splits, maps, np.arange(nsplits)):
示例#13
0
    curvedsky.alm2map(kappa_alms, kappa_map_car)

    lmax = healpy.Alm.getlmax(len(kappa_alms))
    ainfo = sharp.alm_info(lmax)

    ellvals = np.arange(lmax)

    #factor to change kappa into phi
    func = 2. / (ellvals * (ellvals + 1.))
    func[0] = 0

    phi_alm = healpy.sphtfunc.almxfl(kappa_alms, func)
    
    cmb_powers = get_cmb_powerspectra.websky_cmb_spectra()['unlensed_scalar']

    cmb_alm, cmb_ainfo = curvedsky.rand_alm(cmb_powers, lmax = lmax, seed = 1, return_ainfo = True)

    unlensed_map, lensed_map = lensing.lens_map_curved((3,) + shape, wcs, phi_alm, cmb_alm, ainfo, output = 'ul')


    cmb_alm_lensed = curvedsky.map2alm(lensed_map, ainfo = cmb_ainfo)
    

    healpy.fitsfunc.write_alm(p['outdir'] + 'lensed_alm.fits',
                              np.complex128(cmb_alm_lensed), overwrite = True)

    healpy.fitsfunc.write_alm(p['outdir'] + 'unlensed_alm.fits',
                              np.complex128(cmb_alm), overwrite = True)

    
示例#14
0
    nSplits,
    lcut=0,
    use_noise_th=use_noise_th)

pixwin = hp.pixwin(nside)

so_mpi.init(True)
subtasks = so_mpi.taskrange(imin=d['iStart'], imax=d['iStop'])

for iii in subtasks:

    t0 = time.time()
    alms = {}

    sim_alm = curvedsky.rand_alm(
        ps_th, lmax=lmax - 1
    )  #the nlms and sim_alm lmax need to be investigated, there is a mismatch of 1 that is not understood at the moment
    nlms = planck_utils.generate_noise_alms(Nl_T, Nl_P, lmax, nSplits, ncomp)

    for freq_id, freq in enumerate(freqs):

        maps = d['map_%s' % freq]

        if include_foregrounds == True:
            freq_alm = np.zeros((3, sim_alm.shape[1]), dtype='complex')
            freq_alm[0] = sim_alm[0 + freq_id * 3].copy()
            freq_alm[1] = sim_alm[1 + freq_id * 3].copy()
            freq_alm[2] = sim_alm[2 + freq_id * 3].copy()

        for hm, map, k in zip(splits, maps, np.arange(nSplits)):
scenarios = ["standard", "noE", "noB"]

# we will use mpi over the number of simulations
so_mpi.init(True)
subtasks = so_mpi.taskrange(imin=d["iStart"], imax=d["iStop"])

for iii in subtasks:
    t0 = time.time()

    for scenario in scenarios:

        # generate cmb alms and foreground alms
        # cmb alms will be of shape (3, lm) 3 standing for T,E,B
        # fglms will be of shape (nfreq, lm) and is T only

        alms = curvedsky.rand_alm(ps_cmb, lmax=lmax, dtype=sim_alm_dtype)
        fglms = curvedsky.rand_alm(ps_fg, lmax=lmax, dtype=sim_alm_dtype)

        master_alms = {}

        for sv in surveys:

            arrays = d["arrays_%s" % sv]
            ks_f = d["k_filter_%s" % sv]

            for ar_id, ar in enumerate(arrays):

                win_T = so_map.read_map(d["window_T_%s_%s" % (sv, ar)])
                win_pol = so_map.read_map(d["window_pol_%s_%s" % (sv, ar)])

                window_tuple = (win_T, win_pol)
示例#16
0
pl._ax.set_xlim(10, 6500)
pl.hline(y=1)
pl.done("/scratch/r/rbond/msyriac/data/depot/tilec/plots/allfits.png")

#sys.exit()

#lsave = 400
#np.savetxt("/scratch/r/rbond/msyriac/data/for_sigurd/bad_matrix.txt",cfgres[:,:,lsave])
# sys.exit()

fgres_seed = 1
print("done with txt")

print(cfgres.dtype)

alms2 = curvedsky.rand_alm(cfgres, lmax=lmax, seed=fgres_seed)
alms1 = curvedsky.rand_alm_healpy(cfgres, seed=fgres_seed)
print("done")

for i in range(narrays):
    for j in range(i, narrays):
        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1)
        ax.set_xlabel('l', fontsize=14)
        ax.set_ylabel('D', fontsize=14)
        ax.set_xscale('linear', nonposx='clip')
        ax.set_yscale('log', nonposy='clip')

        qid1 = qids[i]
        qid2 = qids[j]
all_freqs = [freq for exp in experiments for freq in d["freqs_%s" % exp]]
ncomp = 3
ps_cmb = powspec.read_spectrum(d["clfile"])[:ncomp, :ncomp]

if include_fg == True:
    l, ps_fg = maps_to_params_utils.get_foreground_matrix(
        fg_dir, fg_components, all_freqs, lmax_simu + 1)

so_mpi.init(True)
subtasks = so_mpi.taskrange(imin=d["iStart"], imax=d["iStop"])

for iii in subtasks:
    #First we will generate our simulations and take their harmonics transforms
    t0 = time.time()

    alms = curvedsky.rand_alm(ps_cmb, lmax=lmax_simu)

    if include_fg == True:
        fglms = curvedsky.rand_alm(ps_fg, lmax=lmax_simu)

    master_alms = {}
    fcount = 0

    for exp in experiments:
        freqs = d["freqs_%s" % exp]
        nsplits = d["nsplits_%s" % exp]

        if d["pixel_%s" % exp] == "CAR":
            template = so_map.car_template(ncomp, d["ra0_%s" % exp],
                                           d["ra1_%s" % exp],
                                           d["dec0_%s" % exp],
示例#18
0
 def _generate_gaussian_kappa(self, seed=None):
     if seed is not None:
         np.random.seed(seed_tracker.get_kappa_seed(seed))
     clkk = self.clkk_spec[:, 1]
     alm = curvedsky.rand_alm(clkk)
     return curvedsky.alm2map(alm, self.template.copy())[np.newaxis, ...]