Example #1
0
                    fname = f"/scratch/r/rbond/msyriac/data/scratch/tilec/test_sim_galtest_nofg_{version}_00_00{seed}_deep56/scovs_{i}_{j}.npy"
                    scov = enmap.enmap(np.load(fname),modlmap.wcs)

                    fname = f"/scratch/r/rbond/msyriac/data/scratch/tilec/test_sim_galtest_nofg_{version}_00_00{seed}_deep56/unsmoothed_noise_cov_{i}_{j}.npy"
                    try:
                        ncov = enmap.enmap(np.load(fname),modlmap.wcs)
                    except:
                        ncov = 0

                    ccov = scov + ncov
                else:
                    fname = f"/scratch/r/rbond/msyriac/data/scratch/tilec/test_sim_galtest_nofg_{version}_00_00{seed}_deep56/coadd_cov_{i}_{j}.npy"
                    ccov = enmap.enmap(np.load(fname),modlmap.wcs)


                usig[...,i,j] = usig[...,j,i] = ccov.copy()
                print(i,j)

    print("eigs...")
    emap = modlmap*0
    # v = np.linalg.eigh(usig[modlmap<6000,...][500,...])[0]
    # print(v)
    # print(v.shape)
    emap[modlmap<6000] = np.linalg.eigh(usig[modlmap<6000,...])[0][...,0]
    #emap = np.linalg.eigh(usig)[0][:,:,0]
    np.save("emap_tot",emap)
else:
    emap = np.load("emap_tot.npy")
emap[emap<-1e-10] = np.nan
io.power_crop(np.fft.fftshift(emap),300,"eigmapdet.png",ftrans=False,lim=[-0.01,0.01])
    return p, cents, p1d


seeds = [12, 13]

narrays = len(qids)

for comp in ['cmb']:

    pl1 = io.Plotter('Cell', xyscale='loglin', ylabel='$W$')
    pl2 = io.Plotter('Cell')

    for seed in seeds:
        mname = f"/scratch/r/rbond/msyriac/data/depot/tilec/map_joint_{version}_00_00{seed}_deep56/tilec_single_tile_deep56_cmb_map_joint_{version}_00_00{seed}.fits"
        p2d, cents, p1d = pow(enmap.read_map(mname))
        io.power_crop(p2d, 150, f"det2d{seed}comp.png", lim=[-10, 1])
        #io.plot_img(np.log10(p2d),f"det2d{seed}comp.png",lim=[-10,1],aspect='auto')
        #continue # !!!

        for i in range(narrays):
            qid = qids[i]

            #if qid!='p08': continue

            fname = f"/scratch/r/rbond/msyriac/data/depot/tilec/map_joint_{version}_00_00{seed}_deep56/tilec_single_tile_deep56_cmb_map_joint_{version}_00_00{seed}_{qid}_weight.fits"
            w2d = enmap.read_map(fname)
            cents, w1d = binner.bin(w2d)
            pl1.add(cents, w1d, ls={12: '-', 13: '--'}[seed], color=f'C{i}')

            io.power_crop(np.fft.fftshift(w2d),
                          150,
Example #3
0

lmap = mask.lmap()
lymap,lxmap = lmap
# def model(x,width,amplitude,sigma):
#     mmap = 1-amplitude * np.exp(-lymap**2./2./sigma**2.)
#     mmap[lxmap>width/2.] = 1
#     mmap[lxmap<-width/2.] = 1
#     return mmap

def model(x,width,amplitude,sigma):
    mmap = (1-amplitude * np.exp(-lymap**2./2./sigma**2.))* (1-np.exp(-lxmap**2./2./width**2.))
    return mmap

m = model(0,100,1,3000)
io.power_crop(np.fft.fftshift(m),Ncrop,'model.png',ftrans=False)
# sys.exit()

# io.hplot(enmap.downgrade(isim,4),'isim')
# io.hplot(enmap.downgrade(tmap,4),'tmap')


kisim1 = ffunc(isim1[0])
kisim2 = ffunc(isim2[0])
ktmap1 = ffunc(tmap1[0])
ktmap2 = ffunc(tmap2[0])

pcross2d1 = pfunc(kisim1,ktmap1)
pcross2d2 = pfunc(kisim2,ktmap2)
psim2d1 = pfunc(kisim1,kisim1)
psim2d2 = pfunc(kisim2,kisim2)
from __future__ import print_function
from orphics import maps,io,cosmology,stats
from pixell import enmap
import numpy as np
import os,sys
from tilec import covtools
from tilec.ilc import CTheory

qid = 'p01'

scov = enmap.read_map("/scratch/r/rbond/msyriac/dump/unsmoothed_debeamed_%s_%s.fits" % (qid,qid))
dncov = enmap.read_map("/scratch/r/rbond/msyriac/dump/smoothed_noise_%s_%s.fits" % (qid,qid))
beamsq = enmap.read_map("/scratch/r/rbond/msyriac/dump/beamsq_%s_%s.fits" % (qid,qid))

io.power_crop(scov,200,"inv_scov.png")
io.power_crop(dncov,200,"inv_dncov.png")
io.power_crop(beamsq,200,"inv_beamsq.png")

bin_edges = np.arange(80,3000,20)
modlmap = scov.modlmap()
binner = stats.bin2D(modlmap,bin_edges)

# fwhm = 33.
# lefts = bin_edges[:-1]
# rights = bin_edges[1:]
# cents = binner.centers
# ms = maps.gauss_beam(rights,fwhm)/maps.gauss_beam(lefts,fwhm)
# pl = io.Plotter(xyscale='linlin',xlabel='l',ylabel='Bright/Bleft')
# pl.add(cents,ms)
# pl.done("inv_brat.png")
# sys.exit()
Example #5
0
        #     print(ksol[px[0]-11,px[1]])
        #     print(optile[px[0],px[1]])
        #     print(optile[px[0]-1,px[1]])
        #     print(modlmap[px[0],px[1]])
        #     print(modlmap[px[0]-1,px[1]])
        #     # pftile = ptile
        #     # pftile[modlmap>300] = 0
        #     # print(np.sort(pftile[pftile>0]))
        #     # print(modlmap[np.isclose(ptile,1.52256073e+02)])
        #     # io.plot_img(np.log10(np.fft.fftshift(ptile)),os.environ['WORK']+"/tiling/ptile_%d_smap" % i)
        #     # io.hplot(enmap.enmap(np.log10(np.fft.fftshift(ptile)),ewcs),os.environ['WORK']+"/tiling/phtile_%d_smap" % i)
        smap = enmap.ifft(kbeam * enmap.enmap(ksol, ewcs),
                          normalize='phys').real
        if solution == 'CMB':
            io.hplot(smap, os.environ['WORK'] + "/tiling/tile_%d_smap" % i)
            io.power_crop(np.real(ksol * ksol.conj()), 100,
                          os.environ['WORK'] + "/tiling/ptile_%d.png" % i)
        # sys.exit()
        ta.update_output(solution, smap, inserter)
    #ta.update_output("processed",c*civar,inserter)
    #ta.update_output("processed_ivar",civar,inserter)
    #pmap = ilc.do_ilc
    #ta.update_output("processed",pmap,inserter)
print("Rank %d done" % comm.rank)
for solution in solutions:
    pmap = ta.get_final_output(solution)
    if comm.rank == 0:
        io.hplot(pmap, os.environ['WORK'] + "/tiling/map_%s" % solution)
        mask = sints.get_act_mr3_crosslinked_mask("deep56")
        io.hplot(
            enmap.extract(pmap, mask.shape, mask.wcs) * mask,
            os.environ['WORK'] + "/tiling/mmap_%s" % solution)
Example #6
0
version = "noLFI_nohigh_test"

mask = sints.get_act_mr3_crosslinked_mask(region)
modlmap = mask.modlmap()
lmap = mask.lmap()
bin_edges = np.arange(20, 6000, 80)
binner = stats.bin2D(modlmap, bin_edges)


def pow(x, y=None):
    k = enmap.fft(x, normalize='phys')
    ky = enmap.fft(y, normalize='phys') if y is not None else k
    p = (k * ky.conj()).real
    cents, p1d = binner.bin(p)
    return p, cents, p1d


seeds = [12]  #,13]

qids = "d56_04,d56_05,d56_06,p04,p05,p06".split(',')
narrays = len(qids)

for comp in ['cmb']:
    for i in range(narrays):
        qid = qids[i]
        for seed in seeds:

            fname = f"/scratch/r/rbond/msyriac/data/scratch/tilec/test_sim_galtest_nofg_{version}_00_00{seed}_deep56/dncovs_{i}_{i}.npy"
            scov = enmap.enmap(np.load(fname), modlmap.wcs)
            io.power_crop(scov, 600, f"dn2d_det_{qid}_{seed}.png")
# seeds = [12]

versions = ['test_sim_galtest_final']
seeds = [12,13]



for version in versions:
    pl = io.Plotter(xyscale='linlog',scalefn = lambda x: x**2./2./np.pi,xlabel='l',ylabel='D')
    for seed in seeds:
        csfile = tutils.get_generic_fname(tdir,region,'cmb',deproject=None,data_comb=dcomb,version=version,sim_index=seed)
        imap = enmap.read_map(csfile)
        modlmap = imap.modlmap()
        k = enmap.fft(imap,normalize='phys')
        p2d = p(k)
        io.power_crop(p2d,300,f"cp2d_{version}.png")
        binner = stats.bin2D(modlmap,bin_edges)
        cents,p1d = binner.bin(p2d)
        pl.add(cents,p1d,lw=1,alpha=0.8,label=f'{seed}')
    pl._ax.set_ylim(10,3e5)
    pl.done("cpowall_%s.png" % version)


# #This snippet discovered that sim_index=12 is the first instance of break-down
# nsims = 13

# p = lambda x: (x*x.conj()).real

# bin_edges = np.arange(20,6000,20)

# pl = io.Plotter(xyscale='linlog',scalefn = lambda x: x**2./2./np.pi,xlabel='l',ylabel='D')
Example #8
0
    #omap = enmap.read_map('/scratch/r/rbond/msyriac/data/tilec/omar/dataCoadd_combined_I_s14&15_deep56.fits')
    omap = enmap.read_map(
        '/scratch/r/rbond/msyriac/data/tilec/omar/preparedMap_T_s14&15_deep56.fits'
    ) * 2.726e6
    omar_mask = enmap.read_map(
        '/scratch/r/rbond/msyriac/data/tilec/omar/mask_s14&15_deep56.fits')
    omar_w2 = np.mean(omar_mask**2.)
    # io.hplot(enmap.downgrade(omap,4),"omap")
    # io.hplot(enmap.downgrade(omask,4),"omask")
    # sys.exit()
    okmap = enmap.fft(omap, normalize='phys')
    op2d = np.real(okmap * okmap.conj())

io.power_crop(p2d,
              200,
              "pimg_%s_%s.png" % (args.solution, args.region),
              lim=lim)
io.power_crop(nmap,
              200,
              "nimg_%s_%s.png" % (args.solution, args.region),
              lim=lim)

sel = np.logical_and(modlmap > lmin, modlmap < lmax)
xs = modlmap[sel].reshape(-1)
ys = p2d[sel].reshape(-1)

pl = io.Plotter(xyscale='linlog', xlabel='l', ylabel='C')
pl._ax.scatter(xs, ys)
#pl._ax.set_ylim(lim[0],lim[1])
pl.done("pscatter_%s_%s.png" % (args.solution, args.region))
Example #9
0
"""

# ti_noise2d = enmap.read_map("%stilec_single_tile_%s_cmb_map_v1.0.0_rc_joint_noise.fits" % (tpath,region))
# ti_nosz_noise2d = enmap.read_map("%stilec_single_tile_%s_cmb_deprojects_comptony_map_v1.0.0_rc_joint_noise.fits" % (tpath,region))
# ti_cross_noise2d = enmap.read_map("%stilec_single_tile_%s_cmb_deprojects_comptony_map_v1.0.0_rc_joint_cross_noise.fits" % (tpath,region))

ti_map = enmap.read_map("%stilec_single_tile_%s_cmb_map_v1.0.0_rc_joint.fits" %
                        (tpath, region))
ti_nosz_map = enmap.read_map(
    "%stilec_single_tile_%s_cmb_deprojects_comptony_map_v1.0.0_rc_joint.fits" %
    (tpath, region))
ti_noise2d = pow2(ti_map, ti_map, tkbeam, tkbeam)
ti_nosz_noise2d = pow2(ti_nosz_map, ti_nosz_map, tkbeam_nosz, tkbeam_nosz)
ti_cross_noise2d = pow2(ti_map, ti_nosz_map, tkbeam, tkbeam_nosz)

io.power_crop(ti_noise2d, Nplot, "ti_noise2d.png", ftrans=True)
io.power_crop(ti_nosz_noise2d, Nplot, "ti_nosz_noise2d.png", ftrans=True)
io.power_crop(ti_cross_noise2d, Nplot, "ti_cross_noise2d.png", ftrans=True)

tmap = enmap.read_map("%sdataCoadd_combined_I_s14&15_%s.fits" %
                      (opath, region))
oi_noise2d = pow(tmap)

io.power_crop(oi_noise2d, Nplot, "oi_noise2d.png", ftrans=True)

cents, ti_noise1d = binner.bin(ti_noise2d)
cents, ti_nosz_noise1d = binner.bin(ti_nosz_noise2d)
cents, ti_cross_noise1d = binner.bin(ti_cross_noise2d)
cents, oi_noise1d = binner.bin(oi_noise2d)

pl = io.Plotter(xlabel='l', ylabel='C', xyscale='linlog')
    p2d, cents, p1d = pow(imap)
    lp2d = np.log10(p2d)
    sel = np.logical_and(modlmap < 1300, modlmap > 1100)
    vals = lp2d[sel]
    # print(vals)
    # print(vals.mean(),vals.max(),vals.min(),vals.std())
    hist, edges = np.histogram(vals, bins=np.linspace(-15, 5, 300))
    hcents = (edges[1:] + edges[:-1]) / 2.
    pl2 = io.Plotter(xlabel='v', ylabel='N')
    pl2.add(hcents, hist)
    pl2.done(f"detvalhist{seed}.png")

    pl.add(cents, p1d, label=f"{seed}")

    llim = 0
    io.power_crop(p2d, 150, f"det2d{seed}comp.png", lim=[-10, 1])
    badinds = np.argwhere(np.logical_and(np.log10(p2d) > llim, modlmap > 1000))
    print(modlmap[np.logical_and(np.log10(p2d) > llim, modlmap > 1000)])
    #sys.exit()
    badinds = np.argwhere(np.logical_and(np.log10(p2d) > llim, modlmap > 1000))
    if len(badinds) > 0:
        ind = 0
        print(badinds[ind])
        print(modlmap[badinds[ind][0], badinds[ind][1]])
        print(modlmap[badinds[ind][0] + 10, badinds[ind][1] + 10])
        print(p2d[badinds[ind][0], badinds[ind][1]])
        print(p2d[badinds[ind][0] + 10, badinds[ind][1] + 10])

    p2d[np.logical_and(np.log10(p2d) > llim, modlmap > 1000)] = np.nan
    #p2d[sel] = np.nan
    io.power_crop(p2d, 150, f"mdet2d{seed}comp.png", lim=[-10, 1])