python script

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
daan meerburg
Posts: 27
Joined: November 20 2007
Affiliation: Cambridge

python script

Post by daan meerburg » April 11 2013

Hi there,
I am trying to run a python plot script, given some of the examples found in the batch1/outputs directory and the website. I have run a planck chain, and the getdits output are "planck_29.00'. After an example, I tried to code:

import GetDistPlots
g=GetDistPlots.GetDistPlotter('PLA/plot_data')
g.settings.setWithSubplotSize(4)

roots = ['planck_29.00']
g.plot_2d(roots, param_pair=['logA','amp'], filled=True)
g.add_legend(['w = 29.00'],legend_loc='upper right');
g.export('amp_logA.png')

However, running this I get:


File "python/mypy.py", line 6, in <module>
g.plot_2d(roots, param_pair=['logA','amp'], filled=True)
File "/home/meerburg/oscillations_planck/cosmomc/python/GetDistPlots.py", line 300, in plot_2d
self.setAxes(param_pair, **ax_args)
File "/home/meerburg/oscillations_planck/cosmomc/python/GetDistPlots.py", line 336, in setAxes
self.setAxisProperties(ax.xaxis, True, prune)
File "/home/meerburg/oscillations_planck/cosmomc/python/GetDistPlots.py", line 328, in setAxisProperties
tick_params(axis='both', which='major', labelsize=self.settings.axes_fontsize)
NameError: global name 'tick_params' is not defined


so there is some parameter that is not defined. Anyone else has encountered this problem? I have also tried to run a similar python script with the planck style file, but I get a different error there, because the default dir is set to 'main' as opposed to PLA. I am not sure in which of the py scripts I should change that. I will try and edit a little more and see if I have some luck.

Thanks
Daan

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

Re: python script

Post by Antony Lewis » April 11 2013

Seems to be a standard part of matplotlib

http://matplotlib.org/api/axes_api.html ... ick_params

maybe check you don't have very old version?

You can symbolic link "./main" to whatever directory you like if you want to try planckStyle.

Björn Sörgel
Posts: 13
Joined: April 05 2013
Affiliation: Institute of Astronomy/Kavli Institute for Cosmology Cambridge

python script

Post by Björn Sörgel » April 16 2013

Hi,

I also have a problem with the python scripts:

When running getdist from the python scripts, e.g. with
bsoergel@werc1:~/programs/cosmomc2013> python2.7 python/runGridGetdist.py PLA --paramtag base --data planck

first everything works well, but at some some point the script stops with the error message

reading /home/moon/bsoergel/programs/cosmomc2013/PLA/base/planck_tauprior_highL
/base_planck_tauprior_highL_post_lensing_8.txt
outlier fraction 1.8102824E-04
Number of chains used = 8
var(mean)/mean(var), remaining chains, worst e-value: R-1 = 0.03378
mean input multiplicity = 4.839473827901345E-003
using 16572 rows, processing 60 parameters
effective number of samples (assuming indep): 343
Best fit -Ln(like) = 4260.85200000000
mean(-Ln(like)) = 4272.56725768099
-Ln(mean like) = 4267.17859900803
doing 2D plots for most correlated variables
Producing 12 2D plots
Traceback (most recent call last):
File "python/runGridGetdist.py", line 67, in <module>
if not args.norun and not args.noplots or args.compare_only:
AttributeError: 'Namespace' object has no attribute 'compare_only'


When using other parameters or other data, I still get the same problem, e.g.

reading /home/moon/bsoergel/programs/cosmomc2013/PLA/base_mnu/WMAP/base_mnu_WMA
P_post_Union2_8.txt
Number of chains used = 8
var(mean)/mean(var), remaining chains, worst e-value: R-1 = 0.01195
mean input multiplicity = 0.504715263331951
using 10685 rows, processing 32 parameters
effective number of samples (assuming indep): 5057
Best fit -Ln(like) = 3844.08700000000
mean(-Ln(like)) = 3847.39288923199
-Ln(mean like) = 3846.34234651625
Producing 31 2D plots
Traceback (most recent call last):
File "python/runGridGetdist.py", line 67, in <module>
if not args.norun and not args.noplots or args.compare_only:
AttributeError: 'Namespace' object has no attribute 'compare_only'


When I run getdist by itself and not via the python scripts, it works perfectly well.

Thanks,
Björn

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

Re: python script

Post by Antony Lewis » April 16 2013

This is a bug, but I think it only breaks after it has calculated everything so all outputs should be OK?

Björn Sörgel
Posts: 13
Joined: April 05 2013
Affiliation: Institute of Astronomy/Kavli Institute for Cosmology Cambridge

python script

Post by Björn Sörgel » April 16 2013

Hi Antony,
thanks for the quick reply. You are right, the outputs are all there.
At first, I was experiencing another error ("bad magic number") with the plotting routines in batch1/output and believed this to be somehow related to the error in runGridGetdist.py. Finally, I traced it back to some issue with the matplotlib installation, which should also be fixed now.

Thanks,
Björn

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

Re: python script

Post by Antony Lewis » April 17 2013

This should now be fixed in the April 2013 version.

Post Reply