예제 #1
0
# usage:
# python covcmb.py out.covmat in1.covmat in2.covmat
# Nb. in1 values take priority over in2
from __future__ import print_function
import sys
from getdist import covmat

if len(sys.argv) < 3:
    print(
        'Usage: python covcmb.py out.covmat in1.covmat in2.covmat [in3.covmat...]'
    )
    sys.exit()

foutname = sys.argv[1]

cov = covmat.CovMat(sys.argv[2])

for fname in sys.argv[3:]:
    print('merging: ' + fname)
    cov = cov.mergeCovmatWhereNew(covmat.CovMat(fname))

cov.saveToFile(foutname)
예제 #2
0
filemeans.close()

print 'MEANS AND BESTFIT FILES CREATED'

stats = samples.getMargeStats()

stats.saveAsText('../output/chains/1Dstatistics.txt')

print '1D STATISTICS FILE CREATED'

f = plots.getSubplotPlotter()

f.settings.rcSizes(axes_fontsize = 2,lab_fontsize = 7)

f.plots_1d(samples,['omega_b','omega_cdm','n_s','A_s','H0','m_ncdm','nc_bias_b0','cs2_fld','w0_fld','f_pi','g_pi','tau'])#,markers=[2.225e-2,1.198e-1,9.645e-1,2.20652e-9,6.727e1,6.0e-2,1.],nx=3)

f.export('../output/chains/1D_plots.pdf')

print '1D PLOTS CREATED'

covariance_matrix = samples.getCov(pars=[0,1,2,12,4,5,6,7,8,9,13,11])#nparam=number_of_parameters)

covariance_matrix_2 = covmat.CovMat(matrix=covariance_matrix)

covariance_matrix_2.saveToFile('../output/chains/covariance_matrix.txt')

print 'COVARIANCE MATRIX CREATED'

exit()

예제 #3
0
import sys
import fnmatch
import os
from getdist import covmat

if len(sys.argv) < 4:
    print(
        'covscale rescales parameter(s) in all .covmat files in a directory and outputs to another directory'
    )
    print(
        'Usage: python covscale.py in_dir out_dir param1:param2:.. fac1:fac2:..'
    )
    sys.exit()

indir = os.path.abspath(sys.argv[1]) + os.sep
outdir = os.path.abspath(sys.argv[2]) + os.sep
pars = sys.argv[3].split(':')
factors = sys.argv[4].split(':')

if not os.path.exists(outdir):
    os.makedirs(outdir)

for f in os.listdir(indir):
    if fnmatch.fnmatch(f, "*.covmat"):
        print(indir + f)
        cov = covmat.CovMat(indir + f)
        for par, factor in zip(pars, factors):
            cov.rescaleParameter(par, float(factor))
        cov.saveToFile(outdir + f)