Changeset 738 for trunk/GSASIIphsGUI.py


Ignore:
Timestamp:
Aug 26, 2012 12:54:17 PM (11 years ago)
Author:
vondreele
Message:

put wx.BusyCursor? in various places

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r736 r738  
    20752075            SGData = generalData['SGData']
    20762076            cellArray = G2lat.CellBlock(1)
    2077             for ind in indx:
    2078                 atomA = atomData[ind]
    2079                 xyzA = np.array(atomA[cx:cx+3])
    2080                 indA = atomTypes.index(atomA[ct])
    2081                 for atomB in atomData[:numAtoms]:
    2082                     indB = atomTypes.index(atomB[ct])
    2083                     sumR = radii[indA]+radii[indB]
    2084                     xyzB = np.array(atomB[cx:cx+3])
    2085                     for xyz in cellArray+xyzB:
    2086                         dist = np.sqrt(np.sum(np.inner(Amat,xyz-xyzA)**2))
    2087                         if 0 < dist <= data['Drawing']['radiusFactor']*sumR:
    2088                             if noDuplicate(xyz,atomData):
    2089                                 oprB = atomB[cx+3]
    2090                                 C = xyz-xyzB
    2091                                 newOp = '1+'+str(int(round(C[0])))+','+str(int(round(C[1])))+','+str(int(round(C[2])))
    2092                                 newAtom = atomB[:]
    2093                                 newAtom[cx:cx+3] = xyz
    2094                                 newAtom[cx+3] = G2spc.StringOpsProd(oprB,newOp,SGData)
    2095                                 atomData.append(newAtom)
     2077            wx.BeginBusyCursor()
     2078            try:
     2079                for ind in indx:
     2080                    atomA = atomData[ind]
     2081                    xyzA = np.array(atomA[cx:cx+3])
     2082                    indA = atomTypes.index(atomA[ct])
     2083                    for atomB in atomData[:numAtoms]:
     2084                        indB = atomTypes.index(atomB[ct])
     2085                        sumR = radii[indA]+radii[indB]
     2086                        xyzB = np.array(atomB[cx:cx+3])
     2087                        for xyz in cellArray+xyzB:
     2088                            dist = np.sqrt(np.sum(np.inner(Amat,xyz-xyzA)**2))
     2089                            if 0 < dist <= data['Drawing']['radiusFactor']*sumR:
     2090                                if noDuplicate(xyz,atomData):
     2091                                    oprB = atomB[cx+3]
     2092                                    C = xyz-xyzB
     2093                                    newOp = '1+'+str(int(round(C[0])))+','+str(int(round(C[1])))+','+str(int(round(C[2])))
     2094                                    newAtom = atomB[:]
     2095                                    newAtom[cx:cx+3] = xyz
     2096                                    newAtom[cx+3] = G2spc.StringOpsProd(oprB,newOp,SGData)
     2097                                    atomData.append(newAtom)
     2098            finally:
     2099                wx.EndBusyCursor()
    20962100            data['Drawing']['Atoms'] = atomData
    20972101            UpdateDrawAtoms()
     
    21102114            generalData = data['General']
    21112115            SGData = generalData['SGData']
    2112             for ind in indx:
    2113                 atom = atomData[ind]
    2114                 XYZ = np.array(atom[cx:cx+3])
    2115                 if atom[cuia] == 'A':
    2116                     Uij = atom[cuij:cuij+6]
    2117                     result = G2spc.GenAtom(XYZ,SGData,False,Uij,False)
    2118                     for item in result:
    2119                         atom = copy.copy(atomData[ind])
    2120                         atom[cx:cx+3] = item[0]
    2121                         atom[cx+3] = str(item[2])+'+' \
    2122                             +str(item[3][0])+','+str(item[3][1])+','+str(item[3][2])
    2123                         atom[cuij:cuij+6] = item[1]
    2124                         Opp = G2spc.Opposite(item[0])
    2125                         for xyz in Opp:
    2126                             if noDuplicate(xyz,atomData):
    2127                                 cell = np.asarray(np.rint(xyz-atom[cx:cx+3]),dtype=np.int32)
    2128                                 cell = '1'+'+'+ \
    2129                                     str(cell[0])+','+str(cell[1])+','+str(cell[2])
    2130                                 atom[cx:cx+3] = xyz
    2131                                 atom[cx+3] = G2spc.StringOpsProd(cell,atom[cx+3],SGData)
    2132                                 atomData.append(atom[:])
    2133                 else:
    2134                     result = G2spc.GenAtom(XYZ,SGData,False,Move=False)
    2135                     for item in result:
    2136                         atom = copy.copy(atomData[ind])
    2137                         atom[cx:cx+3] = item[0]
    2138                         atom[cx+3] = str(item[1])+'+' \
    2139                             +str(item[2][0])+','+str(item[2][1])+','+str(item[2][2])
    2140                         Opp = G2spc.Opposite(item[0])
    2141                         for xyz in Opp:
    2142                             if noDuplicate(xyz,atomData):
    2143                                 cell = np.asarray(np.rint(xyz-atom[cx:cx+3]),dtype=np.int32)
    2144                                 cell = '1'+'+'+ \
    2145                                     str(cell[0])+','+str(cell[1])+','+str(cell[2])
    2146                                 atom[cx:cx+3] = xyz
    2147                                 atom[cx+3] = G2spc.StringOpsProd(cell,atom[cx+3],SGData)
    2148                                 atomData.append(atom[:])               
    2149                 data['Drawing']['Atoms'] = atomData
     2116            wx.BeginBusyCursor()
     2117            try:
     2118                for ind in indx:
     2119                    atom = atomData[ind]
     2120                    XYZ = np.array(atom[cx:cx+3])
     2121                    if atom[cuia] == 'A':
     2122                        Uij = atom[cuij:cuij+6]
     2123                        result = G2spc.GenAtom(XYZ,SGData,False,Uij,False)
     2124                        for item in result:
     2125                            atom = copy.copy(atomData[ind])
     2126                            atom[cx:cx+3] = item[0]
     2127                            atom[cx+3] = str(item[2])+'+' \
     2128                                +str(item[3][0])+','+str(item[3][1])+','+str(item[3][2])
     2129                            atom[cuij:cuij+6] = item[1]
     2130                            Opp = G2spc.Opposite(item[0])
     2131                            for xyz in Opp:
     2132                                if noDuplicate(xyz,atomData):
     2133                                    cell = np.asarray(np.rint(xyz-atom[cx:cx+3]),dtype=np.int32)
     2134                                    cell = '1'+'+'+ \
     2135                                        str(cell[0])+','+str(cell[1])+','+str(cell[2])
     2136                                    atom[cx:cx+3] = xyz
     2137                                    atom[cx+3] = G2spc.StringOpsProd(cell,atom[cx+3],SGData)
     2138                                    atomData.append(atom[:])
     2139                    else:
     2140                        result = G2spc.GenAtom(XYZ,SGData,False,Move=False)
     2141                        for item in result:
     2142                            atom = copy.copy(atomData[ind])
     2143                            atom[cx:cx+3] = item[0]
     2144                            atom[cx+3] = str(item[1])+'+' \
     2145                                +str(item[2][0])+','+str(item[2][1])+','+str(item[2][2])
     2146                            Opp = G2spc.Opposite(item[0])
     2147                            for xyz in Opp:
     2148                                if noDuplicate(xyz,atomData):
     2149                                    cell = np.asarray(np.rint(xyz-atom[cx:cx+3]),dtype=np.int32)
     2150                                    cell = '1'+'+'+ \
     2151                                        str(cell[0])+','+str(cell[1])+','+str(cell[2])
     2152                                    atom[cx:cx+3] = xyz
     2153                                    atom[cx+3] = G2spc.StringOpsProd(cell,atom[cx+3],SGData)
     2154                                    atomData.append(atom[:])               
     2155                    data['Drawing']['Atoms'] = atomData
     2156            finally:
     2157                wx.EndBusyCursor()
    21502158            UpdateDrawAtoms()
    21512159            drawAtoms.ClearSelection()
     
    38223830        const = 9.e-2/(np.pi*Sample['Gonio. radius'])                  #shifts in microns
    38233831       
    3824         for ref in Refs:
    3825             pos = 2.0*asind(wave/(2.0*ref[4]))
    3826             if 'Bragg' in Sample['Type']:
    3827                 pos -= const*(4.*Sample['Shift'][0]*cosd(pos/2.0)+ \
    3828                     Sample['Transparency'][0]*sind(pos)*100.0)            #trans(=1/mueff) in cm
    3829             else:               #Debye-Scherrer - simple but maybe not right
    3830                 pos -= const*(Sample['DisplaceX'][0]*cosd(pos)+Sample['DisplaceY'][0]*sind(pos))
    3831             indx = np.searchsorted(xdata[0],pos)
    3832             try:
    3833                 FWHM = max(0.001,G2pwd.getFWHM(pos,Inst))/2.
    3834                 dx = xdata[0][indx+1]-xdata[0][indx]
    3835                 ref[6] = FWHM*xdata[1][indx]/dx
    3836                 Lorenz = 1./(2.*sind(xdata[0][indx]/2.)**2*cosd(xdata[0][indx]/2.))           #Lorentz correction
    3837                 pola,dIdPola = G2pwd.Polarization(Inst['Polariz.'],xdata[0][indx],Inst['Azimuth'])
    3838                 ref[6] /= (Lorenz*pola*ref[3])
    3839             except IndexError:
    3840                 pass
     3832        wx.BeginBusyCursor()
     3833        try:
     3834            for ref in Refs:
     3835                pos = 2.0*asind(wave/(2.0*ref[4]))
     3836                if 'Bragg' in Sample['Type']:
     3837                    pos -= const*(4.*Sample['Shift'][0]*cosd(pos/2.0)+ \
     3838                        Sample['Transparency'][0]*sind(pos)*100.0)            #trans(=1/mueff) in cm
     3839                else:               #Debye-Scherrer - simple but maybe not right
     3840                    pos -= const*(Sample['DisplaceX'][0]*cosd(pos)+Sample['DisplaceY'][0]*sind(pos))
     3841                indx = np.searchsorted(xdata[0],pos)
     3842                try:
     3843                    FWHM = max(0.001,G2pwd.getFWHM(pos,Inst))/2.
     3844                    dx = xdata[0][indx+1]-xdata[0][indx]
     3845                    ref[6] = FWHM*xdata[1][indx]/dx
     3846                    Lorenz = 1./(2.*sind(xdata[0][indx]/2.)**2*cosd(xdata[0][indx]/2.))           #Lorentz correction
     3847                    pola,dIdPola = G2pwd.Polarization(Inst['Polariz.'],xdata[0][indx],Inst['Azimuth'])
     3848                    ref[6] /= (Lorenz*pola*ref[3])
     3849                except IndexError:
     3850                    pass
     3851        finally:
     3852            wx.EndBusyCursor()
    38413853        FillPawleyReflectionsGrid()
    38423854
     
    38513863        PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistoNames[0])
    38523864        refData = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))[PhaseName]
    3853         for iref,ref in enumerate(Refs):
    3854             try:
    3855                 ref[6] = abs(refData[iref][9])
    3856                 ref[7] = 1.0
    3857             except IndexError:
    3858                 pass
     3865        wx.BeginBusyCursor()
     3866        try:
     3867            for iref,ref in enumerate(Refs):
     3868                try:
     3869                    ref[6] = abs(refData[iref][9])
     3870                    ref[7] = 1.0
     3871                except IndexError:
     3872                    pass
     3873        finally:
     3874            wx.EndBusyCursor()
    38593875        FillPawleyReflectionsGrid()
    38603876                           
     
    39583974            Ind = MapPeaks.GetSelectedRows()
    39593975            if Ind:
    3960                 Ind = G2mth.PeaksUnique(data,Ind)
    3961                 for r in range(MapPeaks.GetNumberRows()):
    3962                     if r in Ind:
    3963                         MapPeaks.SelectRow(r,addToSelected=True)
    3964                     else:
    3965                         MapPeaks.DeselectRow(r)
     3976                wx.BeginBusyCursor()
     3977                try:
     3978                    Ind = G2mth.PeaksUnique(data,Ind)
     3979                    for r in range(MapPeaks.GetNumberRows()):
     3980                        if r in Ind:
     3981                            MapPeaks.SelectRow(r,addToSelected=True)
     3982                        else:
     3983                            MapPeaks.DeselectRow(r)
     3984                finally:
     3985                    wx.EndBusyCursor()
    39663986                G2plt.PlotStructure(G2frame,data)
    39673987   
Note: See TracChangeset for help on using the changeset viewer.