def refinePeaks(peaks,ibrav,A,ifX20=True): 'needs a doc string' dmin = getDmin(peaks) smin = 1.0e10 pwr = 8 maxTries = 10 OK = False tries = 0 sgtype = G2lat.make_sgtype(ibrav) HKL = G2lat.GenHBravais(dmin,ibrav,A, sg_type=sgtype) while len(HKL) > 2 and IndexPeaks(peaks,HKL)[0]: Pwr = pwr - (tries % 2) HKL = [] tries += 1 osmin = smin oldA = A[:] Vold = G2lat.calc_V(oldA) OK,smin,A,result = FitHKL(ibrav,peaks,A,Pwr) Vnew = G2lat.calc_V(A) if Vnew > 2.0*Vold or Vnew < 2.: A = ranAbyR(ibrav,oldA,tries+1,maxTries,ran2axis) OK = False continue try: HKL = G2lat.GenHBravais(dmin,ibrav,A, sgtype) except FloatingPointError: A = oldA OK = False break if len(HKL) == 0: break #absurd cell obtained! rat = (osmin-smin)/smin if abs(rat) < 1.0e-5 or not OK: break if tries > maxTries: break if OK: OK,smin,A,result = FitHKL(ibrav,peaks,A,2) Peaks = np.array(peaks).T H = Peaks[4:7] try: Peaks[8] = 1./np.sqrt(G2lat.calc_rDsq(H,A)) peaks = Peaks.T except FloatingPointError: A = oldA M20,X20 = calc_M20(peaks,HKL,ifX20) return len(HKL),M20,X20,A
def refinePeaks(peaks,ibrav,A,ifX20=True): 'needs a doc string' dmin = getDmin(peaks) smin = 1.0e10 pwr = 8 maxTries = 10 OK = False tries = 0 HKL = G2lat.GenHBravais(dmin,ibrav,A) while len(HKL) > 2 and IndexPeaks(peaks,HKL)[0]: Pwr = pwr - (tries % 2) HKL = [] tries += 1 osmin = smin oldA = A[:] Vold = G2lat.calc_V(oldA) OK,smin,A,result = FitHKL(ibrav,peaks,A,Pwr) Vnew = G2lat.calc_V(A) if Vnew > 2.0*Vold or Vnew < 2.: A = ranAbyR(ibrav,oldA,tries+1,maxTries,ran2axis) OK = False continue try: HKL = G2lat.GenHBravais(dmin,ibrav,A) except FloatingPointError: A = oldA OK = False break if len(HKL) == 0: break #absurd cell obtained! rat = (osmin-smin)/smin if abs(rat) < 1.0e-5 or not OK: break if tries > maxTries: break if OK: OK,smin,A,result = FitHKL(ibrav,peaks,A,2) Peaks = np.array(peaks).T H = Peaks[4:7] try: Peaks[8] = 1./np.sqrt(G2lat.calc_rDsq(H,A)) peaks = Peaks.T except FloatingPointError: A = oldA M20,X20 = calc_M20(peaks,HKL,ifX20) return len(HKL),M20,X20,A
def errFit(values,ibrav,d,H,Pwr): A = Values2A(ibrav,values) Qo = 1./d**2 Qc = G2lat.calc_rDsq(H,A) return (Qo-Qc)*d**Pwr
def errFit(values,ibrav,d,H,Pwr): A = Values2A(ibrav,values) Qo = 1./d**2 Qc = G2lat.calc_rDsq(H,A) return (Qo-Qc)*d**Pwr