# the installation and use of Monte Pyhton is documented in http://monte-python.readthedocs.io # but here we give you guidelines such that you may do the exercises without reading more that this file :-) # 1. go to a folder of your choice; we recommend the one containing the directory class_public/ (but don't go inside class_public/ !) > cd ...... # 2. clone their the branch 2.2 of MontePyhton from git: > git clone https://github.com/baudren/montepython_public.git # 3. now you should have the two class and MP directories in the same place: > ls montepython_public class_public # 4. check that class is compiled, if not, compile it with: > cd class_public/ > make clean > make -j > cd .. # 5. note that things won't work if the class python wrapper was not compiled correctly. When you do: > pyhton >>> import classy # the code should not complain # 6. go to the MP folder cd montepython_public/ # 7. you must teach MP where CLASS is located; for that: > cp default.conf.template default.conf # 8. edit the file default.conf (with emacs, vim, etc...) and replace the line root = '/Path/to/your/codes' #with the actual path of the directory that contains class_public/ and montepyhton_public/ # 9. now update the line path['cosmo'] = root+'/class' # with the name and path of the directory containing class relative to the previous path, no normally you should simply replace with path['cosmo'] = root+'/class_public' # 10. look at the content of the file example.param. Check that it will use the likelihood 'fake_planck_bluebook' (idealised Planck likelihood using mock data, written before the actual planck data became available). Check that it will vary just the 6 parameters of the LambdaCDM model and that it will write two derived parameters. # 11. run one chain of 10 points with: > python montepython/MontePython.py run -p example.param -o my_first_run/ -N 10 # 12. if the run succeeds, go to the next step. If not, if something fail, try to understand and solve the problem, but it is important that before any new attempt to run your first delete the previous output file: > rm -rf -o my_first_run/ # 13. otherwise, your problem might reproduce forever because it has been logged to a file. # 14. if it worked, check that the file has created three files inside my_first_run/: 2017-07-26_10_.paramnames 2017-07-26_10__1.txt log.param # 15. edit the chain directory and check that it does contain a few lines. Check that the sum of integere numbers in the first column (the weight or mutiplicity parameter) is 10 as you requested. Check that the number in the scond column (-ln(Likelihood) = 0.5*chi^2_effective) is roughly decreasing (because the chain is moving roughly towards the bestfit). # 16. open the file my_first_run/log.param abd check that it contains all the information about your run (version of class, copy of the input file, information about the liklihood being used, ...) # from now on any run in this directory, with "-o my_first_run/" will use this file to start. You could pass "-p example.param" or not, it would make no difference. This is why after a failed run you would have to delete the log.param before retrying. But if you run was successfull you can launch a second chain with just: > python montepython/MontePython.py run -o my_first_run/ -N 10 # 17. do that and check that a second chain has been created: 2017-07-26_10__2.txt # 18. type > python montepython/MontePython.py run --help # just to check that in principle, the code would offer you many running options # 19. you have two chains of 10 points each. It is not enough for analysis and plotting. Check it by typing > python montepython/MontePython.py info my_first_run/ # 20. you should get this message: Analyze Error: /|\ No decently sized chain was found. Please wait a bit to analyze this /_o_\ folder # 21. check that in principle, the analysis+plotting module gives you many options, by typing > python montepython/MontePython.py info --help # 22. if the chains were big enough, you would have the choice to make plots with MontePython itself, or with Antony Lewis's code Getdist. The file my_first_run/2017-07-26_100_.paramnames # that has been automatically created ensures compatibility with getdist. It contains the parameter names. Montepyhton does not need this file becuase it reads the same information directly insde the log.param # 23. have a quick look at the name of all likelihoods implemented in the current public montepyhton version: > ls montepython/likelihoods/ # any of these names could be added to the list of likelihoods at the beginning of your input file. # 24. now, we want to try the analysis tool on long chains! We can do it provided that we do a run requiring a minimal execution time for each model (fast class + fast likelihood). It is possible e.g. if we only try to fit the likelihoods called hst and bao_boss, becuase they only ask CLASS to compute the background evolutiopn, not the perturbations. To check what these likelihoods are about, look at the content of the files: more montepython/likelihoods/hst/hst.data more montepython/likelihoods/bao_boss/bao_boss.data # as you understand, the first is the H0 measurement of Riess et al., while the second is a compilation of slightly obsolete BAO data from 2015 (we have more bao data and we will update with BOSS DR12 in a forthcoming release). # 25. to fit only these two likelihoods, you can create from scratch a very simple input parameter file bao_hst.param with just 5 lines: data.experiments=['bao_boss','hst'] # data.parameters['omega_cdm'] = [0.15, -1,-1, 0.019,1, 'cosmo'] data.parameters['h'] = [0.74, -1,-1, 0.024,1, 'cosmo'] # data.cosmo_arguments['YHe'] = 0.25 # data.write_step=50 # 26. check that you can run a small chain with python montepython/MontePython.py run -p bao_hst.param -o bao_hst/ - N 10 # 27. if it fails, correct your mistake, remembering that between unsuccesful attempts, wou must always delete the log.param. # 28. if it works, keep your log.param , and launch one or two big chains in silent + update mode: python montepython/MontePython.py -o bao_hst/ -N 10000 --silent --update 300 #To run 2 chains simultaneously you can type the same line on two terminals or you can type: > python montepython/MontePython.py -o bao_hst/ -N 10000 --silent --update 300 & > python montepython/MontePython.py -o bao_hst/ -N 10000 --silent --update 300 & # This makes sense on a laptop. On a cluster you would have a submission script, and you would try to use MPI to launch N chains in 1 line. Each chain should take a few minutes only on your laptop/desktop, but you can go on working in the meantime: # 29. Indeed it is possible to try to analyse and plot in real time while the chains are working, eventually from another terminal. First you can monitor the number of lines in the chains at anytime with > wc bao_hst/*.txt # 30. As soon as you have a few hundreds lines in totoal you can try: > python montepython/MontePython.py info bao_hst/ --no-mean # 31. check all the results of the analysis: the text files bao_hst/bao_hst.v_info bao_hst/bao_hst.h_info bao_hst/bao_hst.log bao_hst/bao_hst.bestfit bao_hst/bao_hst.covmat # the latex file bao_hst/bao_hst.tex # the PDF plots bao_hst/plots/bao_hst_1d.pdf bao_hst/plots/bao_hst_triangle.pdf # 32. in the future, if you want to do a run with a similar model (but wven with slightly different likelihoods or additional cosmological parameters) you could use the bestfit and covmat of this previous run as a guess: it will make the code faster at the beginning. To check that this works, you may load a last chain with > python montepython/MontePython.py -o bao_hst/ -N 10 -c bao_hst/bao_hst.covmat -b bao_hst/bao_hst.bestfit # 33. if you are done you can try many things: add a likelihood like e.g. 'fake_planck_bluebook', restoring all the 6 LambdaCDM parameters; add more cosmological parameter (any of the ones defined in explanatory.ini); add more derived parameters; or customise your plot with the option > python montepython/MontePython.py info bao_hst/ --no-mean --extra plot_files/my_settings.plot # where plot_files/my_settings.plot is your customisation file, inspired from plot_files/example.plot # 34. You may send me your triangle plots by emails, I will show the nicest one in my sides of tomorrow :-)