Esempio n. 1
0
    def parseForBatch(self, vals=None):
        if self.importanceParameter:
            self.parser.add_argument('--noimportance', action='store_true',
                                     help='original chains only, no importance sampled')
            self.parser.add_argument('--importance', nargs='*', default=None,
                                     help='data names for importance sampling runs to include')
            self.parser.add_argument('--importancetag', nargs='*', default=None,
                                     help='importance tags for importance sampling runs to include')

        self.parser.add_argument('--name', default=None, nargs='+',
                                 help='specific chain full name only (base_paramx_data1_data2)')
        self.parser.add_argument('--param', default=None, nargs='+',
                                 help='runs including specific parameter only (paramx)')
        self.parser.add_argument('--paramtag', default=None, nargs='+',
                                 help='runs with specific parameter tag only (base_paramx)')
        self.parser.add_argument('--data', nargs='+', default=None, help='runs including specific data only (data1)')
        self.parser.add_argument('--datatag', nargs='+', default=None,
                                 help='runs with specific data tag only (data1_data2)')
        self.parser.add_argument('--musthave_data', nargs='+', default=None,
                                 help='include only runs that include specific data (data1)')
        self.parser.add_argument('--skip_data', nargs='+', default=None,
                                 help='skip runs containing specific data (data1)')
        self.parser.add_argument('--skip_param', nargs='+', default=None,
                                 help='skip runs containing specific parameter (paramx)')
        self.parser.add_argument('--group', default=None, nargs='+', help='include only runs with given group names')
        self.parser.add_argument('--skip_group', default=None, nargs='+', help='exclude runs with given group names')

        if self.notExist:
            self.parser.add_argument('--notexist', action='store_true',
                                     help='only include chains that don\'t already exist on disk')
        if self.notall:
            self.parser.add_argument('--notall', type=int, default=None,
                                     help='only include chains where all N chains don\'t already exist on disk')
        if self.doplots:
            self.parser.add_argument('--paramNameFile', default='clik_latex.paramnames',
                                     help=".paramnames file for custom labels for parameters")
            self.parser.add_argument('--param_list', default=None,
                                     help=".paramnames file listing specific parameters to include (only)")
            self.parser.add_argument('--size_inch', type=float, default=None, help='output subplot size in inches')
            self.parser.add_argument('--nx', default=None, help='number of plots per row')
            self.parser.add_argument('--outputs', nargs='+', default=['pdf'], help='output file type (default: pdf)')

        args = self.parser.parse_args(vals)
        self.args = args
        if args.batchPath:
            self.batch = batchjob.readobject(args.batchPath)
            if self.batch is None:
                raise Exception('batchPath %s does not exist or is not initialized with makeGrid.py' % args.batchPath)
            if self.doplots:
                import getdist.plots as plots
                from getdist import paramnames

                if args.paramList is not None: args.paramList = paramnames.ParamNames(args.paramList)
                g = plots.GetDistPlotter(chain_dir=self.batch.batchPath)
                if args.size_inch is not None: g.settings.set_with_subplot_size(args.size_inch)
                return self.batch, self.args, g
            else:
                return self.batch, self.args
        else:
            return None, self.args
Esempio n. 2
0
Opts.parser.add_argument('--compare', nargs='+', default=None)

Opts.parser.add_argument('--titles', default=None)  # for compare plots
Opts.parser.add_argument('--forpaper', action='store_true')
Opts.parser.add_argument('--separate_tex', action='store_true')
Opts.parser.add_argument('--header_tex', default=None)
Opts.parser.add_argument('--height', default="13in")
Opts.parser.add_argument('--width', default="12in")

(batch, args) = Opts.parseForBatch()

if args.blockEndParams is not None:
    args.blockEndParams = args.blockEndParams.split(';')

if args.paramList is not None:
    args.paramList = paramnames.ParamNames(args.paramList)

if args.forpaper:
    formatter = planckStyle.planckStyleTableFormatter()
else:
    formatter = None


def texEscapeText(string):
    return string.replace('_', '{\\textunderscore}')


def getTableLines(content, referenceDataJobItem=None):
    if referenceDataJobItem is not None:
        refResults = referenceDataJobItem.result_marge
    else:
Opts.parser.add_argument('--params', nargs='+')
Opts.parser.add_argument('--chain_name_params', nargs='+')

Opts.parser.add_argument('--compare', nargs='+', default=None)
Opts.parser.add_argument('--nobestfits', action='store_true')
Opts.parser.add_argument('--single_extparam', action='store_true')
Opts.parser.add_argument('--limit', type=int, default=2)
Opts.parser.add_argument('--latex_filename', default=None)
Opts.parser.add_argument('--mathColumns', action='store_true')
Opts.parser.add_argument('--endline', default='\\cr')
Opts.parser.add_argument('--paramNameFile', default='clik_latex.paramnames')

(batch, args) = Opts.parseForBatch()
formatter = types.TableFormatter()

names = paramnames.ParamNames(args.paramNameFile)

if args.chain_name_params is None: args.chain_name_params = args.params

if args.compare:
    args.compare = [batch.normalizeDataTag(dat) for dat in args.compare]

table = dict()
paramtag_for_param = dict()
for par in args.params:
    paramtag_for_param[par] = []

for jobItem in Opts.filteredBatchItems():
    if (args.compare is None or jobItem.matchesDatatag(args.compare)) and (
            not args.single_extparam or len(jobItem.param_set) == 1
            and jobItem.hasParam(args.chain_name_params)):
Opts.parser.add_argument('--labelNames',
                         default=None,
                         help=".paramnames file for new param labels")
Opts.parser.add_argument('--map_file',
                         help="file with rows of oldname newname label")
Opts.parser.add_argument('--confirm',
                         action='store_true',
                         help="true to replace .paramnames files")

(batch, args) = Opts.parseForBatch()

if args.old_new and len(args.old_new) < 2:
    raise Exception('Must have at least one pair of parameters to rename')

if args.labelNames:
    labels = paramnames.ParamNames(args.labelNames)
else:
    labels = None

mapper = dict()
if args.map_file:
    with open(args.map_file) as f:
        for line in f:
            if line.strip():
                old, new, label = [s.strip() for s in line.split(None, 2)]
                mapper[old] = (new, label)
if args.old_new:
    for old, new in zip(args.old_new[::2], args.old_new[1::2]):
        mapper[old] = (new, None)

for jobItem in Opts.filteredBatchItems():
Esempio n. 5
0
# Just look at parameters being produced in single chain
from __future__ import absolute_import
from __future__ import print_function
import os, sys
from getdist import paramnames
import numpy as np

if len(sys.argv) < 3:
    print(
        'Usage: python/chainPeek.py chains/chainroot paramname [chain_index]')
    print('e.g. python/makeGrid.py chains/test omegabh2 1')
    sys.exit()

chain = os.path.abspath(sys.argv[1])
param = sys.argv[2]
index = 1
if len(sys.argv) > 4: index = int(sys.argv[3])

d = np.loadtxt(chain + '_' + str(index) + '.txt')
names = paramnames.ParamNames(chain + '.paramnames')

print(d[:, names.numberOfName(param) + 2])