anesthetic


Nameanesthetic JSON
Version 2.9.1 PyPI version JSON
download
home_pageNone
Summarynested sampling post-processing
upload_time2024-09-30 16:13:25
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2019 Will Handley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===========================================
anesthetic: nested sampling post-processing
===========================================
:Authors: Will Handley and Lukas Hergt
:Version: 2.9.1
:Homepage: https://github.com/handley-lab/anesthetic
:Documentation: http://anesthetic.readthedocs.io/

.. image:: https://github.com/handley-lab/anesthetic/workflows/CI/badge.svg?branch=master
   :target: https://github.com/handley-lab/anesthetic/actions?query=workflow%3ACI+branch%3Amaster
   :alt: Build Status
.. image:: https://codecov.io/gh/handley-lab/anesthetic/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/handley-lab/anesthetic
   :alt: Test Coverage Status
.. image:: https://readthedocs.org/projects/anesthetic/badge/?version=latest
   :target: https://anesthetic.readthedocs.io/en/latest/?badge=latest
   :alt: Documentation Status
.. image:: https://badge.fury.io/py/anesthetic.svg
   :target: https://badge.fury.io/py/anesthetic
   :alt: PyPi location
.. image:: https://anaconda.org/handley-lab/anesthetic/badges/version.svg
   :target: https://anaconda.org/handley-lab/anesthetic
   :alt: Conda location
.. image:: https://zenodo.org/badge/175663535.svg
   :target: https://zenodo.org/badge/latestdoi/175663535
   :alt: Permanent DOI for this release
.. image:: http://joss.theoj.org/papers/8c51bffda75d122cf4a8b991e18d3e45/status.svg
   :target: http://joss.theoj.org/papers/8c51bffda75d122cf4a8b991e18d3e45
   :alt: Review Status
.. image:: https://img.shields.io/badge/license-MIT-blue.svg
   :target: https://github.com/handley-lab/anesthetic/blob/master/LICENSE
   :alt: License information





``anesthetic`` brings together tools for processing nested sampling chains by leveraging standard scientific python libraries.

TLDR: See the `quickstart <https://anesthetic.readthedocs.io/en/latest/quickstart.html>`__.

Current functionality includes:

- Computation of Bayesian evidences, Kullback-Liebler divergences and Bayesian model dimensionalities.
- Marginalised 1d and 2d plots.
- Dynamic replaying of nested sampling.

This tool was designed primarily for use with nested sampling outputs, although it can be used for normal MCMC chains.

For an interactive view of a nested sampling run, you can use the ``anesthetic`` script.

.. code:: bash

   $ anesthetic <ns file root>

.. image:: https://github.com/handley-lab/anesthetic/raw/master/images/anim_1.gif

Features
--------

- Both samples and plotting axes are stored as a ``pandas.DataFrame``, with parameter names as indices, which makes for easy access and modification.
- Sensible color scheme for plotting nearly flat distributions.
- For easy extension/modification, uses the standard python libraries:
  `numpy <https://www.numpy.org/>`__,
  `scipy <https://www.scipy.org/>`__,
  `matplotlib <https://matplotlib.org/>`__
  and `pandas <https://pandas.pydata.org/>`__.

Installation
------------

``anesthetic`` can be installed via pip

.. code:: bash

    pip install anesthetic

via conda

.. code:: bash

    conda install -c handley-lab anesthetic

or from the github repository

.. code:: bash

    git clone https://github.com/handley-lab/anesthetic
    cd anesthetic
    python -m pip install .

You can check that things are working by running the test suite:

.. code:: bash

    export MPLBACKEND=Agg     # only necessary for OSX users
    python -m pip install ".[test]"
    python -m pytest
    flake8 anesthetic tests
    pydocstyle --convention=numpy anesthetic


Dependencies
~~~~~~~~~~~~

Basic requirements:

- Python 3.9+
- `matplotlib <https://pypi.org/project/matplotlib/>`__
- `numpy <https://pypi.org/project/numpy/>`__
- `scipy <https://pypi.org/project/scipy/>`__
- `pandas <https://pypi.org/project/pandas/>`__
- `fastKDE <https://pypi.org/project/fastkde/>`__

Documentation:

- `sphinx <https://pypi.org/project/Sphinx/>`__
- `numpydoc <https://pypi.org/project/numpydoc/>`__

Tests:

- `pytest <https://pypi.org/project/pytest/>`__

Documentation
-------------

Full Documentation is hosted at `ReadTheDocs <http://anesthetic.readthedocs.io/>`__.  To build your own local copy of the documentation you'll need to install `sphinx <https://pypi.org/project/Sphinx/>`__. You can then run:

.. code:: bash

    python -m pip install ".[all,docs]"
    cd docs
    make html

and view the documentation by opening ``docs/build/html/index.html`` in a browser. To regenerate the automatic RST files run:

.. code:: bash

    sphinx-apidoc -fM -t docs/templates/ -o docs/source/ anesthetic/

Citation
--------

If you use ``anesthetic`` to generate plots for a publication, please cite
as: ::

   Handley, (2019). anesthetic: nested sampling visualisation. Journal of Open
   Source Software, 4(37), 1414, https://doi.org/10.21105/joss.01414

or using the BibTeX:

.. code:: bibtex

   @article{anesthetic,
       doi = {10.21105/joss.01414},
       url = {http://dx.doi.org/10.21105/joss.01414},
       year  = {2019},
       month = {Jun},
       publisher = {The Open Journal},
       volume = {4},
       number = {37},
       pages = {1414},
       author = {Will Handley},
       title = {anesthetic: nested sampling visualisation},
       journal = {The Journal of Open Source Software}
   }


Contributing
------------
There are many ways you can contribute via the `GitHub repository <https://github.com/handley-lab/anesthetic>`__.

- You can `open an issue <https://github.com/handley-lab/anesthetic/issues>`__ to report bugs or to propose new features.
- Pull requests are very welcome. Note that if you are going to propose major changes, be sure to open an issue for discussion first, to make sure that your PR will be accepted before you spend effort coding it.


Questions/Comments
------------------
Another posterior plotting tool?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    This is my posterior plotter. There are many like it, but this one is mine.

There are several excellent tools for plotting marginalised posteriors:

- `getdist <http://getdist.readthedocs.io/en/latest/intro.html>`__
- `corner <https://corner.readthedocs.io>`__
- `pygtc <https://pygtc.readthedocs.io>`__
- `dynesty <https://dynesty.readthedocs.io>`__
- `MontePython <http://baudren.github.io/montepython.html>`__

Why create another one? In general, any dedicated user of software will find that there is some functionality that in their use case is lacking, and the designs of previous codes make such extensions challenging. In my case this was:

1. For large numbers of samples, kernel density estimation is slow, or inaccurate (particularly for samples generated from nested sampling). There are kernel density estimators, such as `fastKDE <https://pypi.org/project/fastkde/>`__, which ameliorate many of these difficulties.

2. Existing tools can make it difficult to define new parameters. For example, the default cosmomc chain defines ``omegabh2``, but not ``omegab``. The transformation is easy, since ``omegab = omegabh2/ (H0/100)**2``, but implementing this transformation in existing packages is not so trivial. ``anesthetic`` solves this issue by storing the samples as a pandas array, for which the relevant code for defining the above new parameter would be

.. code:: python

    from anesthetic import read_chains
    samples = read_chains(file_root)               # Load the samples
    label = 'omegab'
    tex = '$\Omega_b$'
    h = (samples.H0/100)
    samples[(label, tex)] = samples.omegabh2/h**2  # Define omegab
    samples.plot_1d('omegab')                      # Simple 1D plot

3. Many KDE plotting tools have conventions that don't play well with uniformly distributed parameters, which presents a problem if you are trying to plot priors along with your posteriors. ``anesthetic`` has a sensible mechanism, by defining the contours by the amount of iso-probability mass they contain, but colouring the fill in relation to the probability density of the contour.

What's in a name?
~~~~~~~~~~~~~~~~~

There is a convention for naming nested sampling packages with words that have nest in them (`nestle and dynesty <https://dynesty.readthedocs.io/en/latest/>`__, `nestorflow <https://bitbucket.org/tomcharnock/nestorflow>`__). Doing a UNIX grep:

.. code:: bash

    grep nest /usr/share/dict/words

yields a lot of superlatives (e.g. greenest), but a few other cool names for future projects:

- amnesty
- defenestrate
- dishonestly
- inestimable
- minestrone
- rhinestone

I chose ``anesthetic`` because I liked the soft 'th', and in spite of the US spelling.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "anesthetic",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Will Handley <williamjameshandley@gmail.com>, Lukas Hergt <lthergt@phas.ubc.ca>",
    "keywords": null,
    "author": null,
    "author_email": "Will Handley <williamjameshandley@gmail.com>, Lukas Hergt <lthergt@phas.ubc.ca>, Adam Ormondroyd <ano23@cam.ac.uk>, Harry Bevins <htjb2@cam.ac.uk>, Johannes Buchner <jbuchner@mpe.mpg.de>, Ethan Carragher <ethan.carragher@adelaide.edu.au>, Andrew Fowlie <andrew.j.fowlie@googlemail.com>, Thomas Gessey-Jones <tg400@cam.ac.uk>, Stefan Heimersheim <sh2061@ast.cam.ac.uk>, Pablo Lemos <plemos91@gmail.com>, Toby Lovick <tcl44@cam.ac.uk>, Deborah Odunuyi <debbieodunuyi@gmail.com>, Aleksandr Petrosyan <a-p-petrosyan@yandex.ru>, Liangliang Su <liangliangsu@njnu.edu.cn>, David Yallup <david.yallup@gmail.com>, Dily Ong <dlo26@cam.ac.uk>",
    "download_url": "https://files.pythonhosted.org/packages/4e/44/c6a0952bf1054127d84d46fdb5abd1c2347934ce327da9c4a9364fa5cb72/anesthetic-2.9.1.tar.gz",
    "platform": null,
    "description": "===========================================\nanesthetic: nested sampling post-processing\n===========================================\n:Authors: Will Handley and Lukas Hergt\n:Version: 2.9.1\n:Homepage: https://github.com/handley-lab/anesthetic\n:Documentation: http://anesthetic.readthedocs.io/\n\n.. image:: https://github.com/handley-lab/anesthetic/workflows/CI/badge.svg?branch=master\n   :target: https://github.com/handley-lab/anesthetic/actions?query=workflow%3ACI+branch%3Amaster\n   :alt: Build Status\n.. image:: https://codecov.io/gh/handley-lab/anesthetic/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/handley-lab/anesthetic\n   :alt: Test Coverage Status\n.. image:: https://readthedocs.org/projects/anesthetic/badge/?version=latest\n   :target: https://anesthetic.readthedocs.io/en/latest/?badge=latest\n   :alt: Documentation Status\n.. image:: https://badge.fury.io/py/anesthetic.svg\n   :target: https://badge.fury.io/py/anesthetic\n   :alt: PyPi location\n.. image:: https://anaconda.org/handley-lab/anesthetic/badges/version.svg\n   :target: https://anaconda.org/handley-lab/anesthetic\n   :alt: Conda location\n.. image:: https://zenodo.org/badge/175663535.svg\n   :target: https://zenodo.org/badge/latestdoi/175663535\n   :alt: Permanent DOI for this release\n.. image:: http://joss.theoj.org/papers/8c51bffda75d122cf4a8b991e18d3e45/status.svg\n   :target: http://joss.theoj.org/papers/8c51bffda75d122cf4a8b991e18d3e45\n   :alt: Review Status\n.. image:: https://img.shields.io/badge/license-MIT-blue.svg\n   :target: https://github.com/handley-lab/anesthetic/blob/master/LICENSE\n   :alt: License information\n\n\n\n\n\n``anesthetic`` brings together tools for processing nested sampling chains by leveraging standard scientific python libraries.\n\nTLDR: See the `quickstart <https://anesthetic.readthedocs.io/en/latest/quickstart.html>`__.\n\nCurrent functionality includes:\n\n- Computation of Bayesian evidences, Kullback-Liebler divergences and Bayesian model dimensionalities.\n- Marginalised 1d and 2d plots.\n- Dynamic replaying of nested sampling.\n\nThis tool was designed primarily for use with nested sampling outputs, although it can be used for normal MCMC chains.\n\nFor an interactive view of a nested sampling run, you can use the ``anesthetic`` script.\n\n.. code:: bash\n\n   $ anesthetic <ns file root>\n\n.. image:: https://github.com/handley-lab/anesthetic/raw/master/images/anim_1.gif\n\nFeatures\n--------\n\n- Both samples and plotting axes are stored as a ``pandas.DataFrame``, with parameter names as indices, which makes for easy access and modification.\n- Sensible color scheme for plotting nearly flat distributions.\n- For easy extension/modification, uses the standard python libraries:\n  `numpy <https://www.numpy.org/>`__,\n  `scipy <https://www.scipy.org/>`__,\n  `matplotlib <https://matplotlib.org/>`__\n  and `pandas <https://pandas.pydata.org/>`__.\n\nInstallation\n------------\n\n``anesthetic`` can be installed via pip\n\n.. code:: bash\n\n    pip install anesthetic\n\nvia conda\n\n.. code:: bash\n\n    conda install -c handley-lab anesthetic\n\nor from the github repository\n\n.. code:: bash\n\n    git clone https://github.com/handley-lab/anesthetic\n    cd anesthetic\n    python -m pip install .\n\nYou can check that things are working by running the test suite:\n\n.. code:: bash\n\n    export MPLBACKEND=Agg     # only necessary for OSX users\n    python -m pip install \".[test]\"\n    python -m pytest\n    flake8 anesthetic tests\n    pydocstyle --convention=numpy anesthetic\n\n\nDependencies\n~~~~~~~~~~~~\n\nBasic requirements:\n\n- Python 3.9+\n- `matplotlib <https://pypi.org/project/matplotlib/>`__\n- `numpy <https://pypi.org/project/numpy/>`__\n- `scipy <https://pypi.org/project/scipy/>`__\n- `pandas <https://pypi.org/project/pandas/>`__\n- `fastKDE <https://pypi.org/project/fastkde/>`__\n\nDocumentation:\n\n- `sphinx <https://pypi.org/project/Sphinx/>`__\n- `numpydoc <https://pypi.org/project/numpydoc/>`__\n\nTests:\n\n- `pytest <https://pypi.org/project/pytest/>`__\n\nDocumentation\n-------------\n\nFull Documentation is hosted at `ReadTheDocs <http://anesthetic.readthedocs.io/>`__.  To build your own local copy of the documentation you'll need to install `sphinx <https://pypi.org/project/Sphinx/>`__. You can then run:\n\n.. code:: bash\n\n    python -m pip install \".[all,docs]\"\n    cd docs\n    make html\n\nand view the documentation by opening ``docs/build/html/index.html`` in a browser. To regenerate the automatic RST files run:\n\n.. code:: bash\n\n    sphinx-apidoc -fM -t docs/templates/ -o docs/source/ anesthetic/\n\nCitation\n--------\n\nIf you use ``anesthetic`` to generate plots for a publication, please cite\nas: ::\n\n   Handley, (2019). anesthetic: nested sampling visualisation. Journal of Open\n   Source Software, 4(37), 1414, https://doi.org/10.21105/joss.01414\n\nor using the BibTeX:\n\n.. code:: bibtex\n\n   @article{anesthetic,\n       doi = {10.21105/joss.01414},\n       url = {http://dx.doi.org/10.21105/joss.01414},\n       year  = {2019},\n       month = {Jun},\n       publisher = {The Open Journal},\n       volume = {4},\n       number = {37},\n       pages = {1414},\n       author = {Will Handley},\n       title = {anesthetic: nested sampling visualisation},\n       journal = {The Journal of Open Source Software}\n   }\n\n\nContributing\n------------\nThere are many ways you can contribute via the `GitHub repository <https://github.com/handley-lab/anesthetic>`__.\n\n- You can `open an issue <https://github.com/handley-lab/anesthetic/issues>`__ to report bugs or to propose new features.\n- Pull requests are very welcome. Note that if you are going to propose major changes, be sure to open an issue for discussion first, to make sure that your PR will be accepted before you spend effort coding it.\n\n\nQuestions/Comments\n------------------\nAnother posterior plotting tool?\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n    This is my posterior plotter. There are many like it, but this one is mine.\n\nThere are several excellent tools for plotting marginalised posteriors:\n\n- `getdist <http://getdist.readthedocs.io/en/latest/intro.html>`__\n- `corner <https://corner.readthedocs.io>`__\n- `pygtc <https://pygtc.readthedocs.io>`__\n- `dynesty <https://dynesty.readthedocs.io>`__\n- `MontePython <http://baudren.github.io/montepython.html>`__\n\nWhy create another one? In general, any dedicated user of software will find that there is some functionality that in their use case is lacking, and the designs of previous codes make such extensions challenging. In my case this was:\n\n1. For large numbers of samples, kernel density estimation is slow, or inaccurate (particularly for samples generated from nested sampling). There are kernel density estimators, such as `fastKDE <https://pypi.org/project/fastkde/>`__, which ameliorate many of these difficulties.\n\n2. Existing tools can make it difficult to define new parameters. For example, the default cosmomc chain defines ``omegabh2``, but not ``omegab``. The transformation is easy, since ``omegab = omegabh2/ (H0/100)**2``, but implementing this transformation in existing packages is not so trivial. ``anesthetic`` solves this issue by storing the samples as a pandas array, for which the relevant code for defining the above new parameter would be\n\n.. code:: python\n\n    from anesthetic import read_chains\n    samples = read_chains(file_root)               # Load the samples\n    label = 'omegab'\n    tex = '$\\Omega_b$'\n    h = (samples.H0/100)\n    samples[(label, tex)] = samples.omegabh2/h**2  # Define omegab\n    samples.plot_1d('omegab')                      # Simple 1D plot\n\n3. Many KDE plotting tools have conventions that don't play well with uniformly distributed parameters, which presents a problem if you are trying to plot priors along with your posteriors. ``anesthetic`` has a sensible mechanism, by defining the contours by the amount of iso-probability mass they contain, but colouring the fill in relation to the probability density of the contour.\n\nWhat's in a name?\n~~~~~~~~~~~~~~~~~\n\nThere is a convention for naming nested sampling packages with words that have nest in them (`nestle and dynesty <https://dynesty.readthedocs.io/en/latest/>`__, `nestorflow <https://bitbucket.org/tomcharnock/nestorflow>`__). Doing a UNIX grep:\n\n.. code:: bash\n\n    grep nest /usr/share/dict/words\n\nyields a lot of superlatives (e.g. greenest), but a few other cool names for future projects:\n\n- amnesty\n- defenestrate\n- dishonestly\n- inestimable\n- minestrone\n- rhinestone\n\nI chose ``anesthetic`` because I liked the soft 'th', and in spite of the US spelling.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2019 Will Handley  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "nested sampling post-processing",
    "version": "2.9.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/handley-lab/anesthetic/issues",
        "Documentation": "https://anesthetic.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/handley-lab/anesthetic",
        "JOSS paper": "https://joss.theoj.org/papers/10.21105/joss.01414"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "52f1023a4573188e8b5ec438d813dbaa4c42c310fd5a0a750d119645020500e3",
                "md5": "6c4e59b540e76d0e200751bd91966731",
                "sha256": "414c62e5730101fb6784962d62f74e58c975196578bf33b29fc749cb3a59e734"
            },
            "downloads": -1,
            "filename": "anesthetic-2.9.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6c4e59b540e76d0e200751bd91966731",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 76426,
            "upload_time": "2024-09-30T16:13:23",
            "upload_time_iso_8601": "2024-09-30T16:13:23.604267Z",
            "url": "https://files.pythonhosted.org/packages/52/f1/023a4573188e8b5ec438d813dbaa4c42c310fd5a0a750d119645020500e3/anesthetic-2.9.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4e44c6a0952bf1054127d84d46fdb5abd1c2347934ce327da9c4a9364fa5cb72",
                "md5": "c865e175c31c0a4bf8a8d5f6fd3a475a",
                "sha256": "1831849c74bd70d12e7c1715ac42affe662dd824ad643377b4005e79e13e4a39"
            },
            "downloads": -1,
            "filename": "anesthetic-2.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c865e175c31c0a4bf8a8d5f6fd3a475a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 100721,
            "upload_time": "2024-09-30T16:13:25",
            "upload_time_iso_8601": "2024-09-30T16:13:25.282066Z",
            "url": "https://files.pythonhosted.org/packages/4e/44/c6a0952bf1054127d84d46fdb5abd1c2347934ce327da9c4a9364fa5cb72/anesthetic-2.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-30 16:13:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "handley-lab",
    "github_project": "anesthetic",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "anesthetic"
}
        
Elapsed time: 1.09501s