Page 1 of 2

Getdist help

Posted: May 29 2015
by Suresh Kumar India
Dear Antony,
As I understand the recent getdist code available at https://pypi.python.org/pypi/GetDist/0.2.0 gives only two contours (0.68 and 0.95) by default. Please tell me what command I should use to bring into the third contour let us say 0.99 in any plot.

Next, is that alright if I write the columns of all the chain files in succession generated by cosmoMC into a single file say sample1.txt and then I run the above code on sample1.txt.

Re: Getdist help

Posted: May 30 2015
by Antony Lewis
If you are plotting using samples objects (as in the plot gallery ), you can do

Code: Select all

     g = plots.getSinglePlotter()
     samples.contours = np.array([0.68, 0.95, 0.99])
     samples.updateBaseStatistics()
     g.settings.num_plot_contours = 3
     g.plot_2d(samples, 'x1', 'x2');
If you are loading chains from a file and referencing them by root name, you can do something like

Code: Select all

        g = plots.getSinglePlotter(chain_dir=chain_directory,
                                    analysis_settings={'ignore_rows': 0.3, 'contours':'0.68 0.95 0.99'})
        g.settings.num_plot_contours = 3 
 

You should only combine chains if burn in is removed (but even then there is no need). [/url]

Getdist help

Posted: May 31 2015
by Suresh Kumar India
Dear Antony,

Thanks for the helpful reply. I got the first point well but not the second one. For the second instead I tried to load MCSamples object from text files by using the following:

Code: Select all

from getdist import loadMCSamples
samples = loadMCSamples('/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3', dist_settings={'ignore_rows':0.3})
When I python the file trial2.py, I got the following. Please tell me how to correct the error.

/Desktop\$ python Getdist_plotting/trial2.py
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_1.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_2.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_3.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_4.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_5.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_6.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_7.txt
/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3_8.txt
Traceback (most recent call last):
File "Getdist_plotting/trial2.py", line 8, in <module>
samples = loadMCSamples('/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3', dist_settings={'ignore_rows':0.3})
File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.0-py2.7.egg/getdist/mcsamples.py", line 54, in loadMCSamples
samples.readChains(files)
File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.0-py2.7.egg/getdist/mcsamples.py", line 253, in readChains
self.deleteFixedParams()
File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.0-py2.7.egg/getdist/chains.py", line 595, in deleteFixedParams
self.paramNames.deleteIndices(fixed)
AttributeError: 'NoneType' object has no attribute 'deleteIndices'

Re: Getdist help

Posted: June 01 2015
by Antony Lewis
Do you have a .paramnames file (/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3.paramnames)? [it will be fixed for the no-paramnames file in next update]

Getdist help

Posted: June 02 2015
by Suresh Kumar India
Dear Antony, Thanks. It is working. But with the loadMCSamples approach, I am not able to use most of the commands given on plot_gallery page. I feel that any new cosmoMC user would be more comfortable to use the plot_gallery page commands, if a single .txt file say sample1.txt can be obtained from the .txt chain files of the chains directory of cosmomc after the removal of the burn in. Please tell me a command to obtain such a file.

Re: Getdist help

Posted: June 02 2015
by Antony Lewis
What doesn't work? i wouldn't normally recommend combining chains, as it loses information (you can't then change your choice of burn in).

Btw, version GetDist 0.2.1 with some fixes is now on pip upgrade.

Getdist help

Posted: June 02 2015
by Suresh Kumar India
For instance, I got the triangle plot successfully by loading the MCSamples. But to obtain 1D marginalized plot, when I python the following:

Code: Select all

from __future__ import print_function
from getdist import plots, MCSamples
from getdist import loadMCSamples
import warnings
warnings.filterwarnings&#40;'ignore', '.*tight_layout.*',&#41;
import numpy as np
samples = loadMCSamples&#40;'/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3', dist_settings=&#123;'ignore_rows'&#58;0.3&#125;&#41;
labels =  &#91;"x1","x2","H_0","\Omega_&#123;m0&#125;"&#93;
names=&#91;"x1","x2","H_0","\Omega_&#123;m0&#125;"&#93;
g = plots.getSinglePlotter&#40;width_inch=4&#41;
g.plot_1d&#40;samples, 'H_0'&#41;
g.export&#40;'sk1.pdf'&#41;
I get the following error:

Code: Select all

Traceback &#40;most recent call last&#41;&#58;
  File "trial2.py", line 26, in <module>
    g.plot_1d&#40;samples, 'H_0'&#41;
  File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.1-py2.7.egg/getdist/plots.py", line 745, in plot_1d
    root_param = self.check_param&#40;root, param, param_renames&#41;
  File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.1-py2.7.egg/getdist/plots.py", line 814, in check_param
    return self.paramNamesForRoot&#40;root&#41;.parWithName&#40;param, error=True, renames=renames&#41;
  File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.1-py2.7.egg/getdist/paramnames.py", line 106, in parWithName
    if error&#58; raise Exception&#40;"parameter name not found&#58; " + name&#41;
Exception&#58; parameter name not found&#58; H_0

Re: Getdist help

Posted: June 02 2015
by Antony Lewis
Please show your .paramnames file. (and include all code etc in

Code: Select all

[/i] tags)
e.g. does it have a parameter named "[b]H_0[/b]"?

The expected format for files loaded by GetDist is described in the readme
https://github.com/cmbant/getdist

Re: Getdist help

Posted: June 02 2015
by Antony Lewis
Antony Lewis wrote:Please show your .paramnames file. (and include all code etc in

Code: Select all

[/i] tags)
e.g. does it have a parameter named "[b]H_0[/b]"?

The expected format for files loaded by GetDist is described in the readme
https://github.com/cmbant/getdist[/quote]
Currently you are not doing anything with the labels and names arrays.

Getdist help

Posted: June 02 2015
by Suresh Kumar India
The task3.paramnames file has the following content:

Code: Select all

param1 H_0
param2 \Omega_m

Re: Getdist help

Posted: June 02 2015
by Antony Lewis
So you want

Code: Select all

g.plot_1d&#40;samples, 'param1'&#41;
- the scripts use param name tags, not the latex labels.

Getdist help

Posted: June 03 2015
by Suresh Kumar India
Thanks. Now please clarify the following:

(1) What should I use in place of samps in the command:

Code: Select all

cut_samps = samps&#91;samps&#91;&#58;,0&#93;>-0.5,&#58;&#93;
(2) By running the PCA command, I got the following:

Code: Select all

PCA for parameters&#58;
         1 &#58;ln&#40;H_0&#41;
         2 &#58;ln&#40;\Omega_m&#41;

Correlation matrix for reduced parameters
      param1 &#58;  1.0000 -0.7063
      param2 &#58; -0.7063  1.0000
But when I see the task3.covmat file obtained by running the getdist augmented with cosmomc, the correlation matrix reads as

Code: Select all

# param1 param2
    0.11184E+00   -0.40816E-02
   -0.40816E-02    0.29866E-03

Re: Getdist help

Posted: June 03 2015
by Antony Lewis

Code: Select all

cut_samps = samps&#91;samps&#91;&#58;,0&#93;>-0.5,&#58;&#93;
That was just some sample code to simulate samples with a cut.

Covariance is not the same as correlation.

Getdist help

Posted: June 03 2015
by Suresh Kumar India
Thanks. Now the plot labels are comiing as p1, p2 etc. How to replace them with the parameters such as H_0, \Omega0 etc. Also, can we get the covariance matrix using some command. Please display all the gallery plots using the chain files from two dummy chain directories. That would be much more useful for the cosmomc beginners.

Re: Getdist help

Posted: June 03 2015
by Antony Lewis
The cosmomc python readme

http://cosmologist.info/cosmomc/readme_python.html

has examples of reading from chains, and also using "lims" to change plot bounds (independently of the prior bounds on the samples).


.covmat file is produced if you run GetDist, or you can use samples.getCov() from a script.

If your samples have a .paramnames file, labels in there should be used for plots.