def plot(self):
     super(GrandPlot, self).plot()
     ell = self.load_file("cmb_cl", "ell")
     for name in ['tt', 'ee', 'te', 'bb']:
         c_ell = self.load_file("cmb_cl", name)
         pylab.loglog(ell, abs(c_ell), label=name.upper())
     pylab.legend()
     pylab.grid()
     pylab.xlabel("$\\ell$")
     pylab.ylabel("$\\ell(\\ell+1) C_\\ell/2\\pi / uK^2$")
 def plot_section(self, section, label, p_name='p_k'):
     kh = self.load_file(section, "k_h")
     z = self.load_file(section, "z")
     p = self.load_file(section, p_name)
     if (p < 0).all(): p *= -1
     z = np.atleast_1d(z)
     kh = np.atleast_1d(kh)
     p = np.atleast_2d(p)
     nk = len(kh)
     nz = len(z)
     if p.shape == (nz, nk):
         p = p.T
     pylab.loglog(kh, p[:, 0], label=label)
    def plot(self):
        super(ShearCorrelationMinusPlot, self).plot()
        nbin = 0
        for i in range(1, 100):
            filename = self.file_path("shear_xi_minus",
                                      "bin_{0}_{0}".format(i))
            if os.path.exists(filename):
                nbin += 1
            else:
                break
        if nbin == 0:
            IOError("No data for plot: %s" % self.__class__.__name__[:-4])

        theta = self.load_file("shear_xi_minus", "theta")
        sz = 1.0 / (nbin + 2)
        for i in range(1, nbin + 1):
            for j in range(1, i + 1):
                rect = (i * sz, j * sz, sz, sz)
                self.figure.add_axes(rect)
                #pylab.ploy()
                #pylab.subplot(nbin, nbin, (nbin*nbin)-nbin*(j-1)+i)
                xi = self.load_file("shear_xi_minus",
                                    "bin_{0}_{1}".format(i, j))
                pylab.loglog(theta, xi)
                pylab.xlim(1e-4, 1e-1)
                pylab.ylim(2e-7, 1e-3)
                if i == 1 and j == 1:
                    pylab.xlabel("$\\theta$")
                    pylab.ylabel("$\\xi_+(\\theta)$")
                else:
                    pylab.gca().xaxis.set_ticklabels([])
                    pylab.gca().yaxis.set_ticklabels([])

                pylab.gca().tick_params(length=0.0, which='minor')
                pylab.gca().tick_params(length=3.0, which='major')
                pylab.gca().tick_params(labelsize=10)

                pylab.text(1.5e-3,
                           1.8e-4,
                           "(%d,%d)" % (i, j),
                           fontsize=8,
                           color='red')

                pylab.grid()
    def plot_section(self, section):
        nbin = 0
        for i in range(1, 100):
            filename = self.file_path(section, "bin_{0}_{0}".format(i))
            if os.path.exists(filename):
                nbin += 1
            else:
                break
        if nbin == 0:
            IOError("No data for plot: %s" % self.__class__.__name__[:-4])

        ell = self.load_file(section, "ell")
        sz = 1.0 / (nbin + 2)
        for i in range(1, nbin + 1):
            for j in range(1, i + 1):
                rect = (i * sz, j * sz, sz, sz)
                self.figure.add_axes(rect)
                #pylab.ploy()
                #pylab.subplot(nbin, nbin, (nbin*nbin)-nbin*(j-1)+i)
                cl = self.load_file(section, "bin_{0}_{1}".format(i, j))

                if all(cl <= 0):
                    cl *= -1
                pylab.loglog(ell, ell * (ell + 1.) * cl / 2 / np.pi)
                pylab.ylim(*self.ylim)
                if i == 1 and j == 1:
                    pylab.xlabel("$\\ell$")
                    pylab.ylabel("$\\ell (\\ell+1) C_\\ell / 2 \\pi$")
                else:
                    pylab.gca().xaxis.set_ticklabels([])
                    pylab.gca().yaxis.set_ticklabels([])
                pylab.gca().tick_params(length=0.0, which='minor')
                pylab.gca().tick_params(length=3.0, which='major')
                pylab.gca().tick_params(labelsize=10)

                if section == "shear_cl":
                    pylab.text(1.5 * ell.min(),
                               1.8e-4,
                               "(%d,%d)" % (i, j),
                               fontsize=8,
                               color='red')
                    pylab.grid()