コード例 #1
0
 def __init__(self, bin_edges, shape, return_dl=True):
     self.bin_edges = bin_edges
     self.shape = shape
     self.taper, _ = omaps.get_taper(shape)
     loc = self.taper == 0
     self.taper[loc] = np.min(self.taper[~loc])
     self.return_dl = return_dl
コード例 #2
0
    ret = act_sim.getActpolCmbSim(None,
                                  coords,
                                  sim_idx,
                                  cmb_dir,
                                  doBeam=False,
                                  pixelFac=2)

    for i in range(len(ret)):
        ret[i] = enmap.from_flipper(ret[i])
        ret[i] -= np.mean(ret[i])
    return (ret[0], ret[1], ret[2])  # TQU


temp_map, _, _ = get_sim(0)
shape, wcs = temp_map.shape, temp_map.wcs
taper, _ = maps.get_taper(shape)
taper = enmap.enmap(taper, wcs=wcs)

# initialize cusps
overwrite = False
mcm_identifier = "%lsd_le%d_nb%d_lm%d_%s_%s" % (0, lmax, nbin, lmax,
                                                coords_str, postfix)
cusps_fc = cusps.power.CUSPS(mcm_identifier, taper, taper, bin_edges, lmax,
                             None, overwrite)
binner = cusps_fc.binner

# bin the theory
theo_bin = {}
lbin_th, theo_bin['dltt'] = cusps_fc.bin_theory_scalarxscalar(
    l_th, theo['dltt'])
lbin_th, theo_bin['dlte'] = cusps_fc.bin_theory_scalarxscalar(
コード例 #3
0
ファイル: test_beam.py プロジェクト: mjvakili/orphics
mgen = maps.MapGen(shape,wcs,ps)




fwhm = 5.
kbeam = maps.gauss_beam(modlmap,fwhm)
imap = mgen.get_map()

bmap2 = maps.convolve_gaussian(imap.copy(),fwhm=fwhm,nsigma=5.0)
print(bmap2.shape)

bmap = maps.filter_map(imap.copy(),kbeam)

taper,w2 = maps.get_taper(shape)

io.plot_img(imap*taper,io.dout_dir+"bmap0.png",high_res=True)
io.plot_img(bmap*taper,io.dout_dir+"bmap1.png",high_res=True)
io.plot_img(bmap2*taper,io.dout_dir+"bmap2.png",high_res=True)

bin_edges = np.arange(200,3000,100)
binner = stats.bin2D(modlmap,bin_edges)
fc = maps.FourierCalc(shape,wcs)
p2d,_,_ = fc.power2d(imap*taper)
cents,p1di = binner.bin(p2d/w2)
p2d,_,_ = fc.power2d(bmap*taper)
cents,p1db = binner.bin(p2d/w2)
p2d,_,_ = fc.power2d(bmap2*taper)
cents,p1db2 = binner.bin(p2d/w2)
コード例 #4
0
 def __init__(self, shape):
     self.shape = shape
     self.taper, _ = omaps.get_taper(shape, pad_percent=0.)
     loc = self.taper == 0
     self.taper[loc] = np.min(self.taper[~loc])
コード例 #5
0
clkk = theory.gCl('kk', ls)
ellrange = np.arange(0, 6000, 1)
totcls = interp1d(ls, clkk + nls, bounds_error=False,
                  fill_value="extrapolate")(ellrange)
ps = totcls.reshape((1, 1, ellrange.size))
bshape, bwcs = maps.rect_geometry(width_deg=80.,
                                  px_res_arcmin=2.0,
                                  height_deg=15.)
tap_per = 1. / 40. * 100.
pad_per = 1. / 40. * 100.

mg = maps.MapGen(bshape, bwcs, ps)
fc = maps.FourierCalc(bshape, bwcs)

taper, w2 = maps.get_taper(bshape,
                           taper_percent=tap_per,
                           pad_percent=pad_per,
                           weight=None)

bmap = mg.get_map()

#io.plot_img(bmap*taper,"map.png",high_res=True)

# bin_edges = np.arange(100,5000,100)
# binner = stats.bin2D(enmap.modlmap(bshape,bwcs),bin_edges)
# cents, bp1d = binner.bin(fc.power2d(bmap*taper)[0]/w2)

# pl = io.Plotter(yscale='log')
# pl.add(ellrange,totcls)
# pl.add(cents,bp1d)
# pl.done("cls.png")
コード例 #6
0
    def make_sim(self, seed):

        with bench.show(
                "Lensing operation...") if self.rank == 0 else ignore():
            full, kappa = lensing.rand_map(
                self.fshape,
                self.fwcs,
                self.ps,
                lmax=self.lmax,
                maplmax=self.lmax,
                seed=seed,
                verbose=True if self.rank == 0 else False,
                dtype=self.dtype,
                output="lk")
            alms = curvedsky.map2alm(full, lmax=self.lmax)
            ps_data = hp.alm2cl(alms.astype(np.complex128))
            del alms
            self.mpibox.add_to_stats("fullsky_ps", ps_data)
            south = full.submap(self.pos_south)
            equator = full.submap(self.pos_eq)
            ksouth = kappa.submap(self.pos_south)
            kequator = kappa.submap(self.pos_eq)
            del full
            del kappa

        if self.count == 0:
            self.shape['s'], self.wcs['s'] = south.shape, south.wcs
            self.shape['e'], self.wcs['e'] = equator.shape, equator.wcs

            for m in ['s', 'e']:
                self.taper[m], self.w2[m] = fmaps.get_taper(self.shape[m],
                                                            taper_percent=18.0,
                                                            pad_percent=4.0,
                                                            weight=None)
                self.w4[m] = np.mean(self.taper[m]**4.)
                self.w3[m] = np.mean(self.taper[m]**3.)

            self.rotator = fmaps.MapRotatorEquator(
                self.shape['s'],
                self.wcs['s'],
                self.wdeg,
                self.hdeg,
                width_multiplier=0.6,
                height_multiplier=1.2,
                downsample=True,
                verbose=True if self.rank == 0 else False,
                pix_target_override_arcmin=self.pix_intermediate)

            self.taper['r'] = self.rotator.rotate(self.taper['s'])
            self.w2['r'] = np.mean(self.taper['r']**2.)
            self.w4['r'] = np.mean(self.taper['r']**4.)
            self.w3['r'] = np.mean(self.taper['r']**3.)

            self.shape['r'], self.wcs[
                'r'] = self.rotator.shape_final, self.rotator.wcs_final

            self.fc = {}
            self.binner = {}
            self.modlmap = {}
            for m in ['s', 'e', 'r']:
                self.fc[m] = fmaps.FourierCalc(self.shape[m], self.wcs[m])
                self.modlmap[m] = enmap.modlmap(self.shape[m], self.wcs[m])
                self.binner[m] = bin2D(self.modlmap[m], self.bin_edges)
            self.cents = self.binner['s'].centers
            self._init_qests()

        self.count += 1

        south *= self.taper['s']
        equator *= self.taper['e']
        ksouth *= self.taper['s']
        kequator *= self.taper['e']

        return south, equator, ksouth, kequator
コード例 #7
0
ファイル: sim_wsky.py プロジェクト: simonsobs/cmbhalolensing
                                  coords,
                                  r=maxr,
                                  res=px * utils.arcmin,
                                  proj="plain",
                                  oversample=2,
                                  depix=True)

    kstamp = kstamp[0]
    lstamp = lstamp[0]

    if i == 0:
        # get an edge taper map and apodize
        taper = maps.get_taper(
            l_stamp.shape,
            l_stamp.wcs,
            taper_percent=tap_per,
            pad_percent=pad_per,
            weight=None,
        )
        taper = taper[0]

        # get geometry and Fourier info
        shape = kstamp.shape
        wcs = kstamp.wcs
        modlmap = enmap.modlmap(shape, wcs)

        assert wcsutils.equal(kstamp.wcs, lstamp.wcs)

        # evaluate the 2D Gaussian beam on an isotropic Fourier grid
        beam2d = maps.gauss_beam(modlmap, fwhm)
コード例 #8
0
    ellrange = np.arange(200, 6000, 1)
    cltt = theory.lCl('TT', ellrange)
    clee = theory.lCl('EE', ellrange)
    clbb = theory.lCl('BB', ellrange)
    pl.add(ellrange, cltt * ellrange**2., color="k")
    pl.add(ellrange, clee * ellrange**2., color="k")
    pl.add(ellrange, clbb * ellrange**2., color="k")
    pl.add(cents, dtt * cents**2.)
    pl.add(cents, dee * cents**2.)
    pl.add(cents, dbb * cents**2.)
    pl.done(out_dir + "powers_" + suffix + ".png")


plot_powers(cmb, suffix="periodic", w2=1.)
taper, w2 = maps.get_taper(shape,
                           taper_percent=12.0,
                           pad_percent=3.0,
                           weight=None)
plot_powers(cmb * taper, suffix="tapered", w2=w2)

print("Pure...")
#windict = pure.init_deriv_window(taper,px*np.pi/180./60.)
windict = maps.init_deriv_window(taper, px * np.pi / 180. / 60.)
lxMap, lyMap, modLMap, angLMap, lx, ly = maps.get_ft_attributes(shape, wcs)
#cmb *= taper
#fT, fE, fB =  pure.iqu_to_pure_lteb(cmb[0],cmb[1],cmb[2],modlmap,angLMap,windowDict=windict,method='pure')
#fT, fE, fB =  maps.iqu_to_pure_lteb(cmb[0]*taper,cmb[1]*taper,cmb[2]*taper,modlmap,angLMap,windowDict=windict,method='pure')
fT, fE, fB = maps.iqu_to_pure_lteb(cmb[0],
                                   cmb[1],
                                   cmb[2],
                                   modlmap,
                                   angLMap,