baudren / montepython_public

Public repository for the Monte Python Code
MIT License
65 stars 117 forks source link

How to use info.redefine #92

Open AdriPos opened 7 years ago

AdriPos commented 7 years ago

Hi all!

I'm using Montepython to estimate cosmological parameters from the density Cl. In particular, I'm varying _Omegacdm and _Omegab, but I would also like to have plots with _Omega_totalmatter and _fb, the baryon fraction.

For this purpose, I'm trying to use the example.plot file I can add to my analysis with the --extra command. The problem is that I can define for example the total matter density instead of the cold dark matter density:

_info.redefine = {'Omega_cdm' : '(Omega_b + Omega_cdm)'} info.to_change = {'Omega_cdm': 'Omegam'}

or I can do the same for the baryon fraction instead of the baryon density:

_info.redefine = {'Omega_b': 'Omega_b/(Omega_b+Omega_cdm)'} info.to_change = {'Omega_b': 'fb'}

but I can't do both in the same time, since if I redefine for example _Omegab as the baryon fraction, this will affect the total matter density definition (I would have something like total matter = cold dark matter + baryon fraction).

Is there a way of solving my problem? Maybe the example.plot file is not the right choice in order to do what I want to do?

Thank you so much! Adriana

borisbolliet commented 7 years ago

Hi Adriana,

To get what you want I think you need to do:

info.redefine = {
'Omega_cdm' : '(Omega_b + Omega_cdm)',
'Omega_b':'Omega_b/Omega_cdm'
}

info.to_change = {
'Omega_cdm': 'Omega_m',
'Omega_b': 'f_b'
}

info.to_plot = [
'Omega_m',
'f_b'
]

This will plot 'Omega_m' and 'f_b', but not 'Omega_cdm' and 'Omega_b'.

Now, if you would like to plot the four quantities at the same time, you need to write a little code that reads your chains '*.txt' and adds two columns with the desired derived parameters, e.g. 'Omega_m' and 'f_b'.

Once you have the chains files with all the columns (parameters) you need, you can modify the log.param file and add the following two lines by hand:

data.parameters['Omega_m']          = [1, None, None, 0,     1,   'derived']
data.parameters['f_b']          = [1, None, None, 0,     1,   'derived']

(Note that it does not matter if 'f_b' is not defined in CLASS, as Montepython reads the names of the parameters in the log.param file when you analyze the chains.)

I hope this helps, Boris

brinckmann commented 7 years ago

Hi, I think this would work, but it's not necessary to create a separate script as the option to add derived parameters exists in MontePython, please see the help and documentation. Omega_m and omega_m are already available as derived parameters via the class wrapper (please note depending on your version omega_m may be wrong and is divided by h^2 instead of multiplied, this is easy to fix) and it should be easy to add f_b to the wrapper in a similar way to how Omega_m is added. Regards, Thejs

borisbolliet commented 7 years ago

Ha, Yes!
Thank you very much Boris