Exemple #1
0
        recon = pipe.reconstruct(m, cmb[m]) - mf[m]

        if pipe.rank == 0: pipe.logger.info("Powers...")

        rxr, krecon, _ = pipe.fc[m].power2d(recon)
        rxr /= pipe.w4[m]
        rxi = pipe.fc[m].f2power(kinput, krecon)
        rxi /= pipe.w3[m]
        n0 = pipe.qest[m].N.super_dumb_N0_TTTT(cxc) / pipe.w2[m]**2.
        rxr_n0 = rxr - n0

        pipe.mpibox.add_to_stack("meanfield-" + m, recon)

        pipe.mpibox.add_to_stats("rxr-" + m, pipe.binner[m].bin(rxr)[1])
        pipe.mpibox.add_to_stats("rxi-" + m, pipe.binner[m].bin(rxi)[1])
        pipe.mpibox.add_to_stats("n0-" + m, pipe.binner[m].bin(n0)[1])
        pipe.mpibox.add_to_stats("rxr-n0-" + m, pipe.binner[m].bin(rxr_n0)[1])

        if k == 0 and pipe.rank == 0:
            import orphics.tools.io as io
            io.highResPlot2d(cmb[m], io.dout_dir + "cmb_" + m + ".png")
            io.highResPlot2d(recon, io.dout_dir + "recon_" + m + ".png")

if pipe.rank == 0: pipe.logger.info("MPI Collecting...")
pipe.mpibox.get_stacks(verbose=False)
pipe.mpibox.get_stats(verbose=False)

if pipe.rank == 0:
    pipe.dump(save_meanfield=(args.meanfield is None),
              skip_recon=args.skip_recon)
Exemple #2
0
gradfit = 2.*np.pi/180./60.

from scipy.ndimage.interpolation import rotate

N = 100
avgrot = 0.
for i in range(N):
    map = enmap.rand_map(shape, wcs, ps)/TCMB

    gmap = enmap.grad(map)
    angle = np.arctan2(gmap[0][np.where(thetaMap<gradfit)].mean(),gmap[1][np.where(thetaMap<gradfit)].mean())*180./np.pi
    
    lensedTQU = lensing.displace_map(map, pix,order=5)+0.j


    diffmap =  (lensedTQU-map).real
    rotmap = rotate(diffmap, angle,reshape=False)
    avgrot += rotmap
    
    print((i,angle))
    #io.highResPlot2d(map,out_dir+"unl"+str(i)+".png")
    #io.highResPlot2d(rotmap,out_dir+"rot"+str(i)+".png")


avgrot /= N

io.highResPlot2d(avgrot,out_dir+"avgrot.png")

    
Exemple #3
0
hdulist = fits.open(cat_location)
catalog = hdulist[1].data
lmap = liteMap.liteMapFromFits(map_location)
#io.highResPlot2d(lmap.data,out_dir+"bigmap.png")
RAs = []
DECs = []
widthStampArcminute = 60.
pixScale = 0.5
Nrands = 1000

lmap.info()

# select non-noisy part by trial and error
lmap = lmap.selectSubMap(348, 41, -8.3, 5.3)
io.highResPlot2d(lmap.data, out_dir + "cutmap.png")
lmap.info()
#sys.exit()

ra_range = [lmap.x1 - 360., lmap.x0]
dec_range = [lmap.y0, lmap.y1]

#lmap.data = lmap.data - lmap.data.mean()


def stack_on_map(lite_map,
                 width_stamp_arcminute,
                 pix_scale,
                 ra_range,
                 dec_range,
                 catalog=None,
Exemple #4
0
size_deg_x = Nx*px_arc/60.
area = size_deg_y*size_deg_x
print(("Size deg. " , size_deg_y,"x",size_deg_x))
print(("Area deg.sq. " , area))

templateLM = template()
templateLM.Ny, templateLM.Nx = Ny,Nx
templateLM.pixScaleY, templateLM.pixScaleX = px_rad,px_rad


lxMap,lyMap,modLMap,thetaMap,lx,ly = fmaps.getFTAttributesFromLiteMap(templateLM)

#pwindow = fmaps.pixel_window_function(modLMap,thetaMap,pixScaleX,pixScaleY)
pwindow = fmaps.pixwin(modLMap,px_arc)

io.highResPlot2d(fftshift(pwindow),out_dir+"pwindow.png")


ellmin_cmb = 100
ellmax_cmb = 10000
dell_cmb = 100
lmax = 8000
beamArcmin = 1.4
noiseMukArcmin = 16.0
lknee = 3000
alpha = -4.6

bin_edges = np.arange(ellmin_cmb,ellmax_cmb,dell_cmb)
ellfine = np.arange(ellmin_cmb,ellmax_cmb,1)
binner = stats.bin2D(modLMap,bin_edges)
Exemple #5
0
        print((ix, iy))
        c += 1
        ixs.append(ix)
        iys.append(iy)

print(c)

#sys.exit()

holeArc = 10.
holeFrac = 1.

ra_range = [lmap.x1 - 360., lmap.x0]
dec_range = [lmap.y0, lmap.y1]

stack, cents, recons = fmaps.stack_on_map(lmap, 60., 0.5, ra_range, dec_range,
                                          ras, decs)

io.quickPlot2d(stack, out_dir + "stack.png")

pl = io.Plotter(labelX='Distance from Center (arcminutes)',
                labelY='Temperature Fluctuation ($\mu K$)',
                ftsize=10)
pl.add(cents, recons)
pl._ax.axhline(y=0., ls="--", alpha=0.5)
pl.done(out_dir + "profiles.png")

mask = inp.maskLiteMap(lmap, iys, ixs, holeArc, holeFrac)

io.highResPlot2d(mask.data, out_dir + "mask.png")
Exemple #6
0
    snap, massIndex, freqGHz=150., sourceZ=1100.)
print((z, projectedM500, trueM500, trueR500, pixScaleX, pixScaleY))
kappaMap, szMap, projectedM500, z = sim.getKappaSZ(snap,
                                                   massIndex,
                                                   shape,
                                                   wcs,
                                                   apodWidth=500)

print((projectedM500, z))

print("done")

out_dir = os.environ['WWW']

io.quickPlot2d(kappaMap, out_dir + "kappa.png")  #,crange=[-0.1,0.1])
io.highResPlot2d(szMap, out_dir + "sz.png", crange=[-50, 0])

B = fft_gen(kappaMap, axes=[-2, -1], flags=['FFTW_MEASURE'])

modlmap = get_modlmap(kappaMap)

io.quickPlot2d(modlmap, out_dir + "modlmap.png")  #,crange=[-0.1,0.1])

phi, fphi = kappa_to_phi(kappaMap, modlmap, return_fphi=True)
io.quickPlot2d(phi, out_dir + "phi.png")

alpha_pix = enmap.grad_pixf(fphi)
# alpha_pix2 = enmap.grad_pix(phi)
print((alpha_pix.shape))
# print alpha_pix2.shape
decs = np.random.uniform(bbox[0, 0], bbox[1, 0], size=N)
ras = np.random.uniform(bbox[0, 1], bbox[1, 1], size=N)

print((ras.min() * 180. / np.pi, ras.max() * 180. / np.pi))
print((decs.min() * 180. / np.pi, decs.max() * 180. / np.pi))
# coords = np.vstack((decs,ras))

# print "getting pixels..."
# pixs = gal_map.sky2pix(coords)

# print "binning..."
# dat,xedges,yedges = np.histogram2d(pixs[1,:],pixs[0,:],bins=shape)

mapper = CatMapper(shape, wcs, ras * 180. / np.pi, decs * 180. / np.pi)
gal_map = mapper.get_map()

print((gal_map.sum()))
print((gal_map.sum() - N))

gal_map = enmap.smooth_gauss(gal_map, 2.0 * np.pi / 180. / 60.)

#gal_map = enmap.smooth_gauss(enmap.ndmap(dat.astype(np.float32),wcs),2.0*np.pi/180./60.)
print("plotting...")
io.highResPlot2d(gal_map, out_dir + "galmap.png")

fc = enmap.FourierCalc(shape, wcs)
p2d, d, d = fc.power2d(gal_map)

io.quickPlot2d(np.fft.fftshift(np.log10(p2d)), out_dir + "logp2d.png")
io.quickPlot2d(np.fft.fftshift((p2d)), out_dir + "p2d.png")
Exemple #8
0
                                 height_arcmin=hdeg * 60.,
                                 yoffset_degree=yoffset)

ells = np.arange(0, 5000, 1)
ps = theory.lCl('TT', ells).reshape((1, 1, 5000))

with bench.show("Map generation"):
    mg = enmap.MapGen(shape, wcs, ps)
    taper, w2 = fmaps.get_taper(shape,
                                taper_percent=8.0,
                                pad_percent=2.0,
                                weight=None)
    map_south = mg.get_map() * taper

with bench.show("Rotation init"):
    r = fmaps.MapRotatorEquator(map_south.shape,
                                map_south.wcs,
                                wdeg,
                                hdeg,
                                verbose=True,
                                width_multiplier=0.6,
                                height_multiplier=1.2)
with bench.show("Rotation init"):
    rotmap = r.rotate(map_south)

print((map_south.shape))
print((rotmap.shape))

io.highResPlot2d(map_south, "smap.png")
io.highResPlot2d(rotmap, "rotmap.png")
                             parray_sim.modlmap,
                             lowPass=kellmax,
                             highPass=kellmin), wcs_sim)
        arcmax = 5.
        conv = np.mean(
            np.abs(kappa_recon[arcmap < arcmax] / kappa[arcmap < arcmax]))
        if rank == 0 and k == 0: print((j, conv * 100.))

        # update model with residual
        kappa_iter_recon = kappa_model.copy() + kappa_recon
        #kappa_iter_recon = kappa_model + kappa_recon

        if rank == 0 and k == 0:
            io.quickPlot2d(kappa_iter_recon,
                           out_dir + "rtt_itertot_" + str(j) + ".png")
            io.highResPlot2d(delensed,
                             out_dir + "iterdelensed_" + str(j) + ".png")
            io.quickPlot2d(kappa_recon,
                           out_dir + "rtt_iterinst_" + str(j) + ".png")

    # if rank==0 and k==0:
    #     pl.legendOn()
    #     pl.done(out_dir+"n1ds.png")

    mpibox.add_to_stack("kappaiterrecon", kappa_iter_recon)
    rcents, recon1d = binner_dat.bin(kappa_iter_recon)
    mpibox.add_to_stats("kappaiterrecon1d", recon1d)

mpibox.get_stats()
mpibox.get_stacks()
if rank == 0:
Exemple #10
0
def whiteholes(xs, ys, map):
    mask = maskLiteMap(lmap, iys, ixs, holeArc=5, holeFrac=0.6)
    io.highResPlot2d(mask.data, "mask.png")