CosmoMC generic sampler: data filename in input file and labels on header of chain files?

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Gary Mamon
Posts: 3
Joined: November 18 2010
Affiliation: IAP, Paris
Contact:

CosmoMC generic sampler: data filename in input file and lab

Post by Gary Mamon » February 03 2011

I am using CosmoMC as a generic sampler. I read the data in GenericLikelihoodFunction in calclike.f90 (on the first pass only).

1) I would like to avoid recompiling the program every time I change the data file. Can the data filename be specified in params_generic.ini? Can the CosmoMC code be simply changed to allow this?

2) It would be very useful to have the output columns of the chains be preceded by a header line of labels. So, I tried to specify parameter names in params_generic.ini as for the CMB case, e.g.

Code: Select all

param[logHaloMass] = 13 11 15 0.2 0.2
and I edited SetParamNames in params_CMB.f90 as follows:

Code: Select all

if (generic_mcmc) then
call ParamNames_init(Names,trim(LocalDir)//'params_generic.paramnames')
else
and created a params_generic.paramnames file in the directory above source, with the same syntax as the params_CMB.paramnames file. This runs fine, but fails to provide the headers in the chain files. Again, are there simple changes that I could make to the CosmoMC code to allow for this?

Antony Lewis
Posts: 1943
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: CosmoMC generic sampler: data filename in input file and

Post by Antony Lewis » February 03 2011

1. Yes, just define a string variable somewhere and read it from inidriver like all the other input parameters

2. Parameter names are not put in chain file headers, but as a separate .paramnames file produced along with each set of chains.

Gary Mamon
Posts: 3
Joined: November 18 2010
Affiliation: IAP, Paris
Contact:

CosmoMC generic sampler: data filename in input file and lab

Post by Gary Mamon » February 04 2011

1. Yes, just define a string variable somewhere and read it from inidriver like all the other input parameters
Thanks, Antony, for your reply.

I guess you meant source/driver.F90 rather than camb/inidriver.f90. I inserted in SolveCosmology of source/driver.F90

Code: Select all

         if (generic_mcmc) then
            data_file = Ini_Read_String('data_file')
            print *,' data_file=', trim(data_file)
         endif
before

Code: Select all

        propose_scale = Ini_Read_Real('propose_scale',2.4)
        AccuracyLevel = Ini_Read_Real('accuracy_level',1.)
and declared data_file with the top declarations in settings.f90 and it works! I will do the same for all the parameters of my generic models.

Post Reply