brinckmann / montepython_public

Public repository for the Monte Python Code
MIT License
93 stars 79 forks source link

Create new derived parameter #232

Closed savero12 closed 1 year ago

savero12 commented 3 years ago

Hello everyone! I would like to ask about how to create new derived parameter that can be run with monte python. So, I would like to constrain cosmographic parameters (deceleration parameter, jerk parameter, snap parameter, and lerk parameter) with cosmological data (Pantheon, BAO, and Observation Hubble Data). I have relation equations between luminosity distance and cosmographic parameters. But, I don't know how to implement monte python to constrain those cosmographics parameter with cosmological data. Is there anyone who have any idea to do that? It would help me a lot. Thank you...

brinckmann commented 3 years ago

Hi,

If your parameters are in class you need to add them to the python wrapper in python/classy.pyx and python/cclassy.pxd . Look for an example parameter that already exists in the get_current_derived_parameters function in classy.pyx (line 1778 in class 3.0.1), e.g. H0:

            elif name == 'H0':
                value = self.ba.h*100

1) You need to add something similar, replacing H0 with your new parameter and changing the internal class variable, in this case self.ba.h (and of course probably remove 100), so the parameter h in the ba (background) module (internally in class you'd write it as pba->h). 2) You need to make sure your parameter is added to cclassy.pxd, where in the case of h you look at the function cdef struct background (line 58 in class 3.0.1), where it's defined as double h (line 71 in class 3.0.1). 3) Then you can simply add it as a 'derived' parameter in your input param file.

If the derived parameter is not defined within class, but only within your likelihoods, you instead need skip 1) and 2) and instead add the parameter as a 'derived_lkl' parameter in your input param file. You can see it used in this example param file.

You will also need to add the derived_lkl to your likelihood, see the init file of the Lya_abg as an example of what to add. I'm less familiar with the details of how it works, but searching for "derived_lkl" it only has a few lines specified in the likelihood, so hopefully it won't be difficult to figure out (note you might not need all of the lines, but I'm not sure). Perhaps @dchooper can help if your own attempt doesn't work?

Best, Thejs