GetDist


NameGetDist JSON
Version 1.4.3 PyPI version JSON
download
home_pagehttps://getdist.readthedocs.io
SummaryGetDist Monte Carlo sample analysis, plotting and GUI
upload_time2023-03-29 16:22:24
maintainer
docs_urlNone
authorAntony Lewis
requires_python>=3.6
license
keywords mcmc kde sample density estimation plot figure
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===================
GetDist
===================
:GetDist: MCMC sample analysis, plotting and GUI
:Author: Antony Lewis
:Homepage: https://getdist.readthedocs.io
:Source: https://github.com/cmbant/getdist
:Reference: https://arxiv.org/abs/1910.13970

.. image:: https://travis-ci.com/cmbant/getdist.svg?branch=master
   :target: https://app.travis-ci.com/cmbant/getdist
.. image:: https://img.shields.io/pypi/v/GetDist.svg?style=flat
   :target: https://pypi.python.org/pypi/GetDist/
.. image:: https://readthedocs.org/projects/getdist/badge/?version=latest
   :target: https://getdist.readthedocs.io/en/latest
.. image:: https://mybinder.org/badge_logo.svg
   :target: https://mybinder.org/v2/gh/cmbant/getdist/master?filepath=docs%2Fplot_gallery.ipynb
.. image:: https://img.shields.io/badge/arXiv-1910.13970-b31b1b.svg?color=0B6523
   :target: https://arxiv.org/abs/1910.13970

Description
============

GetDist is a Python package for analysing Monte Carlo samples, including correlated samples
from Markov Chain Monte Carlo (MCMC).

* **Point and click GUI** - select chain files, view plots, marginalized constraints, LaTeX tables and more
* **Plotting library** - make custom publication-ready 1D, 2D, 3D-scatter, triangle and other plots
* **Named parameters** - simple handling of many parameters using parameter names, including LaTeX labels and prior bounds
* **Optimized Kernel Density Estimation** - automated optimal bandwidth choice for 1D and 2D densities (Botev et al. Improved Sheather-Jones method), with boundary and bias correction
* **Convergence diagnostics** - including correlation length and diagonalized Gelman-Rubin statistics
* **LaTeX tables** for marginalized 1D constraints

See the `Plot Gallery and tutorial <http://getdist.readthedocs.io/en/latest/plot_gallery.html>`_
(`run online <https://mybinder.org/v2/gh/cmbant/getdist/master?filepath=docs%2Fplot_gallery.ipynb>`_)
and `GetDist Documentation <http://getdist.readthedocs.io/en/latest/index.html>`_.


Getting Started
================

Install getdist using pip::

    $ pip install getdist

or from source files using::

    $ python setup.py install

or::

    $ pip install -e /path/to/source/

You can test if things are working using the unit test by running::

    $ python -m unittest getdist.tests.getdist_test

Check the dependencies listed in the next section are installed. You can then use the getdist module from your scripts, or
use the GetDist GUI (*getdist-gui* command).

Once installed, the best way to get up to speed is probably to read through
the `Plot Gallery and tutorial <http://getdist.readthedocs.io/en/latest/plot_gallery.html>`_.

Dependencies
=============
* Python 3.6+
* matplotlib 2.2+ (3.1+ recommended)
* scipy
* PySide6 or PySide2 - optional, only needed for GUI
* Working LaTeX installation (not essential, only for some plotting/table functions)

Python distributions like Anaconda have most of what you need (except for LaTeX).

To use the `GUI <https://getdist.readthedocs.io/en/latest/gui.html>`_ you need PySide.
See the `GUI docs <https://getdist.readthedocs.io/en/latest/gui.html#installation>`_ for suggestions on how to install.

Algorithm details
==================

Details of kernel density estimation (KDE) algorithms and references are give in the GetDist notes
`arXiv:1910.13970 <https://arxiv.org/pdf/1910.13970>`_.

Samples file format
===================

GetDist can be used in scripts and interactively with standard numpy arrays
(as in the `examples <http://getdist.readthedocs.io/en/latest/plot_gallery.html>`_).
Scripts and the `GetDist GUI <http://getdist.readthedocs.io/en/latest/gui.html>`_ can also read parameter sample/chain files in plain text format
(or in the format output by the `Cobaya <https://cobaya.readthedocs.io>`__ sampling program).
In general plain text files of the form::

  xxx_1.txt
  xxx_2.txt
  ...
  xxx.paramnames
  xxx.ranges

where "xxx" is some root file name.

The .txt files are separate chain files (there can also be just one xxx.txt file). Each row of each sample .txt file is in the format

  *weight like param1 param2 param3* ...

The *weight* gives the number of samples (or importance weight) with these parameters. *like* gives -log(likelihood), and *param1, param2...* are the values of the parameters at the sample point. The first two columns can be 1 and 0 if they are not known or used.

The .paramnames file lists the names of the parameters, one per line, optionally followed by a LaTeX label. Names cannot include spaces, and if they end in "*" they are interpreted as derived (rather than MCMC) parameters, e.g.::

 x1   x_1
 y1   y_1
 x2   x_2
 xy*  x_1+y_1

The .ranges file gives hard bounds for the parameters, e.g.::

 x1  -5 5
 x2   0 N

Note that not all parameters need to be specified, and "N" can be used to denote that a particular upper or lower limit is unbounded. The ranges are used to determine densities and plot bounds if there are samples near the boundary; if there are no samples anywhere near the boundary the ranges have no affect on plot bounds, which are chosen appropriately for the range of the samples.

There can also optionally be a .properties.ini file, which can specify *burn_removed=T* to ensure no burn in is removed, or *ignore_rows=x* to ignore the first
fraction *x* of the file rows (or if *x > 1*, the specified number of rows).

Loading samples
===================

To load an MCSamples object from text files do::

     from getdist import loadMCSamples
     samples = loadMCSamples('/path/to/xxx', settings={'ignore_rows':0.3})

Here *settings* gives optional parameter settings for the analysis. *ignore_rows* is useful for MCMC chains where you want to
discard some fraction from the start of each chain as burn in (use a number >1 to discard a fixed number of sample lines rather than a fraction).
The MCSamples object can be passed to plot functions, or used to get many results. For example, to plot marginalized parameter densities
for parameter names *x1* and *x2*::

    from getdist import plots
    g = plots.get_single_plotter()
    g.plot_2d(samples, ['x1', 'x2'])

When you have many different chain files in the same directory,
plotting can work directly with the root file names. For example to compare *x* and *y* constraints
from two chains with root names *xxx* and *yyy*::

    from getdist import plots
    g = plots.get_single_plotter(chain_dir='/path/to/', analysis_settings={'ignore_rows':0.3})
    g.plot_2d(['xxx','yyy'], ['x', 'y'])


MCSamples objects can also be constructed directly from numpy arrays in memory, see the example
in the `Plot Gallery <https://getdist.readthedocs.io/en/latest/plot_gallery.html>`_.

GetDist script
===================

If you have chain files on on disk, you can also quickly calculate convergence and marginalized statistics using the *getdist* script:

    usage: getdist [-h] [--ignore_rows IGNORE_ROWS] [-V] [ini_file] [chain_root]

    GetDist sample analyser

    positional arguments:
      *ini_file*              .ini file with analysis settings (optional, if omitted uses defaults

      *chain_root*            Root name of chain to analyse (e.g. chains/test), required unless file_root specified in ini_file

    optional arguments:
      -h, --help            show this help message and exit
      --ignore_rows IGNORE_ROWS
                            set initial fraction of chains to cut as burn in
                            (fraction of total rows, or >1 number of rows);
                            overrides any value in ini_file if set
      --make_param_file MAKE_PARAM_FILE
                        Produce a sample distparams.ini file that you can edit
                        and use when running GetDist
      -V, --version         show program's version number and exit

where *ini_file* is optionally a .ini file listing *key=value* parameter option values, and chain_root is the root file name of the chains.
For example::

   getdist distparams.ini chains/test_chain

This produces a set of files containing parameter means and limits (.margestats), N-D likelihood contour boundaries and best-fit sample (.likestats),
convergence diagnostics (.converge), parameter covariance and correlation (.covmat and .corr), and optionally various simple plotting scripts.
If no *ini_file* is given, default settings are used. The *ignore_rows* option allows some of the start of each chain file to be removed as burn in.

To customize settings you can run::

   getdist --make_param_file distparams.ini

to produce the setting file distparams.ini, edit it, then run with your custom settings.

GetDist GUI
===================

Run *getdist-gui* to run the graphical user interface. This requires PySide, but will run on Windows, Linux and Mac.
It allows you to open a folder of chain files, then easily select, open, plot and compare, as well as viewing standard GetDist outputs and tables.
See the `GUI Readme <http://getdist.readthedocs.io/en/latest/gui.html>`_.


Using with CosmoMC and Cobaya
=============================

This GetDist package is general, but is mainly developed for analysing chains from the `CosmoMC <https://cosmologist.info/cosmomc>`_
and `Cobaya <https://cobaya.readthedocs.io/>`_ sampling programs.
No need to install this package separately if you have a full CosmoMC installation; the Cobaya installation will also install GetDist as a dependency.
Detailed help is available for plotting Planck chains
and using CosmoMC parameter grids in the `Readme <https://cosmologist.info/cosmomc/readme_python.html>`_.

Citation
===================
You can refer to the notes::

     @article{Lewis:2019xzd,
      author         = "Lewis, Antony",
      title          = "{GetDist: a Python package for analysing Monte Carlo
                        samples}",
      year           = "2019",
      eprint         = "1910.13970",
      archivePrefix  = "arXiv",
      primaryClass   = "astro-ph.IM",
      SLACcitation   = "%%CITATION = ARXIV:1910.13970;%%",
      url            = "https://getdist.readthedocs.io"
     }


and references therein as appropriate.


            

Raw data

            {
    "_id": null,
    "home_page": "https://getdist.readthedocs.io",
    "name": "GetDist",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "MCMC,KDE,sample,density estimation,plot,figure",
    "author": "Antony Lewis",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/ef/0a/5b79f97b5c797f324ec0e0b7e242ddc3a656bc8248ad21209d2f895d9041/GetDist-1.4.3.tar.gz",
    "platform": "any",
    "description": "===================\nGetDist\n===================\n:GetDist: MCMC sample analysis, plotting and GUI\n:Author: Antony Lewis\n:Homepage: https://getdist.readthedocs.io\n:Source: https://github.com/cmbant/getdist\n:Reference: https://arxiv.org/abs/1910.13970\n\n.. image:: https://travis-ci.com/cmbant/getdist.svg?branch=master\n   :target: https://app.travis-ci.com/cmbant/getdist\n.. image:: https://img.shields.io/pypi/v/GetDist.svg?style=flat\n   :target: https://pypi.python.org/pypi/GetDist/\n.. image:: https://readthedocs.org/projects/getdist/badge/?version=latest\n   :target: https://getdist.readthedocs.io/en/latest\n.. image:: https://mybinder.org/badge_logo.svg\n   :target: https://mybinder.org/v2/gh/cmbant/getdist/master?filepath=docs%2Fplot_gallery.ipynb\n.. image:: https://img.shields.io/badge/arXiv-1910.13970-b31b1b.svg?color=0B6523\n   :target: https://arxiv.org/abs/1910.13970\n\nDescription\n============\n\nGetDist is a Python package for analysing Monte Carlo samples, including correlated samples\nfrom Markov Chain Monte Carlo (MCMC).\n\n* **Point and click GUI** - select chain files, view plots, marginalized constraints, LaTeX tables and more\n* **Plotting library** - make custom publication-ready 1D, 2D, 3D-scatter, triangle and other plots\n* **Named parameters** - simple handling of many parameters using parameter names, including LaTeX labels and prior bounds\n* **Optimized Kernel Density Estimation** - automated optimal bandwidth choice for 1D and 2D densities (Botev et al. Improved Sheather-Jones method), with boundary and bias correction\n* **Convergence diagnostics** - including correlation length and diagonalized Gelman-Rubin statistics\n* **LaTeX tables** for marginalized 1D constraints\n\nSee the `Plot Gallery and tutorial <http://getdist.readthedocs.io/en/latest/plot_gallery.html>`_\n(`run online <https://mybinder.org/v2/gh/cmbant/getdist/master?filepath=docs%2Fplot_gallery.ipynb>`_)\nand `GetDist Documentation <http://getdist.readthedocs.io/en/latest/index.html>`_.\n\n\nGetting Started\n================\n\nInstall getdist using pip::\n\n    $ pip install getdist\n\nor from source files using::\n\n    $ python setup.py install\n\nor::\n\n    $ pip install -e /path/to/source/\n\nYou can test if things are working using the unit test by running::\n\n    $ python -m unittest getdist.tests.getdist_test\n\nCheck the dependencies listed in the next section are installed. You can then use the getdist module from your scripts, or\nuse the GetDist GUI (*getdist-gui* command).\n\nOnce installed, the best way to get up to speed is probably to read through\nthe `Plot Gallery and tutorial <http://getdist.readthedocs.io/en/latest/plot_gallery.html>`_.\n\nDependencies\n=============\n* Python 3.6+\n* matplotlib 2.2+ (3.1+ recommended)\n* scipy\n* PySide6 or PySide2 - optional, only needed for GUI\n* Working LaTeX installation (not essential, only for some plotting/table functions)\n\nPython distributions like Anaconda have most of what you need (except for LaTeX).\n\nTo use the `GUI <https://getdist.readthedocs.io/en/latest/gui.html>`_ you need PySide.\nSee the `GUI docs <https://getdist.readthedocs.io/en/latest/gui.html#installation>`_ for suggestions on how to install.\n\nAlgorithm details\n==================\n\nDetails of kernel density estimation (KDE) algorithms and references are give in the GetDist notes\n`arXiv:1910.13970 <https://arxiv.org/pdf/1910.13970>`_.\n\nSamples file format\n===================\n\nGetDist can be used in scripts and interactively with standard numpy arrays\n(as in the `examples <http://getdist.readthedocs.io/en/latest/plot_gallery.html>`_).\nScripts and the `GetDist GUI <http://getdist.readthedocs.io/en/latest/gui.html>`_ can also read parameter sample/chain files in plain text format\n(or in the format output by the `Cobaya <https://cobaya.readthedocs.io>`__ sampling program).\nIn general plain text files of the form::\n\n  xxx_1.txt\n  xxx_2.txt\n  ...\n  xxx.paramnames\n  xxx.ranges\n\nwhere \"xxx\" is some root file name.\n\nThe .txt files are separate chain files (there can also be just one xxx.txt file). Each row of each sample .txt file is in the format\n\n  *weight like param1 param2 param3* ...\n\nThe *weight* gives the number of samples (or importance weight) with these parameters. *like* gives -log(likelihood), and *param1, param2...* are the values of the parameters at the sample point. The first two columns can be 1 and 0 if they are not known or used.\n\nThe .paramnames file lists the names of the parameters, one per line, optionally followed by a LaTeX label. Names cannot include spaces, and if they end in \"*\" they are interpreted as derived (rather than MCMC) parameters, e.g.::\n\n x1   x_1\n y1   y_1\n x2   x_2\n xy*  x_1+y_1\n\nThe .ranges file gives hard bounds for the parameters, e.g.::\n\n x1  -5 5\n x2   0 N\n\nNote that not all parameters need to be specified, and \"N\" can be used to denote that a particular upper or lower limit is unbounded. The ranges are used to determine densities and plot bounds if there are samples near the boundary; if there are no samples anywhere near the boundary the ranges have no affect on plot bounds, which are chosen appropriately for the range of the samples.\n\nThere can also optionally be a .properties.ini file, which can specify *burn_removed=T* to ensure no burn in is removed, or *ignore_rows=x* to ignore the first\nfraction *x* of the file rows (or if *x > 1*, the specified number of rows).\n\nLoading samples\n===================\n\nTo load an MCSamples object from text files do::\n\n     from getdist import loadMCSamples\n     samples = loadMCSamples('/path/to/xxx', settings={'ignore_rows':0.3})\n\nHere *settings* gives optional parameter settings for the analysis. *ignore_rows* is useful for MCMC chains where you want to\ndiscard some fraction from the start of each chain as burn in (use a number >1 to discard a fixed number of sample lines rather than a fraction).\nThe MCSamples object can be passed to plot functions, or used to get many results. For example, to plot marginalized parameter densities\nfor parameter names *x1* and *x2*::\n\n    from getdist import plots\n    g = plots.get_single_plotter()\n    g.plot_2d(samples, ['x1', 'x2'])\n\nWhen you have many different chain files in the same directory,\nplotting can work directly with the root file names. For example to compare *x* and *y* constraints\nfrom two chains with root names *xxx* and *yyy*::\n\n    from getdist import plots\n    g = plots.get_single_plotter(chain_dir='/path/to/', analysis_settings={'ignore_rows':0.3})\n    g.plot_2d(['xxx','yyy'], ['x', 'y'])\n\n\nMCSamples objects can also be constructed directly from numpy arrays in memory, see the example\nin the `Plot Gallery <https://getdist.readthedocs.io/en/latest/plot_gallery.html>`_.\n\nGetDist script\n===================\n\nIf you have chain files on on disk, you can also quickly calculate convergence and marginalized statistics using the *getdist* script:\n\n    usage: getdist [-h] [--ignore_rows IGNORE_ROWS] [-V] [ini_file] [chain_root]\n\n    GetDist sample analyser\n\n    positional arguments:\n      *ini_file*              .ini file with analysis settings (optional, if omitted uses defaults\n\n      *chain_root*            Root name of chain to analyse (e.g. chains/test), required unless file_root specified in ini_file\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      --ignore_rows IGNORE_ROWS\n                            set initial fraction of chains to cut as burn in\n                            (fraction of total rows, or >1 number of rows);\n                            overrides any value in ini_file if set\n      --make_param_file MAKE_PARAM_FILE\n                        Produce a sample distparams.ini file that you can edit\n                        and use when running GetDist\n      -V, --version         show program's version number and exit\n\nwhere *ini_file* is optionally a .ini file listing *key=value* parameter option values, and chain_root is the root file name of the chains.\nFor example::\n\n   getdist distparams.ini chains/test_chain\n\nThis produces a set of files containing parameter means and limits (.margestats), N-D likelihood contour boundaries and best-fit sample (.likestats),\nconvergence diagnostics (.converge), parameter covariance and correlation (.covmat and .corr), and optionally various simple plotting scripts.\nIf no *ini_file* is given, default settings are used. The *ignore_rows* option allows some of the start of each chain file to be removed as burn in.\n\nTo customize settings you can run::\n\n   getdist --make_param_file distparams.ini\n\nto produce the setting file distparams.ini, edit it, then run with your custom settings.\n\nGetDist GUI\n===================\n\nRun *getdist-gui* to run the graphical user interface. This requires PySide, but will run on Windows, Linux and Mac.\nIt allows you to open a folder of chain files, then easily select, open, plot and compare, as well as viewing standard GetDist outputs and tables.\nSee the `GUI Readme <http://getdist.readthedocs.io/en/latest/gui.html>`_.\n\n\nUsing with CosmoMC and Cobaya\n=============================\n\nThis GetDist package is general, but is mainly developed for analysing chains from the `CosmoMC <https://cosmologist.info/cosmomc>`_\nand `Cobaya <https://cobaya.readthedocs.io/>`_ sampling programs.\nNo need to install this package separately if you have a full CosmoMC installation; the Cobaya installation will also install GetDist as a dependency.\nDetailed help is available for plotting Planck chains\nand using CosmoMC parameter grids in the `Readme <https://cosmologist.info/cosmomc/readme_python.html>`_.\n\nCitation\n===================\nYou can refer to the notes::\n\n     @article{Lewis:2019xzd,\n      author         = \"Lewis, Antony\",\n      title          = \"{GetDist: a Python package for analysing Monte Carlo\n                        samples}\",\n      year           = \"2019\",\n      eprint         = \"1910.13970\",\n      archivePrefix  = \"arXiv\",\n      primaryClass   = \"astro-ph.IM\",\n      SLACcitation   = \"%%CITATION = ARXIV:1910.13970;%%\",\n      url            = \"https://getdist.readthedocs.io\"\n     }\n\n\nand references therein as appropriate.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "GetDist Monte Carlo sample analysis, plotting and GUI",
    "version": "1.4.3",
    "split_keywords": [
        "mcmc",
        "kde",
        "sample",
        "density estimation",
        "plot",
        "figure"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef0a5b79f97b5c797f324ec0e0b7e242ddc3a656bc8248ad21209d2f895d9041",
                "md5": "14f327d20eb9443344155018357fcb59",
                "sha256": "7432945e2d517c6ba765348eff276c0affb2da2b69397b1a99c743ee57666180"
            },
            "downloads": -1,
            "filename": "GetDist-1.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "14f327d20eb9443344155018357fcb59",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 778148,
            "upload_time": "2023-03-29T16:22:24",
            "upload_time_iso_8601": "2023-03-29T16:22:24.988064Z",
            "url": "https://files.pythonhosted.org/packages/ef/0a/5b79f97b5c797f324ec0e0b7e242ddc3a656bc8248ad21209d2f895d9041/GetDist-1.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-29 16:22:24",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "getdist"
}
        
Elapsed time: 0.11414s