traind = None
if class_name in class_options:
    traind = class_options[class_name]
elif not recover and not testdatafor:
    print('available classes:')
    for key, val in class_options.iteritems():
        print(key)
    raise Exception('wrong class selection')

if recover:
    dc.recoverCreateDataFromRootFromSnapshot(recover)
elif args.means:
    dc.convertListOfRootFiles(infile,
                              traind,
                              outPath,
                              means_only=True,
                              output_name='batch_template.djcdc',
                              relpath=relpath)
else:
    logging.info('Start conversion')
    dc.convertListOfRootFiles(
        infile,
        traind,
        outPath,
        takeweightersfrom=usemeansfrom,
        output_name=(args.batch if args.batch else 'dataCollection.djcdc'),
        relpath=relpath)

if args.inRange is not None:
    os.unlink(infile)
    traind = class_options[class_name]
elif not recover and not testdatafor:
    print('available classes:')
    for key, val in class_options.iteritems():
        print(key)
    raise Exception('wrong class selection')
if testdatafor:
    logging.info('converting test data, no weights applied')
    dc.createTestDataForDataCollection(
        testdatafor,
        infile,
        outPath,
        outname=args.batch if args.batch else 'dataCollection.dc',
        batch_mode=bool(args.batch))
elif recover:
    dc.recoverCreateDataFromRootFromSnapshot(recover)
elif args.means:
    dc.convertListOfRootFiles(infile,
                              traind(),
                              outPath,
                              means_only=True,
                              output_name='batch_template.dc')
else:
    dc.convertListOfRootFiles(
        infile,
        traind(),
        outPath,
        usemeansfrom,
        output_name=args.batch if args.batch else 'dataCollection.dc',
        batch_mode=bool(args.batch))
Exemple #3
0
    try:
        cls = class_options[args.c]
    except KeyError:
        raise Exception('wrong class selection')

    if not args.classArgs:
        args.classArgs = tuple()

    dc = DataCollection(nprocs=-1)
    dc.meansnormslimit = int(args.nforweighter)
    try:
        dc.convertListOfRootFiles(
            args.infile,
            cls(*args.classArgs),
            args.out,
            means_only=True,
            output_name='batch_template.dc',
            relpath=('' if args.noRelativePaths else os.path.dirname(
                os.path.realpath(args.infile))))

    except:
        print 'The first round of root conversion failed'
        raise

    print('means/norms/weighter produced successfully')

elif args.meansfrom:
    if not os.path.exists(args.meansfrom):
        raise Exception("The file " + args.meansfrom + " does not exist")
    print('using means/weighter from ' + args.meansfrom)
    os.mkdir(args.out)
if testdatafor:
    logging.info('converting test data, no weights applied')
    dc.createTestDataForDataCollection(
        testdatafor,
        infile,
        outPath,
        outname=(args.batch if args.batch else 'dataCollection.dc'),
        traind=(traind(class_args) if traind else None),
        relpath=relpath)
elif recover:
    dc.recoverCreateDataFromRootFromSnapshot(recover)
elif args.means:
    dc.convertListOfRootFiles(infile,
                              traind(class_args) if class_args else traind(),
                              outPath,
                              means_only=True,
                              output_name='batch_template.dc',
                              relpath=relpath)
else:
    logging.info('Start conversion')
    dc.convertListOfRootFiles(
        infile,
        traind(class_args) if class_args else traind(),
        outPath,
        takemeansfrom=usemeansfrom,
        output_name=(args.batch if args.batch else 'dataCollection.dc'),
        relpath=relpath)

if args.inRange is not None:
    os.unlink(infile)