Plotting with python script

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Plotting with python script

Post by Gansukh Tumurtushaa » March 19 2014

Dear All,

I have been trying to reproduce the very last figure of the following link: http://cosmologist.info/cosmomc/readme_planck.html

I have done up to the "Ploting" section but I have a some problem in this section.
What I have done before I got error is that:

1. I did symbolic link in the Using Planck Chains section as follows:
gansuh@soliton2:~/Code/cosmomc: ln -s /home/gansuh/Code/PLA/ ./PLA (where my cosmomc and PLA under Code directory, but separate)

2. to initialize it for the location:
gansuh@soliton2:~/Code/cosmomc: python python/makeGrid.py PLA settings_planck_nominal

3. to run getdist over the grid:
gansuh@soliton2:~/Code/cosmomc: python python/runGridGetdist.py PLA --burn_removed

4. After that:
gansuh@soliton2:~/Code/cosmomc: python batch1/outputs/triangle_planckonly_vs_WMAP.py

then error looks like:
gansuh@soliton2:~/Code/cosmomc: python batch1/outputs/triangle_planckonly_vs_WMAP.py
Traceback (most recent call last):
File "batch1/outputs/triangle_planckonly_vs_WMAP.py", line 13, in <module>
legend_labels=labs)
File "/home/gansuh/Code/cosmomc/python/GetDistPlots.py", line 574, in triangle_plot
params = self.get_param_array(roots[0], in_params)
File "/home/gansuh/Code/cosmomc/python/GetDistPlots.py", line 434, in get_param_array
if not isinstance(in_params[0], paramNames.paramInfo): return self.paramNamesForRoot(root).parsWithNames(in_params, error=True)
File "/home/gansuh/Code/cosmomc/python/GetDistPlots.py", line 239, in paramNamesForRoot
if not root in self.param_name_sets: self.param_name_sets[root] = self.sampleAnalyser.paramsForRoot(root, labelParams=self.settings.param_names_for_labels)
File "/home/gansuh/Code/cosmomc/python/GetDistPlots.py", line 147, in paramsForRoot
names = paramNames.paramNames(self.plot_data_file(root) + '.paramnames')
File "/home/gansuh/Code/cosmomc/python/paramNames.py", line 48, in __init__
if fileName is not None: self.loadFromFile(fileName)
File "/home/gansuh/Code/cosmomc/python/paramNames.py", line 117, in loadFromFile
f = open(fileName)
IOError: [Errno 2] No such file or directory: 'main/plot_data/base_planck_lowl_post_lensing.paramnames'
gansuh@soliton2:~/Code/cosmomc:

I have not make any directory named "main", but it showed up in the IOError.

Also I would like to make sure that whether I have done the previous steps correctly with your help. In the Using Planck Chains section, I make a symbolic link as following way

gansuh@soliton2:~/Code/cosmomc$ ln -s /home/gansuh/Code/PLA/ ./PLA

instead of "ln -s /scratch/planck/PLA ./PLA" is that correct?

Could you correct me to reproduce the last figure of the link that I have mentioned above?

Any suggestion would be helpful.
Thank you.

Antony Lewis
Posts: 1944
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Plotting with python script

Post by Antony Lewis » March 19 2014

The web page example explicitly sets the correct PLA/plot_data directory in the sample code. The scripts in batch1/outputs assume main/plot_data assume the default ./main directory - you can probably just make a symbolic link from ./main to your PLA directory.

Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Re: Plotting with python script

Post by Gansukh Tumurtushaa » March 21 2014

Dear Antony,

Thank you for the reply.
Let me make sure two things.
Antony Lewis wrote:The scripts in batch1/outputs assume main/plot_data assume the default ./main directory - you can probably just make a symbolic link from ./main to your PLA directory.
You mean that the main directory is the cosmomc directory, and the scripts in batch1/outputs assume it as main directory, is that right?

To make a symbolic link, I have used following line:

gansuh@soliton2:~/Code/cosmomc: ln -s /home/gansuh/Code/all_tar_files/PLA/ ./PLA

where "~/Code/cosmomc$" directory is my main directory(I think) and "/home/gansuh/Code/all_tar_files/PLA/" is the path where PLA is located.

Since it worked out, I guess, maybe I've understood coreectly, but please give a comment on these two.

Best,
Gansukh

Antony Lewis
Posts: 1944
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Plotting with python script

Post by Antony Lewis » March 21 2014

in your cosmomc directory

ln -s ./PLA ./main

("main" being "main", not a placeholder for your cosmomc directory)

Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Plotting with python script

Post by Gansukh Tumurtushaa » March 24 2014

Dear Antony,

Thank you for the previous replies.
I have another problem when I run the web page example. The following error occured:
Code wrote:
gansuh@soliton2:~/Code/cosmomc: python batch1/outputs/triangle_planckonly_vs_WMAP.py
Traceback (most recent call last):
File "batch1/outputs/triangle_planckonly_vs_WMAP.py", line 14, in <module>
g.export('triangle_planckonly_vs_WMAP')
File "/home/gansuh/Code/cosmomc/python/planckStyle.py", line 53, in export
GetDistPlots.GetDistPlotter.export(self, 'outputs/' + fname + '.pdf')
File "/home/gansuh/Code/cosmomc/python/GetDistPlots.py", line 698, in export
savefig(fname, bbox_extra_artists=self.extra_artists, bbox_inches='tight')
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 471, in savefig
return fig.savefig(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 1185, in savefig
self.canvas.print_figure(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 2021, in print_figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backend_bases.py", line 1789, in print_pdf
return pdf.print_pdf(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_pdf.py", line 2180, in print_pdf
file = PdfFile(filename)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_pdf.py", line 370, in __init__
fh = file(filename, 'wb')
IOError: [Errno 2] No such file or directory: 'outputs/triangle_planckonly_vs_WMAP.pdf'
gansuh@soliton2:~/Code/cosmomc:

Could you suggest me what I can do in this case, please?
Thank you.

The best,
Gansukh Tumurtushaa

Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Plotting with python script

Post by Gansukh Tumurtushaa » March 24 2014

Dear Antony,

Thank you for the all helpful feed back.
Finally, I have reproduced the web page example.
Thank you very much once again.

The best,
Gansukh Tumurtushaa

Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Plotting with python script

Post by Gansukh Tumurtushaa » April 02 2014

By the way,

Can one still reproduce web page example with the latest March 2014 version?

-Gansukh

Antony Lewis
Posts: 1944
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Plotting with python script

Post by Antony Lewis » April 02 2014

Should work much the same.

Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Plotting with python script

Post by Gansukh Tumurtushaa » April 03 2014

An attributeError occurred after running the latest CosmoMC with following command:

Code: Select all

gansuh2@soliton2&#58;~/project1/cosmomc&#36; python python/makeGrid.py PLA settings_planck_nominal
Traceback &#40;most recent call last&#41;&#58;
  File "python/makeGrid.py", line 40, in <module>
    batch.makeItems&#40;settings.groups&#41;
  File "/home/gansuh2/project1/cosmomc/python/batchJob.py", line 227, in makeItems
    item.makeImportance&#40;group.importanceRuns&#41;
  File "/home/gansuh2/project1/cosmomc/python/batchJob.py", line 79, in makeImportance
    if len&#40;arr&#41; > 2 and not arr&#91;2&#93;.wantImportance&#40;self&#41;&#58; continue
  File "/home/gansuh2/project1/cosmomc/python/settings_planck_nominal.py", line 50, in wantImportance
    return planck in jobItem.dataname_set and &#40;not'omegak' in jobItem.param_set or &#40;len&#40;jobItem.param_set&#41; == 1&#41;&#41;
AttributeError&#58; jobItem instance has no attribute 'dataname_set'
The command was fine with previous one, Dec2013 version.
Would you kindly help me to figure it out?
Thank you.

Antony Lewis
Posts: 1944
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Plotting with python script

Post by Antony Lewis » April 03 2014

Ah, think I forgot to move across the updated file to the release version.. try changing the offending line to

Code: Select all

        return planck in jobItem.data_set.names and &#40;not'omegak' in jobItem.param_set or &#40;len&#40;jobItem.param_set&#41; == 1&#41;&#41;

Gansukh Tumurtushaa
Posts: 34
Joined: October 05 2013
Affiliation: Sogang univ.

Plotting with python script

Post by Gansukh Tumurtushaa » April 03 2014

Wow you are the best!
Now it works. Thank you.

Antony Lewis
Posts: 1944
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Plotting with python script

Post by Antony Lewis » April 30 2014

Should now be fixed in the April 2014 cosmomc version

Post Reply