Package: anesthetic
Authors:Will Handley and Lukas HergtVersion:2.7.0Homepage:https://github.com/handley-lab/anestheticDocumentation:http://anesthetic.readthedocs.io/anestheticbrings together tools for processing nested sampling chains by leveraging standard scientific python libraries.TLDR: See thequickstart.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 theanestheticscript.$anesthetic<nsfileroot>FeaturesBoth samples and plotting axes are stored as apandas.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,scipy,matplotlibandpandas.Installationanestheticcan be installed via pippipinstallanestheticor from the repositorygitclonehttps://github.com/handley-lab/anestheticcdanestheticpython-mpipinstall.You can check that things are working by running the test suite:exportMPLBACKEND=Agg# only necessary for OSX userspython-mpipinstall".[test]"python-mpytestflake8anesthetictestspydocstyle--convention=numpyanestheticDependenciesBasic requirements:Python 3.9+matplotlibnumpyscipypandasfastKDEDocumentation:sphinxnumpydocTests:pytestDocumentationFull Documentation is hosted atReadTheDocs.  To build your own local copy of the documentation you’ll need to installsphinx. You can then run:python-mpipinstall".[all,docs]"cddocsmakehtmland view the documentation by openingdocs/build/html/index.htmlin a browser. To regenerate the automatic RST files run:sphinx-apidoc-fM-tdocs/templates/-odocs/source/anesthetic/CitationIf you useanestheticto 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.01414or using the 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}}ContributingThere are many ways you can contribute via theGitHub repository.You canopen an issueto 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/CommentsAnother 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:getdistcornerpygtcdynestyMontePythonWhy 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: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 asfastKDE, which ameliorate many of these difficulties.Existing tools can make it difficult to define new parameters. For example, the default cosmomc chain definesomegabh2, but notomegab. The transformation is easy, sinceomegab = omegabh2/(H0/100)**2, but implementing this transformation in existing packages is not so trivial.anestheticsolves this issue by storing the samples as a pandas array, for which the relevant code for defining the above new parameter would befromanestheticimportread_chainssamples=read_chains(file_root)# Load the sampleslabel='omegab'tex='$\Omega_b$'h=(samples.H0/100)samples[(label,tex)]=samples.omegabh2/h**2# Define omegabsamples.plot_1d('omegab')# Simple 1D plotMany 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.anesthetichas 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,nestorflow). Doing a UNIX grep:grepnest/usr/share/dict/wordsyields a lot of superlatives (e.g. greenest), but a few other cool names for future projects:amnestydefenestratedishonestlyinestimableminestronerhinestoneI choseanestheticbecause I liked the soft ‘th’, and in spite of the US spelling.