How to use the getdist.plots.GetDistPlotter function in getdist

To help you get started, we’ve selected a few getdist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cmbant / getdist / paramgrid / batchjob_args.py View on Github external
self.parser.add_argument('--size_inch', type=float, default=None, help='output subplot size in inches')
            self.parser.add_argument('--nx', default=None, help='number of plots per row')
            self.parser.add_argument('--outputs', nargs='+', default=['pdf'], help='output file type (default: pdf)')

        args = self.parser.parse_args(vals)
        self.args = args
        if args.batchPath:
            self.batch = batchjob.readobject(args.batchPath)
            if self.batch is None:
                raise Exception('batchPath %s does not exist or is not initialized with makeGrid.py' % args.batchPath)
            if self.doplots:
                import getdist.plots as plots
                from getdist import paramnames

                if args.paramList is not None: args.paramList = paramnames.ParamNames(args.paramList)
                g = plots.GetDistPlotter(chain_dir=self.batch.batchPath)
                if args.size_inch is not None: g.settings.set_with_subplot_size(args.size_inch)
                return self.batch, self.args, g
            else:
                return self.batch, self.args
        else:
            return None, self.args
github williamjameshandley / fgivenx / planck_style / planckStyle.py View on Github external
output_base_dir = getdist.output_base_dir or batchjob.getCodeRootPath()

H0_gpe = [70.6, 3.3]

# various Omegam sigma8 constraints for plots
def planck_lensing(omm, sigma):
    # g60_full
    return  (0.591 + 0.021 * sigma) * omm ** (-0.25)


def plotBounds(omm, data, c='gray'):
    plt.fill_between(omm, data(omm, -2), data(omm, 2), facecolor=c, alpha=0.15, edgecolor=c, lw=0)
    plt.fill_between(omm, data(omm, -1), data(omm, 1), facecolor=c, alpha=0.25, edgecolor=c, lw=0)


class planckPlotter(plots.GetDistPlotter):

    def getBatch(self):
        if not hasattr(self, 'batch'): self.batch = batchjob.readobject(rootdir)
        return self.batch

    def doExport(self, fname=None, adir=None, watermark=None, tag=None):
        if watermark is None and non_final:
            watermark = version
        if adir:
            if not os.sep in adir: adir = os.path.join(output_base_dir, adir)
        super(planckPlotter, self).export(fname, adir, watermark, tag)

    def export(self, fname=None, tag=None):
        self.doExport(fname, 'outputs', tag=tag)

    def exportExtra(self, fname=None):
github Jammy2211 / PyAutoLens / autolens / autofit / non_linear.py View on Github external
def output_pdf_plots(self):

        import getdist.plots
        pdf_plot = getdist.plots.GetDistPlotter()

        plot_pdf_1d_params = conf.instance.general.get('output', 'plot_pdf_1d_params', bool)

        if plot_pdf_1d_params:

            for param_name in self.param_names:
                pdf_plot.plot_1d(roots=self.pdf, param=param_name)
                pdf_plot.export(fname=self.phase_path + 'image/pdf_' + param_name + '_1D.png')

        plt.close()

        plot_pdf_triangle = conf.instance.general.get('output', 'plot_pdf_triangle', bool)

        if plot_pdf_triangle:

            try:
github Jammy2211 / PyAutoLens / autolens / autofit / non_linear.py View on Github external
def output_pdf_plots(self):

        pdf_plot = getdist.plots.GetDistPlotter()

        for i in range(self.variable.total_parameters):
            pdf_plot.plot_1d(roots=self.pdf, param=self.paramnames_names[i])
            pdf_plot.export(fname=self.path + '/pdfs/' + self.paramnames_names[i] + '_1D.png')

        try:
            pdf_plot.triangle_plot(roots=self.pdf)
            pdf_plot.export(fname=self.path + '/pdfs/Triangle.png')
        except np.linalg.LinAlgError:
            pass
github cmbant / getdist / getdist / plots.py View on Github external
def getPlotter(**kwargs):
    """
    Creates a new plotter and returns it

    :param kwargs: arguments for :class:`~getdist.plots.GetDistPlotter`
    :return: The :class:`GetDistPlotter` instance
    """
    return GetDistPlotter(**kwargs)
github cmbant / getdist / getdist / gui / mainwindow.py View on Github external
self._set_rc(self.orig_rc)
        QApplication.setOverrideCursor(Qt.WaitCursor)
        self.showMessage("Rendering plot....")
        try:
            script_exec = self.script_edit

            if "g.export()" in script_exec:
                # Comment line which produces export to PDF
                script_exec = script_exec.replace("g.export", "#g.export")

            globaldic = {}
            localdic = {}
            exec(script_exec, globaldic, localdic)

            for v in six.itervalues(localdic):
                if isinstance(v, plots.GetDistPlotter):
                    self.updateScriptPreview(v)
                    break

            self.exportAct.setEnabled(True)

        except SyntaxError as e:
            QMessageBox.critical(self, "Plot script", type(e).__name__ + ': %s\n %s' % (e, e.text))
        except Exception as e:
            self.errorReport(e, caption="Plot script")
        finally:
            QApplication.restoreOverrideCursor()
            plots.default_settings = oldset
            plots.set_active_style(old_style)
            self._set_rc(oldrc)
            self.showMessage()