コード例 #1
0
    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()
コード例 #2
0
    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()
コード例 #3
0
    def run(self):
        #Get the columns we need, in reduced form
        #since this is not MCMC
        weight = self.weight_col()
        weight = weight / weight.max()
        #Sort the final 500 samples, since they
        #are otherwise un-ordered
        weight[-500:] = np.sort(weight[-500:])

        #x-axis is just the iteration number
        x = np.arange(weight.size)

        #Choose a filename and make a figure for your plot.
        figure, filename = self.figure("nest_weight")

        #Do the plotting, and set the limits and labels
        pylab.plot(x, weight / weight.max())
        #pylab.xlim(-353, -341.5)
        pylab.xlim(0, 8000)
        pylab.xlabel("Iteration number $i$")
        pylab.ylabel(r"$p_i$")

        #Add some helpful text, on the title and the plot itself
        pylab.title("Normalised posterior weight $p_i$", size='medium')
        pylab.text(500,
                   0.4,
                   "Increasing likelihood,\n volume still large",
                   size="small")
        pylab.text(5500, 0.65, "Volume\ndecreasing", size='small')
        pylab.text(6500, 0.12, "Final $n_\mathrm{live}$\npoints", size='small')

        #Return the list of filenames we made
        return [filename]