Пример #1
0
    def __init__(self,
                 mpibox,
                 theory,
                 shape,
                 wcs,
                 lbinner=None,
                 bin_edges=None,
                 pol=False,
                 iau_convention=False):

        self.mpibox = mpibox
        self.theory = theory
        self.shape = shape
        self.pol = pol
        self.wcs = wcs
        self.modlmap = enmap.modlmap(shape, wcs)
        self.fcalc = enmap.FourierCalc(shape,
                                       wcs,
                                       iau_convention=iau_convention)
        if lbinner is None:
            assert bin_edges is not None
            import orphics.tools.stats as stats
            self.lbinner = stats.bin2D(self.modlmap, bin_edges)
        else:
            self.lbinner = lbinner
Пример #2
0
    def __init__(self,
                 shape,
                 wcs,
                 components,
                 constDict,
                 ksz_file='input/ksz_BBPS.txt',
                 ksz_p_file='input/ksz_p_BBPS.txt',
                 tsz_cib_file='input/sz_x_cib_template.dat',
                 ksz_battaglia_test_csv=None,
                 tsz_battaglia_template_csv=None):

        from enlib import enmap
        from orphics import maps

        modlmap = enmap.modlmap(shape, wcs)
        fgNoises.__init__(self,
                          constDict,
                          ksz_file,
                          ksz_p_file,
                          tsz_cib_file,
                          ksz_battaglia_test_csv,
                          tsz_battaglia_template_csv,
                          components,
                          lmax=modlmap.max())

        self.mgens = {}
        for component in components:
            noise = self.noises[component](self.ells)
            ps = noise.reshape((1, 1, self.ells.size))
            self.mgens[component] = maps.MapGen(shape, wcs, ps)
Пример #3
0
def minimum_ell(shape, wcs):
    """
    Returns the lowest angular wavenumber of an ndmap
    rounded down to the nearest integer.
    """
    modlmap = enmap.modlmap(shape, wcs)
    min_ell = modlmap[modlmap > 0].min()
    return int(min_ell)
Пример #4
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] = enmap.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
Пример #5
0
def init_geometry(ishape,iwcs):
    modlmap = enmap.modlmap(ishape,iwcs)
    bin_edges = np.arange(args.kellmin,args.kellmax,args.dell)
    binner = stats.bin2D(modlmap,bin_edges)
    if args.beam<1e-5:
        kbeam = None
    else:
        kbeam = maps.gauss_beam(modlmap,args.beam)
    lmax = modlmap.max()
    ells = np.arange(2,lmax,1)
    wnoise_TT = ells*0.+(args.noise*(np.pi/180./60.))**2.
    wnoise_PP = 2.*wnoise_TT
    nT = modlmap*0.+(args.noise*(np.pi/180./60.))**2.
    nP = 2.*nT
    ncomp = 3 if pol else 1
    ps = np.zeros((ncomp,ncomp,ells.size))
    ps[0,0] = wnoise_TT
    if pol:
        ps[1,1] = wnoise_PP
        ps[2,2] = wnoise_PP
    oshape = (3,)+ishape if pol else ishape

    if not(args.flat) and args.noise_pad>1.e-5:
        # Pad noise sim geometry
        pad_width_deg = args.noise_pad
        pad_width = pad_width_deg * np.pi/180.
        res = maps.resolution(oshape[-2:],iwcs)
        pad_pixels = int(pad_width/res)
        template = enmap.zeros(oshape,iwcs)
        btemplate = enmap.pad(template,pad_pixels)
        bshape,bwcs = btemplate.shape,btemplate.wcs
        del template
        del btemplate
        ngen = maps.MapGen(bshape,bwcs,ps)
    else:
        ngen = maps.MapGen(oshape,iwcs,ps)
    
    tmask = maps.mask_kspace(ishape,iwcs,lmin=args.tellmin,lmax=args.tellmax)
    pmask = maps.mask_kspace(ishape,iwcs,lmin=args.pellmin,lmax=args.pellmax)
    kmask = maps.mask_kspace(ishape,iwcs,lmin=args.kellmin,lmax=args.kellmax)

    qest = lensing.qest(ishape,iwcs,theory,noise2d=nT,beam2d=kbeam,kmask=tmask,noise2d_P=nP,kmask_P=pmask,kmask_K=kmask,pol=pol,grad_cut=None,unlensed_equals_lensed=True)

    taper,w2 = maps.get_taper_deg(ishape,iwcs,taper_width_degrees = args.taper_width,pad_width_degrees = args.pad_width)
    fc = maps.FourierCalc(oshape,iwcs,iau=args.iau)

    
    purifier = maps.Purify(ishape,iwcs,taper) if args.purify else None

    
    return qest,ngen,kbeam,binner,taper,fc,purifier
Пример #6
0
def mask_kspace(shape, wcs, lxcut=None, lycut=None, lmin=None, lmax=None):
    output = np.ones(shape[-2:], dtype=int)
    if (lmin is not None) or (lmax is not None):
        modlmap = enmap.modlmap(shape, wcs)
    if (lxcut is not None) or (lycut is not None):
        ly, lx = enmap.laxes(shape, wcs, oversample=1)
    if lmin is not None:
        output[np.where(modlmap <= lmin)] = 0
    if lmax is not None:
        output[np.where(modlmap >= lmax)] = 0
    if lxcut is not None:
        output[:, np.where(np.abs(lx) < lxcut)] = 0
    if lycut is not None:
        output[np.where(np.abs(ly) < lycut), :] = 0
    return output
Пример #7
0
def init_flat(ishape,iwcs):
    modlmap = enmap.modlmap(ishape,iwcs)
    lmax = modlmap.max()
    ells = np.arange(2,lmax,1)
    ncomp = 3 if pol else 1
    ps = np.zeros((ncomp,ncomp,ells.size))
    ps[0,0] = theory.uCl('TT',ells)
    if pol:
        ps[1,1] = theory.uCl('EE',ells)
        ps[1,0] = theory.uCl('TE',ells)
        ps[0,1] = theory.uCl('TE',ells)
    oshape = (3,)+ishape if pol else ishape
    mgen = maps.MapGen(oshape,iwcs,ps)
    psk = theory.gCl('kk',ells).reshape((1,1,ells.size))
    kgen = maps.MapGen(ishape,iwcs,psk)
    return mgen,kgen
Пример #8
0
 def __init__(self, shape, wcs, groups=None):
     # Symbolic
     self.l1x, self.l1y, self.l2x, self.l2y, self.l1, self.l2 = get_ells()
     self.Lx, self.Ly, self.L = get_Ls()
     if groups is None:
         groups = [self.Lx * self.Lx, self.Ly * self.Ly, self.Lx * self.Ly]
     self._default_groups = groups
     self.integrands = {}
     self.ul1s = {}
     self.ul2s = {}
     self.ogroups = {}
     self.ogroup_weights = {}
     self.ogroup_symbols = {}
     self.l1funcs = []
     self.l2funcs = []
     # Diagnostic
     self.nfft = 0
     self.nifft = 0
     # Numeric
     self.shape, self.wcs = shape, wcs
     self.modlmap = enmap.modlmap(shape, wcs)
     self.lymap, self.lxmap = enmap.lmap(shape, wcs)
     self.pixarea = np.prod(enmap.pixshape(shape, wcs))
Пример #9
0
                                        wcs,
                                        wdeg,
                                        hdeg,
                                        width_multiplier=0.6,
                                        height_multiplier=1.2,
                                        downsample=True,
                                        pix_target_override_arcmin=pxover)

    rotmap = r.rotate(map_south)

    if k == 0:
        rottap = r.rotate(taper)
        #tmg = enmap.MapGen(r.shape_final,r.wcs_final,ps)
        w2 = np.mean(rottap**2.)
        fc = enmap.FourierCalc(r.shape_final, r.wcs_final)
        modlmap = enmap.modlmap(r.shape_final, r.wcs_final)
        bin_edges = np.arange(100, lmax, 40)
        binner = bin2D(modlmap, bin_edges)

    map_test = fullsky.submap(enmap.box(r.shape_final, r.wcs_final))
    del fullsky
    if k == 0:
        rect_taper, rw2 = fmaps.get_taper(map_test.shape,
                                          taper_percent=18.0,
                                          pad_percent=4.0,
                                          weight=None)
        rfc = enmap.FourierCalc(map_test.shape, map_test.wcs)
        rmodlmap = enmap.modlmap(map_test.shape, map_test.wcs)
        rbinner = bin2D(rmodlmap, bin_edges)

    map_test *= rect_taper
Пример #10
0
pol = False if pol_list == ['TT'] else True

fine_ells = np.arange(0, lmax, 1)

shape_sim, wcs_sim = enmap.get_enmap_patch(patch_width_arcmin,
                                           sim_pixel_scale,
                                           proj="car",
                                           pol=pol)
modr_sim = enmap.modrmap(shape_sim, wcs_sim) * 180. * 60. / np.pi

# === LENS ===

lxmap_sim, lymap_sim, modlmap_sim, angmap_sim, lx_sim, ly_sim = fmaps.get_ft_attributes_enmap(
    shape_sim, wcs_sim)
pix_ells = np.arange(0, modlmap_sim.max(), 1)
modl_map_alt = enmap.modlmap(shape_sim, wcs_sim)
assert np.all(np.isclose(modlmap_sim, modl_map_alt))

if cluster:
    massOverh = 2.e14
    zL = 0.7
    overdensity = 500.
    critical = True
    atClusterZ = True
    concentration = 3.2
    comS = cc.results.comoving_radial_distance(cc.cmbZ) * cc.h
    comL = cc.results.comoving_radial_distance(zL) * cc.h
    winAtLens = (comS - comL) / comS
    kappa_map, r500 = NFWkappa(cc,
                               massOverh,
                               concentration,
Пример #11
0
numcores = comm.Get_size()


# Paths
PathConfig = io.load_path_config()
GridName = PathConfig.get("paths","output_data")+args.GridName
with open(GridName+"/attribs.json",'r') as f:
    attribs = json.loads(f.read())
barc = attribs['arc'] ; bpix = attribs['pix']  ; bbeam = attribs['beam']  
pout_dir = PathConfig.get("paths","plots")+args.GridName+"/joint_bayesian_hdv_plots_"+io.join_nums((barc,bpix,bbeam,args.noise))+"_"
io.mkdir(pout_dir,comm)


# Tiny Geometry
bshape, bwcs = maps.rect_geometry(width_arcmin=barc,px_res_arcmin=bpix,pol=False)
bmodlmap = enmap.modlmap(bshape,bwcs)
bmodrmap = enmap.modrmap(bshape,bwcs)





# Noise model
noise_uK_rad = args.noise*np.pi/180./60.
normfact = np.sqrt(np.prod(enmap.pixsize(bshape,bwcs)))
noise_uK_pixel = noise_uK_rad/normfact
Ncov = np.diag([(noise_uK_pixel)**2.]*np.prod(bshape))

kbeam = maps.gauss_beam(bbeam,bmodlmap)

        
Пример #12
0
                                        cc,
                                        zL=0.7,
                                        concentration=3.2,
                                        overdensity=200.,
                                        critical=True,
                                        atClusterZ=True)
#sigma = 1.0 * np.pi/180./60.
#lens_func = lambda x: 0.2 * np.exp(-x**2./sigma**2./2.)

rshape, rwcs = maps.rect_geometry(width_arcmin=5., px_res_arcmin=0.001)
fshape, fwcs = maps.rect_geometry(width_arcmin=20., px_res_arcmin=0.1)
cshape, cwcs = maps.rect_geometry(width_arcmin=20., px_res_arcmin=0.5)
rmodrmap = enmap.modrmap(rshape, rwcs)
fmodrmap = enmap.modrmap(fshape, fwcs)
cmodrmap = enmap.modrmap(cshape, cwcs)
rmodlmap = enmap.modlmap(rshape, rwcs)
fmodlmap = enmap.modlmap(fshape, fwcs)
cmodlmap = enmap.modlmap(cshape, cwcs)
print(fshape, cshape)

mass = 2.e14
fkappa = lens_func(fmodrmap)
phi, _ = lensing.kappa_to_phi(fkappa, fmodlmap, return_fphi=True)
grad_phi = enmap.grad(phi)
pos = enmap.posmap(fshape, fwcs) + grad_phi
alpha_pix = enmap.sky2pix(fshape, fwcs, pos, safe=False)

lmax = cmodlmap.max()
ells = np.arange(0, lmax, 1)
cls = theory.uCl('TT', ells)
ps = cls.reshape((1, 1, ells.size))
Пример #13
0
 def add_beam_1d(self, ells, beam_1d_transform):
     modlmap = enmap.modlmap(self.shape[-2:], self.wcs)
     self.kbeam2d = interp1d(ells,
                             beam_1d_transform,
                             bounds_error=False,
                             fill_value=0.)(modlmap)
Пример #14
0
    def _init_qests(self):

        mlist = ['e', 's', 'r']
        self.qest = {}
        tellminY = 500
        tellmaxY = 3000
        pellminY = 500
        pellmaxY = 3000
        tellminX = 500
        tellmaxX = 3000
        pellminX = 500
        pellmaxX = 3000
        kellmin = 80
        kellmax = 3000
        self.kellmin = kellmin
        self.kellmax = kellmax

        for m in mlist:
            modlmap_dat = enmap.modlmap(self.shape[m], self.wcs[m])
            nT = modlmap_dat.copy() * 0.
            nP = modlmap_dat.copy() * 0.
            lbeam = modlmap_dat.copy() * 0. + 1.
            fMaskCMB_TX = fmaps.mask_kspace(self.shape[m],
                                            self.wcs[m],
                                            lmin=tellminX,
                                            lmax=tellmaxX)
            fMaskCMB_TY = fmaps.mask_kspace(self.shape[m],
                                            self.wcs[m],
                                            lmin=tellminY,
                                            lmax=tellmaxY)
            fMaskCMB_PX = fmaps.mask_kspace(self.shape[m],
                                            self.wcs[m],
                                            lmin=pellminX,
                                            lmax=pellmaxX)
            fMaskCMB_PY = fmaps.mask_kspace(self.shape[m],
                                            self.wcs[m],
                                            lmin=pellminY,
                                            lmax=pellmaxY)
            fMask = fmaps.mask_kspace(self.shape[m],
                                      self.wcs[m],
                                      lmin=kellmin,
                                      lmax=kellmax)
            with io.nostdout():
                self.qest[m] = Estimator(
                    self.shape[m],
                    self.wcs[m],
                    self.theory,
                    theorySpectraForNorm=None,
                    noiseX2dTEB=[nT, nP, nP],
                    noiseY2dTEB=[nT, nP, nP],
                    fmaskX2dTEB=[fMaskCMB_TX, fMaskCMB_PX, fMaskCMB_PX],
                    fmaskY2dTEB=[fMaskCMB_TY, fMaskCMB_PY, fMaskCMB_PY],
                    fmaskKappa=fMask,
                    kBeamX=lbeam,
                    kBeamY=lbeam,
                    doCurl=False,
                    TOnly=True,
                    halo=True,
                    uEqualsL=True,
                    gradCut=None,
                    verbose=False,
                    bigell=self.lmax)
Пример #15
0
        i).zfill(2) + ".fits"
    lmap_file = "/gpfs01/astro/workarea/msyriac/data/sims/sigurd/cori/v61600/equator_curved_lensed_car_" + str(
        i).zfill(2) + ".fits"
    imap = enmap.read_map(map_file)[0]
    lmap = enmap.read_map(lmap_file)[0]
    smap = imap.submap(bbox)

    if k == 0:
        shape = smap.shape
        wcs = smap.wcs
        fc = enmap.FourierCalc(shape, wcs)
        taper, w2 = fmaps.get_taper(shape,
                                    taper_percent=12.0,
                                    pad_percent=3.0,
                                    weight=None)
        binner = stats.bin2D(enmap.modlmap(shape, wcs), bin_edges)

        shape2 = lmap.shape
        wcs2 = lmap.wcs
        fc2 = enmap.FourierCalc(shape2, wcs2)
        taper2, w22 = fmaps.get_taper(shape2,
                                      taper_percent=12.0,
                                      pad_percent=3.0,
                                      weight=None)
        binner2 = stats.bin2D(enmap.modlmap(shape2, wcs2), bin_edges)

        ells = np.arange(0, 5000, 1)
        ps = theory.lCl('TT', ells).reshape((1, 1, 5000))
        shapeN, wcsN = enmap.rect_geometry(1.2 * deg * 60., px, proj="car")
        mg = enmap.MapGen(shapeN, wcsN, ps)
Пример #16
0
with open(GridName + "/attribs.json", 'r') as f:
    attribs = json.loads(f.read())
barc = attribs['arc']
bpix = attribs['pix']
bbeam = attribs['beam']
pout_dir = PathConfig.get(
    "paths",
    "plots") + args.GridName + "/joint_bayesian_hdv_plots_" + io.join_nums(
        (barc, bpix, args.beam, args.noise)) + "_"
io.mkdir(pout_dir, comm)

# Tiny Geometry
bshape, bwcs = maps.rect_geometry(width_arcmin=barc,
                                  px_res_arcmin=bpix,
                                  pol=False)
bmodlmap = enmap.modlmap(bshape, bwcs)
bmodrmap = enmap.modrmap(bshape, bwcs)

# Big Geometry
shape, wcs = maps.rect_geometry(width_arcmin=args.arc,
                                px_res_arcmin=args.pix,
                                pol=False)
modlmap = enmap.modlmap(shape, wcs)
modrmap = enmap.modrmap(shape, wcs)
oshape, owcs = enmap.scale_geometry(shape, wcs, args.pix / bpix)
omodlmap = enmap.modlmap(oshape, owcs)
omodrmap = enmap.modrmap(oshape, owcs)

if rank == 0:
    print(bshape, bwcs)
    print(shape, wcs)
Пример #17
0
# Theory
theory_file_root = "../alhazen/data/Aug6_highAcc_CDM"
cc = counts.ClusterCosmology(skipCls=True)
theory = cosmology.loadTheorySpectraFromCAMB(theory_file_root,
                                             unlensedEqualsLensed=False,
                                             useTotal=False,
                                             TCMB=2.7255e6,
                                             lpad=9000,
                                             get_dimensionless=False)

# Geometry

shape, wcs = maps.rect_geometry(width_arcmin=args.arc,
                                px_res_arcmin=args.pix,
                                pol=False)
modlmap = enmap.modlmap(shape, wcs)
modrmap = enmap.modrmap(shape, wcs)
bshape, bwcs = maps.rect_geometry(width_arcmin=args.arc * args.buffer_factor,
                                  px_res_arcmin=args.pix,
                                  pol=False)
bmodlmap = enmap.modlmap(bshape, bwcs)
bmodrmap = enmap.modrmap(bshape, bwcs)

#gshape, gwcs = maps.rect_geometry(width_arcmin=args.arc,px_res_arcmin=0.1953125,pol=False)
gshape, gwcs = maps.rect_geometry(width_arcmin=100.,
                                  px_res_arcmin=args.pix,
                                  pol=False)
gshape, gwcs = bshape, bwcs
gmodlmap = enmap.modlmap(gshape, gwcs)
gmodrmap = enmap.modrmap(gshape, gwcs)
Пример #18
0
from __future__ import print_function
from orphics import maps,io,cosmology,stats
from enlib import enmap
import numpy as np
import os,sys
from scipy import signal

cc = cosmology.Cosmology(lmax=6000,pickling=True)

deg = 15.
shape,wcs = maps.rect_geometry(width_deg=deg,px_res_arcmin=1.0)
modlmap = enmap.modlmap(shape,wcs)
modrmap = enmap.modrmap(shape,wcs)
lmax = modlmap.max()
ells = np.arange(0,lmax,1)
ps = cc.theory.lCl('TT',ells).reshape((1,1,ells.size))

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)
Пример #19
0
def make_circular_geometry(shape,
                           wcs,
                           context_arcmin,
                           hole_arcmin,
                           power2d,
                           buffer_factor=2,
                           verbose=False):
    '''Makes the circular geometry matrices that need to be pre-calculated for later inpainting.

    Arguments
    ---------

    input2DPower - ndarray containing 2D power spectrum of a map. It need not already have been
                   downsampled to the shape of the stamp cutout
    inputLy
    inputLx      - the fourier wavenumbers corresponding to the y and x axes of the stamp cutout
    stampArc     - the width in arcminutes of the stamp cut out
    stampPxX      - the pixel width in arcminutes of the stamp cut out in the x direction
    stampPxY      - the pixel width in arcminutes of the stamp cut out in the y direction
    holeArc      - the radius of the circular hole in arcminutes
    bufferFactor - the pixel covariance matrix will be calculated on a periodic stamp larger by this
                   factor
    verbose      - True if you want more commentary

    Returns
    -------

    meanMul      - a matrix that has shape (nh,nc) where nh is the number of pixels in the hole and
                   nc is the number of pixels outside (in the "context"). It should be multiplied
                   by a vector (nc) containing pixels outside to get a vector (nh) for the mean
                   value of the pixels inside
    covRoot      - a (nh,nh) sqrt(covariance matrix) that can be used to generate a random realization
                   in the hole. This can be generated by multiplying the sqrt of cov by a vector (nh)
                   of standard normal variables. The generated vector should be added to the mean value
                   obtained using meanMul
    pcov         - the pixel-pixel covariance matrix used in intermediate steps, if you want to re-use it
    targetTemplate - a liteMap template of the stamp cutout
    m1           - a boolean array that can be used to select the hole region
    m2           - a boolean array that can be used to select the context region


    '''

    arc = context_arcmin
    res = maps.resolution(shape, wcs) * 60. * 180. / np.pi

    bshape, bwcs = maps.rect_geometry(width_arcmin=arc * buffer_factor,
                                      px_res_arcmin=res)
    tshape, twcs = maps.rect_geometry(width_arcmin=arc, px_res_arcmin=res)
    sny, snx = tshape
    bmodlmap = enmap.modlmap(bshape, bwcs)
    modlmap = enmap.modlmap(shape, wcs)

    if verbose: print("Downsampling...")
    Niy, Nix = shape[-2:]
    Noy, Nox = bshape[-2:]

    # print(bshape,tshape,power2d.shape)
    # io.plot_img(np.fft.fftshift(np.log10(power2d)))
    #out_power = resample.resample_fft(power2d,bshape[-2:],axes=[-2,-1])
    #out_power = np.fft.ifftshift(resample.resample_fft(np.fft.fftshift(power2d),bshape[-2:],axes=[-2,-1]))
    out_power = resample.resample_bin(
        power2d, factors=[float(Noy) / Niy, float(Nox) / Nix], axes=[-2, -1])
    # io.plot_img(np.fft.fftshift(np.log10(out_power)))
    # print(out_power.shape)

    if verbose: print("Starting slow part...")
    d = maps.diagonal_cov(out_power)
    with bench.show("pixcov"):
        pcov = maps.pixcov(bshape, bwcs, d)[0, 0, :sny, :snx, :sny, :snx]
    modrmap = enmap.modrmap(tshape, twcs)
    m1 = np.where(modrmap.reshape(-1) < hole_arcmin * np.pi / 180. / 60.)[0]
    m2 = np.where(modrmap.reshape(-1) >= hole_arcmin * np.pi / 180. / 60.)[0]

    with bench.show("geom"):
        meanMul, cov = get_geometry(pcov.reshape(sny * snx, sny * snx), m1, m2)

    covRoot = stats.eig_pow(cov, 0.5)

    return meanMul, covRoot, pcov, tshape, twcs, m1, m2