Example #1
0
    def plotCls(self,saveFile,keys=None,xlimits=None,ylimits=None,transform=True,showBinnedTheory=False,scaleX='linear',scaleY='linear'):

        nsigma = 2.
        
        binCenters = self.binner.getBinCenters()

        if transform:
            ylab = "$\ell C_{\ell}$"
            mult = binCenters
            multTh = 1.#binCenters*0.+1.
        else:
            ylab = "$C_{\ell}$"
            mult = binCenters*0.+1.
            multTh = 0.#binCenters*0.
            
        pl = Plotter(labelX="$\ell$",labelY=ylab,scaleX=scaleX,scaleY=scaleY)


        
        if keys is None: keys = list(self.datas.keys())
        for key in keys:

            dat = self.datas[key]

            if dat['covmat'] is None:
                #This is a theory curve
                ells = np.array(list(range(len(dat['unbinned']))))
                if dat['isFit']:
                    ls="--"
                    lw=1
                else:
                    ls="-"
                    lw=2
                    
                base_line, = pl.add(ells,(multTh*(ells-1)+1.)*dat['unbinned'],label=dat['label'],lw=lw,ls=ls)
                if dat['isFit']:
                    pl._ax.fill_between(ells,(multTh*(ells-1)+1.)*dat['unbinned']*(1.-nsigma*dat['amp'][1]/dat['amp'][0]),(multTh*(ells-1)+1.)*dat['unbinned']*(1.+nsigma*dat['amp'][1]/dat['amp'][0]),alpha=0.3, facecolor=base_line.get_color())
                    
                if showBinnedTheory:
                    pl.add(binCenters[:len(dat['binned'])],mult[:len(dat['binned'])]*dat['binned'],
                           ls='none',marker='x',mew=2,markersize=10,label=dat['label']+' binned')
                  
            else:
                errs = np.sqrt(np.diagonal(dat['covmat']))
                print((dat['label']))
                pl.addErr(binCenters[:len(dat['binned'])],mult[:len(dat['binned'])]*dat['binned'],mult[:len(dat['binned'])]*errs,label=dat['label'],marker='o',elinewidth=2,markersize=10,mew=2,)


        [i.set_linewidth(2.0) for i in list(pl._ax.spines.values())]
        pl._ax.tick_params(which='major',width=2)
        pl._ax.tick_params(which='minor',width=2)
        pl._ax.axhline(y=0.,ls='--')
    
        if not(xlimits is None):
            pl._ax.set_xlim(*xlimits)
        else:
            pl._ax.set_xlim(self.binner.bin_edges[0],self.binner.bin_edges[-1])    
        if not(ylimits is None): pl._ax.set_ylim(*ylimits)
        pl.legendOn(loc='lower left',labsize=10)
        pl.done(saveFile)
Example #2
0
def stat_analysis(cutouts, binsize, arcmax, cents, modRMaps):
    profiles = []
    for i in range(0, len(cutouts)):
        thetaRange = np.arange(0., arcmax, binsize)
        breali = bin2D(modRMaps[i] * 180. * 60. / np.pi, thetaRange)
        a = breali.bin(cutouts[i])[1]
        profiles.append(a)
    statistics = stats.getStats(profiles)
    mean = statistics['mean']
    error = statistics['errmean']
    covmat = statistics['cov']
    corrcoef = stats.cov2corr(covmat)
    io.quickPlot2d(corrcoef, 'corrcoef.png')
    pl = Plotter(labelX='Distance from Center (arcminutes)',
                 labelY='Temperature Fluctuation ($\mu K$)',
                 ftsize=10)
    pl.add(cents, mean)
    pl.addErr(cents, mean, yerr=error)
    pl._ax.axhline(y=0., ls="--", alpha=0.5)
    pl.done(out_dir + "error.png")
Example #3
0
            listAllReconPower[polComb] = np.vstack(
                (listAllReconPower[polComb], rcvInputPowerMat))

    statsCross = {}
    statsRecon = {}

    pl = Plotter(scaleY='log')
    pl.add(ellkk, Clkk, color='black', lw=2)

    for polComb, col in zip(polCombList, colorList):
        statsCross[polComb] = getStats(listAllCrossPower[polComb])
        pl.addErr(centers,
                  statsCross[polComb]['mean'],
                  yerr=statsCross[polComb]['errmean'],
                  ls="none",
                  marker="o",
                  markersize=8,
                  label="recon x input " + polComb,
                  color=col,
                  mew=2,
                  elinewidth=2)

        statsRecon[polComb] = getStats(listAllReconPower[polComb])
        fp = interp1d(centers,
                      statsRecon[polComb]['mean'],
                      fill_value='extrapolate')
        pl.add(ellkk, (fp(ellkk)) - Clkk, color=col, lw=2)

        Nlkk2d = qest.N.Nlkk[polComb]
        ncents, npow = stats.binInAnnuli(Nlkk2d, p2d.modLMap, bin_edges)
        pl.add(ncents, npow, color=col, lw=2, ls="--")
Example #4
0
def stack_on_map(lite_map,
                 width_stamp_arcminute,
                 pix_scale,
                 ra_range,
                 dec_range,
                 catalog=None,
                 n_random_points=None):
    width_stamp_degrees = width_stamp_arcminute / 60.
    Np = np.int(width_stamp_arcminute / pix_scale + 0.5)
    pad = np.int(Np / 2 + 0.5)
    print("Expected width in pixels = ", Np)
    lmap = lite_map
    stack = 0
    N = 0

    if catalog is not None:
        looprange = range(0, len(catalog))
        assert n_random_points is None
        random = False
    else:
        assert n_random_points is not None
        assert len(ra_range) == 2
        assert len(dec_range) == 2
        looprange = range(0, n_random_points)
        random = True
    print(looprange)
    for i in looprange:
        banana = True
        mass = catalog[i][10]
        if random:
            ra = np.random.uniform(*ra_range)
            dec = np.random.uniform(*dec_range)
        if random == False:
            ra = catalog[i][1]  #1 for ACT catalog 2 for SDSS
            dec = catalog[i][2]  #2 for ACT catalog 3 for SDSS
        for j in range(0, 2130):
            distance = np.sqrt((ra - RAps[j])**2 + (dec - DECps[j])**2)
            crit = 0.25
            if distance < crit:
                banana = False
                print('too close')
        ix, iy = lmap.skyToPix(ra, dec)
        if ix >= pad and ix < lmap.Nx - pad and iy >= pad and iy < lmap.Ny - pad and banana == True and mass > 8:
            print(i)
            #print(ra,dec)
            smap = lmap.selectSubMap(ra - width_stamp_degrees / 2.,
                                     ra + width_stamp_degrees / 2.,
                                     dec - width_stamp_degrees / 2.,
                                     dec + width_stamp_degrees / 2.)
            #print (smap.data.shape)
            #cutout = zoom(smap.data.copy(),zoom=(float(Np)/smap.data.shape[0],float(Np)/smap.data.shape[1])
            cutout = resize(smap.data.copy(),
                            output_shape=(Np, Np)) - randomstack
            xMap, yMap, modRMap, xx, yy = fmaps.getRealAttributes(smap)
            dt = pix_scale
            arcmax = 20.
            thetaRange = np.arange(0., arcmax, dt)
            breali = bin2D(modRMap * 180. * 60. / np.pi, thetaRange)
            a = breali.bin(cutout)[1]
            profiles.append(a)
            io.quickPlot2d(cutout, str(i) + "cutout.png")
            #print (cutout.shape)
            stack = stack + cutout
            N = N + 1
        else:
            print("skip")
    stack = stack / N  #-randomstack
    #print(stack.shape())
    #print(smap.data.shape)
    # print(stack)
    print(N)
    statistics = stats.getStats(profiles)
    mean = statistics['mean']
    error = statistics['errmean']
    corrcoef = statistics['corr']
    covmat = statistics['covmat']
    print(mean / error)
    np.save('statistics', statistics)
    #np.save('newrandomstamp',stack)
    # io.quickPlot2d(stack,out_dir+"newACTstack.png")
    dt = pix_scale
    arcmax = 20.
    thetaRange = np.arange(0., arcmax, dt)
    breal = bin2D(modRMap * 180. * 60. / np.pi, thetaRange)
    cents, recons = breal.bin(stack)
    pl = Plotter(labelX='Distance from Center (arcminutes)',
                 labelY='Temperature Fluctuation ($\mu K$)',
                 ftsize=10)
    pl.add(cents, mean)
    pl.addErr(cents, mean, yerr=error)
    pl._ax.axhline(y=0., ls="--", alpha=0.5)
    pl.done(out_dir + "error.png")
    print(covmat)
    io.quickPlot2d(covmat, 'covmat.png')
    return (stack, cents, recons)
Example #5
0
        ".png")

ellfac = el_ilc * (el_ilc + 1.) / (2. * np.pi) * 1e12 * constDict['TCMB']**2
ellfac2 = eln * (eln + 1.) / (2. * np.pi) * 1e12 * constDict['TCMB']**2

pl = Plotter(labelX="$\ell$",
             labelY="$C_\ell \, (1 + \ell) \ell / 2\pi \, [\mu \mathrm{K}]$",
             ftsize=12,
             figsize=(8, 6),
             scaleY='log')
pl._ax.set_ylim(1, 10000)
pl._ax.set_xlim(100., 5000.)
pl.add(el_ilc, cls_ilc * ellfac, color='black')
pl.add(eln, nl * ellfac2, label="$N_\ell$ CCATP")
pl.add(eln2, nl2 * ellfac2, label="$N_\ell$ SO")
pl.addErr(el_ilc, cls_ilc * ellfac, err_ilc * ellfac, label="CCATP")
pl.addErr(el_ilc2 + 10, cls_ilc2 * ellfac, err_ilc2 * ellfac, label="SO")
#pl.legend(loc='upper right',labsize=10)
pl.done(outDir + experimentName + "_cmb_cls" + constraint_tag[cf] + ".png")
ls = np.arange(2, 8000, 10)

pl = Plotter(labelX="$\ell$",
             labelY="$C_\ell \, (1 + \ell) \ell / 2\pi \, [\mu \mathrm{K}]$",
             ftsize=12,
             figsize=(8, 6),
             scaleY='log')
pl._ax.set_ylim(0.1, 1000)
pl._ax.set_xlim(100., 8000.)
pl.add(el_il, cls_il * ellfac, color='black')
pl.add(elnc, nlc * ellfac2, label="$N_\ell$ CCATP")
pl.add(elnc2, nlc2 * ellfac2, label="$N_\ell$ SO")
Example #6
0
xint.generateCls(frange)

Clgg = xint.getCl("cmass", "cmass")
Clkg = xint.getCl("cmb", "cmass")

b = coreBinner(snrange)
cents, clkgbinned = b.binned(frange, Clkg)

from scipy.interpolate import interp1d
clkgint = interp1d(frange, Clkg)

print(("kg S/N ", sn))
pl = Plotter(labelX="$L$", labelY="$LC_L$")
pl.add(frange, frange * Clkg)
pl.addErr(cents,
          clkgint(cents) * cents,
          yerr=np.array(errs) * cents,
          marker="o")
#pl.legendOn(loc='lower right',labsize=12)
pl._ax.set_xlim(0, 2000)
#pl._ax.set_ylim(-0.2e-7,1.6e-7)
pl._ax.axhline(y=0., ls="--", alpha=0.5)
pl.done("output/errs.png")

zcents, dndz = np.loadtxt("data/hscd6.csv", unpack=True)
xint.addNz("hsc", zcents, dndz[1:])
xint.generateCls(snrange)

Clss = xint.getCl("hsc", "hsc")
Clks = xint.getCl("cmb", "hsc")

ngal = 12.0