baudren / montepython_public

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

Learning MontePython and CosmoMC #111

Open esadri21 opened 6 years ago

esadri21 commented 6 years ago

Dear friends. I have just learnt to use MCMC (M-H algorithm). Now I would like to go toward learning Motepython and CosmoMC. At first step, I choose MontePython. But I could not find any useful tutorial. I think it is very complicated. Could you help me about this issue?

brinckmann commented 6 years ago

You can find MontePython tutorials on the course page of Julien Lesgourgues' website: https://lesgourg.github.io/courses.html Best, Thejs

ivandebono commented 6 years ago

I found this to a very good tutorial: http://www.iac.es/congreso/cosmo2017/media/montepython.pdf It goes into a lot more detail than the Montepython manual.

esadri21 commented 6 years ago

@ivandebono Thank you, I have checked it before, but similar to Cosmo MC, EMCEE, CosmoHammer needs to clarifications and class to learn. Really I don't understand why these tutorial are not simple. Assume, in mathematics class they teach 2+2 and in the exam they want us to solve 3order ODE.

ivandebono commented 6 years ago

I get your point. The best way to learn Montepython is to talk to experienced users, or even someone who's justing starting out. With software, you can often find solutions to little snags just by discussing them with someone else.

I would be happy to provide some hints if you would let me know what you need. I put up a couple of posts on my website, but they're specific to users of the computing cluster at my institute.

esadri21 commented 6 years ago

@ivandebono Thank you. Unfortunately I couldn't find anyone so for to do so. But the whole thing is fitting data of a model in astrophysics, from simple models like wCDM to complicated ones. I have wanted to learn EMCEE but after writing the code, there were no one to help me that what are the probable problems of my code (Teachers of EMCEE and authors of papers). Hence, I went toward using MontePython, But this one is more harder than EMCEE. Sometimes I tell God: God, for God sake help me :))

ivandebono commented 6 years ago

I find that gods tend to have their favourites which they shower with favours, while ignoring the pleas of the rest.

Be that as is it may. The first thing to do is to choose a data set to which you wish to fit your model. Then you must choose a theoretical model: Lambda CDM, or wCDM, for example. It doesn't matter which values your parameters take. You will decide that later.

The instructions here are quite straightforward: http://monte-python.readthedocs.io/en/latest/example.html

In this example, the date is a fake Planck data set (i.e. essentially CMB anisotropy measurements), and the theoretical model is Lambda CDM. You are trying to find the best value of the six parameters in the Lambda CDM model.

You choose the parameters to fit (usually the ones which will appear in your final triangle plot) in input/lcdm.param

I hope that helps. Have you tried running the example shown here? You should do that before tackling harder stuff.

esadri21 commented 6 years ago

@ivandebono I will try it out for sure. The first reason of why I came toward learning MontePython etc, was my problem in metropolis hastings method. I wrote a correct code in Python, but in each run it printed different outputs. So, I am getting stuck in a loop.

esadri21 commented 6 years ago

About trying MP(montepython), I have to install ubunto, then running a MP code to see what is the output.

ivandebono commented 6 years ago

Try running the example here: http://monte-python.readthedocs.io/en/latest/example.html

If you get stuck, I'll try to help.

esadri21 commented 6 years ago

Yeah, thank you. I read this link before, but first of all I need to read http://monte-python.readthedocs.io/en/latest/installation.html. I really do not understand what are the instructions. For me they seem Chinese language. "At minimum, default.conf should contain one line, filled with the path of your class/ directory:" "path['cosmo'] = 'path/to/your/class/'" and etc. I think I need more attention. But I do not used to read these such simple/professional instructions.

ivandebono commented 6 years ago

Though not quite Chinese, the instructions could do with a bit of language editing.

What these instructions mean to say is that the location CLASS needs to be specified in the default configuration file used by Montepython.

If you followed the installation instructions, you should have installed CLASS somewhere.

There is a file called 'default.conf' in the folder called 'montepython'. It should contain the following line: path['cosmo'] = 'path/to/your/class/'

Replace 'path/to/your/class/' with the file path to the folder containing CLASS. If you installed it in your home directory, the typical file path would look like this: '~/class'. Or, if you're running your calculations on a cluster with many users, it would be something like '/home/username/class'.

So the line would be:

path['cosmo'] = '~/class'

or

path['cosmo'] = '/home/username/class'

esadri21 commented 6 years ago

I created a folder (with name 'code') copied and pasted the 'montepython' in it. then I downloaded and pasted 'class' folder in code folder too. I mean code folder contains two folders by now, montepython and class. For directory in configuration file should I write: path['cosmo'] = 'c:\user...\class' or its place in code folder is path['cosmo'] = '~/class'. the code folder is in my desktop.

and path['clik'] = 'path/to/your/plc/folder/' what path must be written in it? and Planck_highl.path_clik = data.path['clik']+'../something.clik' is for Planck_highl. for 3 rest likelihood of planck we should write it again? and where it should be written?

Ah, too many questions. Sorry. I just read the instruction by this line, and the rest is for another time.

ivandebono commented 6 years ago

Here's my configuration file. It contains just three lines, giving the location of the root directory (i.e. the home directory where I find myself when I log into the computing cluster), the path to CLASS, and the path to the Planck likelihood code (clik). The cluster runs on UNIX, so you may need to adapt it to your operating system. I haven't tried running it on Windows.

root = '/home/debono' path['cosmo'] = root+'/class' path['clik'] = root+'/plc-2.0'

ivandebono commented 5 years ago

It's been a while, but I thought I might flag up this link:

http://borisbolliet.com/Research.html

It contains one of the best tutorials on Montepython, dealing with some problems specific to installing and running on a cluster (which is what most of us do).

esadri21 commented 5 years ago

Thank you dear friend. By the way I need to be focused on. I will try to learn it. These months I was working on some papers.