当前位置: 首页>>代码示例>>Python>>正文


Python FramedPlot.ytitle方法代码示例

本文整理汇总了Python中biggles.FramedPlot.ytitle方法的典型用法代码示例。如果您正苦于以下问题:Python FramedPlot.ytitle方法的具体用法?Python FramedPlot.ytitle怎么用?Python FramedPlot.ytitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在biggles.FramedPlot的用法示例。


在下文中一共展示了FramedPlot.ytitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_scinv_npts

# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import ytitle [as 别名]
    def test_scinv_npts(self, nplot, show=False, reload=False, type="png"):
        """

        Test accuracy as a function of the numer of points used in the
        integration.


        """

        dzl = 0.015
        zlmin = 0.02
        zlmax = 0.6

        from biggles import Points, FramedPlot, PlotKey, Table, Histogram, Curve
        from time import time
        import lensing
        import pcolors

        if self.data is None or reload:
            self.load_example_data()

        # this is old ScinvCalculator, need to make work
        # with new one
        scalc1000 = ScinvCalculator(self.zs, dzl, zlmin, zlmax, npts=1000)

        nptsvals = [100, 200, 300, 400, 500, 600, 700, 800, 900]
        numcheck = len(nptsvals)
        # colors=['black','magenta','blue','green','orange','red']
        colors = pcolors.rainbow(len(nptsvals), "hex")
        scalc = []
        for npts in nptsvals:
            scalc.append(ScinvCalculator(self.zs, dzl, zlmin, zlmax, npts=npts))

        times = numpy.zeros(numcheck, dtype="f8")
        time1000 = 0.0

        # we'll fill this in
        scinv_all = numpy.zeros((numcheck, scalc1000.zlvals.size))

        xlim = [0, scalc1000.zsvals.max()]
        for i in xrange(nplot):
            pz = self.data["pofz"][i]

            print("Doing 1000...", end="")

            tm0 = time()
            scinv1000 = scalc1000.calc_mean_scinv(pz)
            time1000 += time() - tm0

            print("done")

            for j in xrange(numcheck):
                npts = nptsvals[j]
                print("%d " % npts, end="")
                tm0 = time()
                scinv_all[j, :] = scalc[j].calc_mean_scinv(pz)
                times[j] += time() - tm0

            print("\nplotting")

            # plot the p(z)
            tab = Table(3, 1)

            binsize = scalc1000.zsvals[1] - scalc1000.zsvals[0]
            pzh = Histogram(pz, x0=scalc1000.zsvals[0], binsize=binsize)
            plt_pzh = FramedPlot()
            plt_pzh.xrange = xlim

            plt_pzh.xtitle = r"$z_s$"
            plt_pzh.ytitle = r"$P(z_s)$"
            plt_pzh.add(pzh)
            tab[0, 0] = plt_pzh

            # plot scinv for each npts value
            plt_scinv = FramedPlot()
            plt_scinv.xrange = xlim

            scinv_plots = []
            for j in xrange(numcheck):
                npts = nptsvals[j]
                p = Curve(scalc[j].zlvals, scinv_all[j, :], type="solid", color=colors[j])
                p.label = "npts: %d" % npts

                plt_scinv.add(p)
                scinv_plots.append(p)

            scinv_key = PlotKey(0.95, 0.9, scinv_plots, halign="right")
            plt_scinv.add(scinv_key)

            plt_scinv.ylabel = r"$\langle \Sigma_{crit}^{-1}(z_{lens}) \rangle$"
            plt_scinv.xlabel = r"$z_{lens}$"
            plt_scinv.yrange = [0, 2.1e-4]

            tab[1, 0] = plt_scinv

            # ratio to 1000 points

            plt_rat = FramedPlot()
            plt_rat.xrange = xlim
            plt_rat.yrange = [1 - 1.0e-2, 1 + 1.0e-2]
#.........这里部分代码省略.........
开发者ID:esheldon,项目名称:espy,代码行数:103,代码来源:sigmacrit.py

示例2: test_scinv_dz

# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import ytitle [as 别名]
    def test_scinv_dz(self, beg, end, yrange=[0, 2.1e-4], show=False, reload=False, type="png"):
        """

        Test accuracy of interpolating scinv as a function of dzl, the
        lens redshift spacing.

        """
        import biggles
        from biggles import Points, FramedPlot, PlotKey, Table, Histogram, Curve
        from time import time
        import lensing
        import pcolors

        biggles.configure("default", "fontface", "HersheySans")
        biggles.configure("default", "fontsize_min", 1.3)

        zsmin = self.zs[0]
        zsmax = self.zs[-1]

        zlmin = 0.00
        zlmax = 1.0

        # dzl_vals = numpy.linspace(0.001,0.015,10)
        dzl_vals = numpy.linspace(0.001, 0.015, 4)
        nzl_vals = ((zlmax - zlmin) / dzl_vals).astype("i8")

        numcheck = len(dzl_vals)
        colors = pcolors.rainbow(numcheck, "hex")
        scalc = []
        for nzl in nzl_vals:
            s = ScinvCalculator(zlmin, zlmax, nzl, zsmin, zsmax, npts=100)
            scalc.append(s)

        times = numpy.zeros(numcheck, dtype="f8")

        # we'll fill this in
        # scinv_all = numpy.zeros( (numcheck, scalc[0].zlvals.size) )

        xlim = [0, zsmax]
        for i in xrange(beg, end):
            scinv_all = []
            pz = self.data["pofz"][i]

            # print(pz)

            for j in xrange(numcheck):
                dzl = dzl_vals[j]
                nzl = nzl_vals[j]
                print("    nzl: %s dzl: %g" % (nzl, dzl))
                tm0 = time()
                # scinv_all[j,:] = scalc[j].calc_mean_scinv(pz)
                sc = scalc[j].calc_mean_scinv(self.zs, pz)
                # sc=sc.clip(min=0.0)
                # print("sc",j,sc)
                scinv_all.append(sc)
                times[j] += time() - tm0

            print("\nplotting")

            # plot the p(z)
            tab = Table(3, 1)

            binsize = self.zs[1] - self.zs[0]
            pzh = Histogram(pz, x0=self.zs[0], binsize=binsize)
            plt_pzh = FramedPlot()
            plt_pzh.xrange = xlim

            plt_pzh.xtitle = r"$z_s$"
            plt_pzh.ytitle = r"$P(z_s)$"
            plt_pzh.add(pzh)
            tab[0, 0] = plt_pzh
            # plt_pzh.show()

            # plot scinv for each dzl
            plt_scinv = FramedPlot()
            plt_scinv.xrange = xlim

            scinv_plots = []
            for j in xrange(numcheck):
                dzl = dzl_vals[j]
                nzl = nzl_vals[j]
                p = Curve(scalc[j].zlvals, scinv_all[j], type="solid", color=colors[j])
                p.label = r"$nz_{lens}: %s dz_{lens}: %0.3f$" % (nzl, dzl)

                plt_scinv.add(p)
                scinv_plots.append(p)

            scinv_key = PlotKey(0.95, 0.9, scinv_plots, halign="right")
            plt_scinv.add(scinv_key)

            plt_scinv.ylabel = r"$\Sigma_{crit}^{-1}(z_{lens})$"
            plt_scinv.xlabel = r"$z_{lens}$"
            plt_scinv.yrange = yrange

            # plt_scinv.show()
            tab[1, 0] = plt_scinv

            # %diff to best dz

            plt_pdiff = FramedPlot()
#.........这里部分代码省略.........
开发者ID:esheldon,项目名称:espy,代码行数:103,代码来源:sigmacrit.py


注:本文中的biggles.FramedPlot.ytitle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。