Changeset 2117 for trunk/GSASIIindex.py


Ignore:
Timestamp:
Jan 8, 2016 12:03:26 PM (7 years ago)
Author:
vondreele
Message:

refactor powder indexing to remove wx from G2index
change indexing progress bar to allow Skip of current Bravais search
Also only makes one Progress Bar Dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIindex.py

    r2111 r2117  
    1414
    1515Cell indexing program: variation on that of A. Coehlo
    16 includes cell refinement from peak positions (not zero as yet)
    17 
    18 This needs a bit of refactoring to remove the little bit of GUI
    19 code referencing wx
     16includes cell refinement from peak positions
    2017'''
    2118
    2219import math
    23 import wx
    2420import time
    2521import numpy as np
     
    775771    Asave = []
    776772    GoOn = True
     773    Skip = False
    777774    if A:
    778775        HKL = G2lat.GenHBravais(dmin,ibrav,A[:])
     
    781778            Asave.append([calc_M20(peaks,HKL,ifX20),A[:]])
    782779    tries = 0
    783     while tries < Ntries:
     780    while tries < Ntries and GoOn:
    784781        if A:
    785782            Abeg = ranAbyR(ibrav,A,tries+1,Ntries,ran2axis)
     
    789786            Abeg = ranAbyV(ibrav,amin,amax,V1)
    790787        HKL = G2lat.GenHBravais(dmin,ibrav,Abeg)
     788        Nc = len(HKL)
     789        if Nc >= ncMax:
     790            GoOn = False
     791        else:
     792            if dlg:
     793                GoOn,Skip = dlg.Update(100*Nc/ncMax)
     794                if Skip or not GoOn:
     795                    GoOn = False
     796                    break
    791797       
    792798        if IndexPeaks(peaks,HKL)[0] and len(HKL) > mHKL[ibrav]:
     
    809815            break
    810816        Nc = len(HKL)
    811         if Nc >= ncMax:
    812             GoOn = False
    813         elif dlg:
    814             GoOn = dlg.Update(Nc)[0]
    815             if not GoOn:
    816                 break
    817817        tries += 1
    818818    X = sortM20(Asave)
    819819    if X:
    820820        Lhkl,M20,X20,A = refinePeaks(peaks,ibrav,X[0][1],ifX20)
    821         return GoOn,Lhkl,M20,X20,A
    822        
    823     else:
    824         return GoOn,0,0,0,0
     821        return GoOn,Skip,Lhkl,M20,X20,A       
     822    else:
     823        return GoOn,Skip,0,0,0,0
    825824       
    826825def monoCellReduce(ibrav,A):
     
    846845    return A
    847846
    848 def DoIndexPeaks(peaks,controls,bravais,ifX20=True):
     847def DoIndexPeaks(peaks,controls,bravais,dlg,ifX20=True):
    849848    'needs a doc string'
    850849   
     
    881880            cycle = 0
    882881            while cycle < 5:
    883                 dlg = wx.ProgressDialog("Generated reflections",tries[cycle]+" cell search for "+bravaisNames[ibrav],ncMax,
    884                     style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_REMAINING_TIME|wx.PD_CAN_ABORT)
    885                 screenSize = wx.ClientDisplayRect()
    886                 Size = dlg.GetSize()
    887                 dlg.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
     882                dlg.Update(0,newmsg=tries[cycle]+" cell search for "+bravaisNames[ibrav])
    888883                try:
    889884                    GoOn = True
     
    894889                                if not N2:
    895890                                    A = []
    896                                     GoOn,Nc,M20,X20,A = findBestCell(dlg,ncMax,A,Nm[ibrav]*N1s[ibrav],ibrav,peaks,V1,ifX20)
     891                                    GoOn,Skip,Nc,M20,X20,A = findBestCell(dlg,ncMax,A,Nm[ibrav]*N1s[ibrav],ibrav,peaks,V1,ifX20)
     892                                    if Skip:
     893                                        break
    897894                                if A:
    898                                     GoOn,Nc,M20,X20,A = findBestCell(dlg,ncMax,A[:],N1s[ibrav],ibrav,peaks,0,ifX20)
     895                                    GoOn,Skip,Nc,M20,X20,A = findBestCell(dlg,ncMax,A[:],N1s[ibrav],ibrav,peaks,0,ifX20)
    899896                            else:
    900                                 GoOn,Nc,M20,X20,A = findBestCell(dlg,ncMax,0,Nm[ibrav]*N1s[ibrav],ibrav,peaks,V1,ifX20)
    901                             if Nc >= ncMax:
     897                                GoOn,Skip,Nc,M20,X20,A = findBestCell(dlg,ncMax,0,Nm[ibrav]*N1s[ibrav],ibrav,peaks,V1,ifX20)
     898                            if Skip:
     899                                break
     900                            elif Nc >= ncMax:
    902901                                GoOn = False
    903902                                break
     
    928927                                break
    929928                            N2 += 1
     929                        if Skip:
     930                            cycle = 10
     931                            GoOn = False
     932                            break
    930933                        if ibrav < 11:
    931934                            V1 *= 1.1
     
    946949                finally:
    947950                    pass
    948                 dlg.Destroy()
     951#                dlg.Destroy()
    949952            print '%s%s%s%s'%('finished cell search for ',bravaisNames[ibrav], \
    950953                ', elapsed time = ',G2lat.sec2HMS(time.time()-begin))
Note: See TracChangeset for help on using the changeset viewer.