Cosmomc Grids and Plotting with Python
The latest CosmoMC versions add a set of tools for generating and analysing grids of parameter runs using CosmoMC and GetDist, plus a variety of utility scripts and plotting functions.
See the ./python directory for scripts (python 2.7+). Most can be run without arguments to show a list of possible input parameters.
Grids of models
A description for a grid of models is given in a python settings file.
- I suggest making a directory for the (potentially large) outputs on a data disk, then doing ln -s /scratch//..//mygrid mygrid, so "mygrid" is an easy shorthand for the location. This name is used as a parameter for most of the scripts.
- Copy and edit python/settings_sample.py appropriately and save in e.g. python/my_settings_file.py
- To generate grid directories and .ini files for CosmoMC do
python python/makeGrid.py mygrid my_settings_file
-
Use runbatch.py to submit all the ini files produced to the queue; makeGrid will tell you what to do.
You will also need to produce a submission script for your machine. Edit the job_script file as appropriate for your machine, and if necessary the submitJob function in python/jobQueue.py.
Covmats for Planck are in planck_covmats folder, linked by default for grid runs.
Grid run scripts include:
- makeGrid.py: as descried above, for setting up a grid of models. Stores the information in a "pickle" file that can then be read by the other scripts for iterating over batch items.
- runbatch.py: submit runs to a job submission script
- settings_xx.py: sample settings files for use with makeGrid.py
- checkConverge.py --running: to check current convergence of chains which are running; without --running it finds chains which are missing or have R-1 larger than a specified threshold after you've run getdist (via runGridGetdist.py as described below)
- cleanup.py: for cleaning up files (e.g. before re-running a failed chain); can also just be used to list files for runs matching input parameters
- batchJob.py: not a script, this just defines the objects and iterators used
- addGridBatch.py: if you run multiple grids, e.g. a standard one and a separate small one for some parameter or test likelihood of interest, they can be combined using addGridBatch.py.
Once you have generated the chains using CosmoMC you can analyse them. Run python/runGridGetdist.py to run getdist over grid of models, and generating parameter constraints and files for plotting. Other scripts you can then use include
Most scripts have standardized input parameters to restrict to subsets of grid items, e.g. filtering by importance sampling run, no importance sampling, or specific item name (pattern match).
Plotting scripts
GetDistPlots.py is used in your own scripts for plots from getdist outputs. Add ./python to your $PYTHONPATH to use this from scripts elsewhere.
See Planck grid readme for examples.
Analysis scripts
Currently most analysis is done by GetDist. You can however use chains.py to read in chain files and do simple calculations (e.g. mean and variance of derived parameters).
See Planck grid readme for a simple example.
Other scripts
Multi-purpose use and utility scripts include
- bestFitCAMB.py: for converting .minimum best-fit file to CAMB input .ini file (not all parameter combinations)
- covscale.py: for modifying .covmat files if parameters are re-scaled
- covMat.py: object for covariance matrix and reading .covmat
- iniFile.py: for reading and writing .ini files (does not support reading fully at the moment, but not needed as yet)
- makePerfectForecastDataset.py: a simple old script for simulating perfect fake CMB datasets
- paramNames.py: for reading paramNames files, and general objects for storing parameter info
- ResultObjs.py: objects for getdist output results (.margestats) and .minimum files. Note is expects formats to be those produced by cosmomcplanck, not older versions.
- runningJobs.py: shows full long job names for running jobs (may not be portable) with status