Ejemplo n.º 1
0
# usage:
# python covcmb.py out.covmat in1.covmat in2.covmat
# Nb. in1 values take priority over in2

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)
Ejemplo n.º 2
0
import sys, fnmatch, os
from getdist import covMat

if len(sys.argv) < 4:
    print 'covscale rescales parmeter(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)