Пример #1
0
def read_full_correlator(filename, emass=None, eamp=False, symmetric=False):
    logging.info("reading file {}".format(filename))
    cor = build_corr.corr_and_vev_from_pickle(filename, None, None)
    logging.info("File read.")

    if symmetric:
        corsym = cor.determine_symmetry()
        if corsym is None:
            logging.error("called with symmetric but correlator isnt")
            raise RuntimeError("called with symmetric but correlator isnt")
        logging.info("correlator found to be {}".format(corsym))
        cor.make_symmetric()

        cor.prune_invalid(delete=False, sigma=2.0)

    if emass:
        emasses = cor.periodic_effective_mass(1, fast=False, period=emass)
        #emasses = cor.periodic_effective_mass(1, fast=False, period=emass)
        #emasses = cor.effective_mass(1)
        times = emasses.keys()
        data = [emasses[t] for t in times]
        #errs = cor.periodic_effective_mass_errors(1, fast=False, period=emass)
        errs = cor.periodic_effective_mass_errors(1, fast=False, period=emass)
        #errs = cor.effective_mass_errors(1)
        errors = [errs[t]  for t in times]
        logging.debug("emasses {}".format(emasses))
        logging.debug("errs {}".format(errs))
    elif eamp:
        eamps = cor.periodic_effective_amp(1, len(cor.times), cor.periodic_effective_mass(1)[32] )
        times = eamps.keys()
        data = [eamps[t] for t in times]
        errors = [0  for t in times]
    else:
        times = cor.times
        data = [cor.average_sub_vev()[t] for t in times]
        errors = [cor.jackknifed_errors()[t]  for t in times]

    d = {"time": times, "correlator": data, "error": errors, "quality": [float('NaN') for t in times]}
    df = pd.DataFrame(d)
    return df
Пример #2
0
                logging.warn(".boot file exists but is empty!")
        except OSError:
            logging.info("running fit")

    consistant_argument_counts(args)

    cors = []
    for i in range(len(args.inputfile)):
        corrfile = args.inputfile[i]

        vev1 = args.vev[i]
        vev2 = vev1
        if args.vev2:
            vev2 = args.vev2[i]

        cor = build_corr.corr_and_vev_from_pickle(corrfile, vev1, vev2)

        if args.bin:
            cor = cor.reduce_to_bins(args.bin)

        corsym = cor.determine_symmetry()
        if corsym is None:
            logging.error("called with symmetric but correlator isnt")
            raise RuntimeError("called with symmetric but correlator isnt")
        logging.info("correlator found to be {}".format(corsym))
        cor.make_symmetric()
        cor.prune_invalid(delete=True, sigma=args.prune)

        if args.debug_heavycorrection:
            import heavy_correction_dicts
            beta = [b for b in ["4.17", "4.35", "4.47"] if b in args.inputfile[i]][0]
Пример #3
0
def determine_fit_range(options):
    """ get fit range """
    logging.debug("Called with {}".format(options))

    files = glob.glob("SymDW_sHtTanh_b2.0_smr3_*x{}x*b{}*0/data/*{}*{}*{}-{}*{}".format(options.period, options.beta, options.heavy, options.flavor, options.smearing1, options.smearing2, options.operator))


    if len(files) < 1:
        logging.error("no files")
        logging.error("looked for SymDW_sHtTanh_b2.0_smr3_*x{}x*b{}*0/data/*{}*{}*{}-{}*{}".format(options.period, options.beta, options.heavy, options.flavor, options.smearing1, options.smearing2, options.operator))
        exit(-1)

    logging.info(files)
    files = files
    #fhandles = [open(f) for f in files]
    maxt = (options.period/2)-1


    rel_err = {t:0 for t in range(1,options.period/2)}


    cors = [build_corr.corr_and_vev_from_pickle(f, None, None) for f in files]

    p = 1.05


    for c in cors:
        if options.operator == "PP":
            c.make_symmetric()
        elif options.operator == "A4P" or options.operator == "PA4":
            c.make_symmetric()
            maxt = (options.period/2)-4
            p = 1.20
        else:
            c.make_symmetric()

    for c in cors:
        c.prune_invalid(delete=True, sigma=2.0)
        maxt = min(maxt,max(c.times))


    for cor in cors:
        asv = cor.average_sub_vev()
        errs = cor.jackknifed_errors()
        masserrs = cor.effective_mass_errors(1)
        for t in range(4,maxt):
            rel_err[t] = max(errs[t]/asv[t], rel_err[t])
            if t > options.period/2 and masserrs[t] > masserrs[t-2]*2:
                logging.warning("Emass error doubled in two slices!")
                logging.warning("{} {} {}".format(t, masserrs[t] , masserrs[t-2]))
                maxt = min(maxt, t-2)



    maxt = maxt
    mint = -1


    for f,cor in zip(files,cors):
        emass = cor.periodic_effective_mass(1, fast=False, period=options.period)
        errs = cor.periodic_effective_mass_errors(1, fast=False, period=options.period)
        prev = emass[3]
        for t in range(4, maxt):
            if emass[t] > prev:
                logging.info("increased at {} for {}".format(t, f))
                mint = max(mint,t)
                break
            logging.debug("{}, {}, {}".format(emass[t]+errs[t]*p > emass[t-1] , emass[t-1]+errs[t-1] > emass[t-2] , emass[t]+errs[t]*p > emass[t-2]))
            logging.debug("{} {}, {} {}, {} {}".format(emass[t]+errs[t]*p , emass[t-1] , emass[t-1]+errs[t-1]*p , emass[t-2] , emass[t]+errs[t] , emass[t-2]))
            if emass[t]+errs[t]*p > emass[t-1] and emass[t-1]+errs[t-1]*p > emass[t-2] and emass[t]+errs[t]*p > emass[t-2]:
                logging.info("const at {} for {}".format(t-1, f))
                mint = max(mint,t-1)
                break

            prev = emass[t]

    if mint < 0:
        logging.error(files)
        logging.error("could not find const")
        mint = maxt-4
        #exit(-1)

    ofilename = options.ofilename

    if maxt - mint < 4:
        logging.error("found fitrange too small {},{}!!".format(mint,maxt))
        if (emass[maxt-4] - emass[maxt])/4.0 < errs[maxt-4]:
            mint = maxt-4
            logging.error("setting fit range to {},{}!!".format(mint,maxt))
        else:
            mint = maxt-4
            logging.error("setting fit range to {},{}!!".format(mint,maxt))
            #exit(-1)


    logging.info("fit range deteremined to be {} {}".format(mint,maxt))
    logging.info("writing fit range to {}".format(ofilename))

    with open(ofilename, 'w') as outfile:
        outfile.write("{} {}\n".format(mint, maxt))