Example #1
0
    for itrial in xrange(1,args.ntrials+1):
        results = {} # one trial of results

        tprofile.info("start trial %d"%itrial)
        logging.info(">"*10 + "Running trial: %05d"%itrial + "<"*10)

        results['seed'] = get_seed()
        logging.info("  RNG seed: %ld"%results['seed'])
        fmap = get_random_map(alt_mh_expectation, seed=results['seed'])

        for hypo_tag, hypo_normal in [('hypo_NMH',True),('hypo_IMH',False)]:

            physics.info(
                "Finding best fit for %s under %s assumption"%(data_tag,hypo_tag))
            with Timer() as t:
                llh_data = find_opt_bfgs(
                    fmap, template_maker, template_settings['params'],
                    minimizer_settings, args.save_steps,
                    normal_hierarchy=hypo_normal, check_octant=check_octant)
            tprofile.info("==> elapsed time for optimizer: %s sec"%t.secs)

            # Store the LLH data
            results[hypo_tag] = llh_data

        trials += [results]
        tprofile.info("stop trial %d"%itrial)

    output[data_tag]['trials'] = trials

to_json(output,args.outfile)
Example #2
0
    results[data_tag] = {}
    # 1) get "Asimov" average fiducial template:
    asimov_fmap = get_asimov_fmap(pseudo_data_template_maker,
                                  get_values(select_hierarchy(pseudo_data_settings['params'],
                                                              normal_hierarchy=data_normal)),
                                  channel=channel)

    # 2) find max llh or min chisquare (and best fit free params) from matching pseudo data
    #    to templates.
    for hypo_tag, hypo_normal in [('hypo_NMH',True),('hypo_IMH',False)]:
        physics.info("Finding best fit for %s under %s assumption"%(data_tag,hypo_tag))
	tprofile.info("start optimizer")
	tprofile.info("Using %s"%metric_name)

	opt_data = find_opt_bfgs(asimov_fmap,template_maker,template_settings['params'],
				 minimizer_settings,args.save_steps,
				 normal_hierarchy=hypo_normal, check_octant=args.check_octant,
				 metric_name=metric_name)

	tprofile.info("stop optimizer")

	# Store the optimum data
	results[data_tag][hypo_tag] = opt_data

# Assemble output dict
output = {'results' : results,
          'template_settings' : template_settings,
          'minimizer_settings' : minimizer_settings}

if args.pseudo_data_settings is not None:
    output['pseudo_data_settings'] = pseudo_data_settings
Example #3
0
                                          pseudo_data_settings['params'],
                                          normal_hierarchy=data_normal)),
                                  channel=channel)

    # 2) find max llh or min chisquare (and best fit free params) from matching pseudo data
    #    to templates.
    for hypo_tag, hypo_normal in [('hypo_NMH', True), ('hypo_IMH', False)]:
        physics.info("Finding best fit for %s under %s assumption" %
                     (data_tag, hypo_tag))
        tprofile.info("start optimizer")
        tprofile.info("Using %s" % metric_name)

        opt_data = find_opt_bfgs(asimov_fmap,
                                 template_maker,
                                 template_settings['params'],
                                 minimizer_settings,
                                 args.save_steps,
                                 normal_hierarchy=hypo_normal,
                                 check_octant=args.check_octant,
                                 metric_name=metric_name)

        tprofile.info("stop optimizer")

        # Store the optimum data
        results[data_tag][hypo_tag] = opt_data

# Assemble output dict
output = {
    'results': results,
    'template_settings': template_settings,
    'minimizer_settings': minimizer_settings
}
Example #4
0
        results = {} # one trial of results

        tprofile.info("start trial %d"%itrial)
        logging.info(">"*10 + "Running trial: %05d"%itrial + "<"*10)

        results['seed'] = get_seed()
        logging.info("  RNG seed: %ld"%results['seed'])
        # Get random map generated from asimov data (or from data_tag).
        fmap = get_random_map(asimov_data, seed=results['seed'])

        for hypo_tag, hypo_normal in [('hypo_NMH',True),('hypo_IMH',False)]:

            physics.info(
                "Finding best fit for %s under %s assumption"%(data_tag,hypo_tag))
            with Timer() as t:
                llh_data = find_opt_bfgs(
                    fmap, template_maker, template_settings['params'],
                    minimizer_settings, args.save_steps,
                    normal_hierarchy=hypo_normal, check_octant=check_octant)
            tprofile.info("==> elapsed time for optimizer: %s sec"%t.secs)

            # Store the LLH data
            results[hypo_tag] = llh_data

        trials += [results]
        tprofile.info("stop trial %d"%itrial)

    output[data_tag]['trials'] = trials

to_json(output,args.outfile)
Example #5
0
print "atm_params: ", atm_params

# Prepare to store all the steps
steps = {key: [] for key in atm_params.keys()}
steps['llh'] = []

# Iterate over the cartesian product, and set fixed parameter to value
for pos in product(*steplist):
    pos_dict = dict(list(pos))
    print "Running at params-pos dict: ", pos_dict
    for k, v in pos_dict.items():
        hypo_params[k]['value'] = v
        steps[k].append(v)

    with Timer() as t:
        llh_data = find_opt_bfgs(asimov_data_set,
                                 template_maker,
                                 hypo_params,
                                 minimizer_settings,
                                 args.save_steps,
                                 normal_hierarchy=hypo_normal)
    tprofile.info("==> elapsed time for optimizer: %s sec" % t.secs)

    steps['llh'].append(llh_data['llh'][-1])

    #Store the LLH data
    results[data_tag][hypo_tag] = steps

logging.warn("FINISHED. Saving to file: %s" % args.outfile)
to_json(results, args.outfile)
Example #6
0
             for name, param in sorted(atm_params.items())]

print "steplist: ",steplist
print "atm_params: ",atm_params

# Prepare to store all the steps
steps = {key:[] for key in atm_params.keys()}
steps['llh'] = []

# Iterate over the cartesian product, and set fixed parameter to value
for pos in product(*steplist):
    pos_dict = dict(list(pos))
    print "Running at params-pos dict: ",pos_dict
    for k,v in pos_dict.items():
        hypo_params[k]['value'] = v
        steps[k].append(v)

    with Timer() as t:
        llh_data = find_opt_bfgs(asimov_data_set,template_maker,hypo_params,
                                 minimizer_settings,args.save_steps,
                                 normal_hierarchy=hypo_normal)
    tprofile.info("==> elapsed time for optimizer: %s sec"%t.secs)

    steps['llh'].append(llh_data['llh'][-1])

    #Store the LLH data
    results[data_tag][hypo_tag] = steps

logging.warn("FINISHED. Saving to file: %s"%args.outfile)
to_json(results,args.outfile)