CosmoCoffee Forum Index CosmoCoffee

 
 FAQFAQ   SearchSearch  MemberlistSmartFeed   MemberlistMemberlist    RegisterRegister 
   ProfileProfile   Log inLog in 
Arxiv New Filter | Bookmarks & clubs | Arxiv ref/author:

Getdist help
Goto page 1, 2  Next  
Post new topic   Reply to topic    CosmoCoffee Forum Index -> Computers and software
View previous topic :: View next topic  
Author Message
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: May 29 2015  Reply with quote

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.
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: May 30 2015  Reply with quote

If you are plotting using samples objects (as in the plot gallery ), you can do
Code:

     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:

        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]
Back to top
View user's profile [ Hidden ] Visit poster's website
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: May 31 2015  Reply with quote

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:
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'
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 01 2015  Reply with quote

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]
Back to top
View user's profile [ Hidden ] Visit poster's website
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: June 02 2015  Reply with quote

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.
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 02 2015  Reply with quote

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.
Back to top
View user's profile [ Hidden ] Visit poster's website
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: June 02 2015  Reply with quote

For instance, I got the triangle plot successfully by loading the MCSamples. But to obtain 1D marginalized plot, when I python the following:
Code:

from __future__ import print_function
from getdist import plots, MCSamples
from getdist import loadMCSamples
import warnings
warnings.filterwarnings('ignore', '.*tight_layout.*',)
import numpy as np
samples = loadMCSamples('/home/suresh/Desktop/Working_COSMOMC/cosmomc/chains/task3', dist_settings={'ignore_rows':0.3})
labels =  ["x1","x2","H_0","\Omega_{m0}"]
names=["x1","x2","H_0","\Omega_{m0}"]
g = plots.getSinglePlotter(width_inch=4)
g.plot_1d(samples, 'H_0')
g.export('sk1.pdf')


I get the following error:

Code:
Traceback (most recent call last):
  File "trial2.py", line 26, in <module>
    g.plot_1d(samples, 'H_0')
  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(root, param, param_renames)
  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(root).parWithName(param, error=True, renames=renames)
  File "/usr/local/lib/python2.7/dist-packages/GetDist-0.2.1-py2.7.egg/getdist/paramnames.py", line 106, in parWithName
    if error: raise Exception("parameter name not found: " + name)
Exception: parameter name not found: H_0
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 02 2015  Reply with quote

Please show your .paramnames file. (and include all code etc in [code] tags)
e.g. does it have a parameter named "H_0"?

The expected format for files loaded by GetDist is described in the readme
https://github.com/cmbant/getdist
Back to top
View user's profile [ Hidden ] Visit poster's website
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 02 2015  Reply with quote

Antony Lewis wrote:
Please show your .paramnames file. (and include all code etc in [code] tags)
e.g. does it have a parameter named "H_0"?

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

Currently you are not doing anything with the labels and names arrays.
Back to top
View user's profile [ Hidden ] Visit poster's website
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: June 02 2015  Reply with quote

The task3.paramnames file has the following content:

Code:
param1 H_0
param2 \Omega_m
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 02 2015  Reply with quote

So you want

Code:
g.plot_1d(samples, 'param1')


- the scripts use param name tags, not the latex labels.
Back to top
View user's profile [ Hidden ] Visit poster's website
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: June 03 2015  Reply with quote

Thanks. Now please clarify the following:

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

Code:
cut_samps = samps[samps[:,0]>-0.5,:]


(2) By running the PCA command, I got the following:

Code:
PCA for parameters:
         1 :ln(H_0)
         2 :ln(\Omega_m)

Correlation matrix for reduced parameters
      param1 :  1.0000 -0.7063
      param2 : -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:
# param1 param2
    0.11184E+00   -0.40816E-02
   -0.40816E-02    0.29866E-03
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 03 2015  Reply with quote

Code:
cut_samps = samps[samps[:,0]>-0.5,:]


That was just some sample code to simulate samples with a cut.

Covariance is not the same as correlation.
Back to top
View user's profile [ Hidden ] Visit poster's website
Suresh Kumar India



Joined: 29 May 2015
Posts: 14
Affiliation: BITS-Pilani, India

PostPosted: June 03 2015  Reply with quote

Thanks. Now the plot labels are comiing as p1, p2 etc. How to replace them with the parameters such as H0, Ω0 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.
Back to top
View user's profile  
Antony Lewis



Joined: 23 Sep 2004
Posts: 1276
Affiliation: University of Sussex

PostPosted: June 03 2015  Reply with quote

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.
Back to top
View user's profile [ Hidden ] Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    CosmoCoffee Forum Index -> Computers and software All times are GMT + 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group. Sponsored by WordWeb online dictionary and dictionary software.