print ''
        
    print '24^3 lattice'
    for scheme in 'g', 'q':
        print 'scheme', scheme
        cfac = C_S(alpha_s2, scheme)*ZAc
        Z = data_0c[0].Z_S[scheme]
        sig = data_0c[0].Z_S_sigmaJK[scheme]
        print ' 2 GeV: {0:.4f} +/- {1:.4f}'.format(cfac*Z, cfac*sig)
        cfac = C_S(alpha_s3, scheme)*ZAc
        # Small interpolation in mu required.
        d1 = data_0c[-2]
        d2 = data_0c[-1]
        #print d1.mu, d1.Z_S[scheme]
        #print d2.mu, d2.Z_S[scheme]
        fit = fits.line_fit2([(d1.mu, d1.Z_S[scheme], d1.Z_S_sigmaJK[scheme]), 
                              (d2.mu, d2.Z_S[scheme], d2.Z_S_sigmaJK[scheme])])
            
        Z = fit.b*3 + fit.a
        #print Z
        sig = max(d1.Z_S_sigmaJK[scheme], d2.Z_S_sigmaJK[scheme]) # Fudge.
        print ' 3 GeV: {0:.4f} +/- {1:.4f}'.format(cfac*Z, cfac*sig)

    print '\n\n Z_P'
    print '32^3 lattice'
    for scheme in 'g', 'q':
        print 'scheme', scheme
        cfac = C_S(alpha_s2, scheme)*ZAf
        Z = data_0f[0].Z_P[scheme]
        sig = data_0f[0].Z_P_sigmaJK[scheme]
        print ' 2 GeV: {0:.4f} +/- {1:.4f}'.format(cfac*Z, cfac*sig)
        cfac = C_S(alpha_s3, scheme)*ZAf
Example #2
0
def pole_subtract_Data2(*Dat):
    '''Remove 1/m dependence in data pts by fitting m*Zinv to a straight line.'''
    for d in Dat:
        assert isinstance(d, Data)
    Dat = list(Dat) 
    # Multiply by am and find intercept. 
    mres = Dat[0].mres  
    points = [(mres + d.m, (mres + d.m)*d.Zinv, (mres + d.m)*d.Zinv_sigmaJK)
             for d in Dat]
    fit = line_fit2(points)
    for d in Dat:
        d.polefit_params = fit  # Save these parameters.
        d.Zinv_sub = d.Zinv - fit.a/(d.m + mres)
        d.Zinv_sub_sigma = sqrt(d.Zinv_sigmaJK**2)# + (fit.sig_a/(d.m+mres))**2)
        
    # Jackknife values.
    # This proceeds in a few steps. First we calculate the fit parameter 'a'
    # many times by removing individual configs.  Then we enlarge the
    # "jackknife space" of each data point to include the effect on the 
    # subtracted value coming from the other mass points.
    
    aJK = []
    for dummy in range(len(Dat)):
        d, ds = Dat[0], Dat[1:]  # Split off first element.
        d.Zinv_subJK = []
        for jk in d.Zinv_JK:
            # We do not recompute d.Zinv_sigmaJK which would require some
            # insane double jackknife.
            points = [(mres + x.m, (mres + x.m)*x.Zinv, 
                     (mres + x.m)*x.Zinv_sigmaJK) for x in ds] +\
                     [(mres + d.m, (mres + d.m)*jk, (mres + d.m)*d.Zinv_sigmaJK)]
            fit = line_fit2(points)
            aJK += [fit.a]
        ds.append(d) # Return element to end.
        Dat = ds
    
    # Initialize Zinv_subJK.  The central value d.Zinv is used when considering
    # the effect from other mass points.  In the following loop we correct
    # the values in the same mass point.
    
    ct = 0
    Zinv_subJK = []
    for d in Dat:
        d.Zinv_JKexpand = [d.Zinv]*len(aJK)  #  Init. expanded 'regular' JK.
        for x in range(len(d.Zinv_JK)):
            Zinv_subJK += [d.Zinv - aJK[ct]/(mres+d.m)]
            d.Zinv_JKexpand[ct] = d.Zinv_JK[x]  # Fill JK values in correct spots.
            ct +=1           
    assert ct == len(aJK)
    
    ct = 0
    for dummy in range(len(Dat)):
        d, ds = Dat[0], Dat[1:]
        d.Zinv_subJK = Zinv_subJK  # Initialize.
        for jk in d.Zinv_JK:
            d.Zinv_subJK[ct] = jk - aJK[ct]/(mres+d.m)  # Corrects wrong values.
            ct += 1
        d.Zinv_sub_sigma2 = JKsigma(d.Zinv_subJK, d.Zinv_sub)
        ds.append(d)
        Dat = ds
    assert ct == len(aJK)