Getdist help
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
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.
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.
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
If you are plotting using samples objects (as in the plot gallery ), you can do
If you are loading chains from a file and referencing them by root name, you can do something like
You should only combine chains if burn in is removed (but even then there is no need). [/url]
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');
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]
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
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:
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'
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})
/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'
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
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]
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
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.
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
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.
Btw, version GetDist 0.2.1 with some fixes is now on pip upgrade.
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
For instance, I got the triangle plot successfully by loading the MCSamples. But to obtain 1D marginalized plot, when I python the following:
I get the following error:
Code: Select all
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')
Code: Select all
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
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
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
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
Antony Lewis wrote:Please show your .paramnames file. (and include all code etc inCode: 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.
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
The task3.paramnames file has the following content:
Code: Select all
param1 H_0
param2 \Omega_m
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
So you want
- the scripts use param name tags, not the latex labels.
Code: Select all
g.plot_1d(samples, 'param1')
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
Thanks. Now please clarify the following:
(1) What should I use in place of samps in the command:
(2) By running the PCA command, I got the following:
But when I see the task3.covmat file obtained by running the getdist augmented with cosmomc, the correlation matrix reads as
(1) What should I use in place of samps in the command:
Code: Select all
cut_samps = samps[samps[:,0]>-0.5,:]
Code: Select all
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
Code: Select all
# param1 param2
0.11184E+00 -0.40816E-02
-0.40816E-02 0.29866E-03
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
Code: Select all
cut_samps = samps[samps[:,0]>-0.5,:]
Covariance is not the same as correlation.
-
- Posts: 14
- Joined: May 29 2015
- Affiliation: BITS-Pilani, India
Getdist help
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.
-
- Posts: 1943
- Joined: September 23 2004
- Affiliation: University of Sussex
- Contact:
Re: Getdist help
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.
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.