baudren / montepython_public

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

Using derived parameters in Likelihood #141

Closed pcampeti closed 3 years ago

pcampeti commented 4 years ago

Hello, I would like to use derived parameters like tau_eq in a likelihood that I created. I added to the .param file the line data.parameters['tau_eq'] = [112.8, -1, -1, 0, 1, 'derived'] and I tried to call the tau_eq parameter inside my new likelihood __init__.py file and to print it:

    `def loglkl(self, cosmo, data):
        tau_eq = (
        data.mcmc_parameters[p]['current']*data.mcmc_parameters[p]['scale']
        for p in ['tau_eq'])        
        print(tau_eq)
        lkl = 1
        return lkl

`

but I get the following error when running MontePython:

`Traceback (most recent call last): File "montepython/MontePython.py", line 40, in sys.exit(run()) File "/home/montepython_public/montepython/run.py", line 44, in run sampler.run(cosmo, data, command_line) File "/home/montepython_public/montepython/sampler.py", line 43, in run mcmc.chain(cosmo, data, command_line) File "/home/montepython_public/montepython/mcmc.py", line 301, in chain loglike = sampler.compute_lkl(cosmo, data) File "/home/montepython_public/montepython/sampler.py", line 543, in compute_lkl "Could not write the current derived parameters") io_mp.CosmologicalModuleError:

Cosmological Module Error: /|\ Could not write the current derived parameters`

Is there any way I can use these derived parameters in my likelihood? Thank you very much in advance!

lesgourg commented 3 years ago

Your are raising issues on the old MontePython repository (active in 2013-2018). As clearly stated on the wiki of this repository, since April 2018 and version 3.0, the MontePython repository has moved to https://github.com/brinckmann/montepython_public Please go there to clone recent, working and maintained versions of the code, and raise issues if necessary.