Page 1 of 1

adding a derived parameter

Posted: September 13 2015
by Ali Narimani
I am trying to add "omegab" as a parameter to the chains and then use it in my plots, but it doesn't work. I have attached my script, which I think follows the guidelines very closely. Here is the code:

Code: Select all

roots = ['../chains1/test', '../chains2/test']
for r in roots:
	samples = getdist.loadMCSamples(r) 
	p = samples.getParams()
	omegab = p.omegabh2/ p.H0**2 * 100**2
	samples.addDerived(omegab, name='omegab', label=r'\Omega_b')
	samples.updateBaseStatistics()



labels=['chain1', 'chain2']
params = ['H0','ns','omegam','omegab','tau','logA']

g = plots.getSubplotPlotter(width_inch=5)
g.settings.axes_fontsize = 9
g.settings.legend_fontsize = 10
g.plots_1d(roots,params, nx = 3, legend_labels=labels)
g.export()
Thanks

Re: adding a derived parameter

Posted: September 14 2015
by Antony Lewis
The first bit of code is only adding the parameter to the "samples" instance in memory. You aren't using this for plotting, but instead loading again from the files on disk (which don't have the new parameter).

Make samples1, samples2 with the new parameter added, and then

Code: Select all

g.plots_1d([samples1,samples2]....)