Changeset 4838 for trunk


Ignore:
Timestamp:
Mar 3, 2021 6:17:59 PM (2 years ago)
Author:
vondreele
Message:

comment out MakeDrawAtom? in G2constrGUI & make the call to G2mth.MakeDrawAtom? which does same thing
move MakeDrawAtom? & DrawAtomsReplaeyID from G2phsGUI to G2mth & fix all references to them in G2phsGUI

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIconstrGUI.py

    r4823 r4838  
    260260            self.onChange()
    261261
    262 def MakeDrawAtom(data,atom):
    263     'Convert atom to format needed to draw it'
    264     generalData = data['General']
    265     deftype = G2obj.validateAtomDrawType(
    266         GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
    267     if generalData['Type'] in ['nuclear','faulted',]:
    268         atomInfo = [atom[:2]+atom[3:6]+['1']+[deftype]+
    269                     ['']+[[255,255,255]]+atom[9:]+[[],[]]][0]
    270     ct,cs = [1,8]         #type & color
    271     atNum = generalData['AtomTypes'].index(atom[ct])
    272     atomInfo[cs] = list(generalData['Color'][atNum])
    273     return atomInfo
     262# def MakeDrawAtom(data,atom):
     263#     'Convert atom to format needed to draw it'
     264#     generalData = data['General']
     265#     deftype = G2obj.validateAtomDrawType(
     266#         GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
     267#     if generalData['Type'] in ['nuclear','faulted',]:
     268#         atomInfo = [atom[:2]+atom[3:6]+['1']+[deftype]+
     269#                     ['']+[[255,255,255]]+atom[9:]+[[],[]]][0]
     270#     ct,cs = [1,8]         #type & color
     271#     atNum = generalData['AtomTypes'].index(atom[ct])
     272#     atomInfo[cs] = list(generalData['Color'][atNum])
     273#     return atomInfo
    274274
    275275class ConstraintDialog(wx.Dialog):
     
    20612061            atmData['Drawing']['Atoms'] = []
    20622062            for atom in atmData['Atoms']:
    2063                 atmData['Drawing']['Atoms'].append(MakeDrawAtom(atmData,atom))
     2063                atmData['Drawing']['Atoms'].append(G2mth.MakeDrawAtom(atmData,atom))
    20642064
    20652065        def onCancel(event,page=0):
  • trunk/GSASIImath.py

    r4830 r4838  
    2929import GSASIIspc as G2spc
    3030import GSASIIpwd as G2pwd
     31import GSASIIobj as G2obj
    3132import GSASIIfiles as G2fil
    3233import numpy.fft as fft
     
    698699    return {atom[indx]:iatm for iatm,atom in enumerate(atomData)}
    699700
     701def DrawAtomsReplaceByID(data,loc,atom,ID):
     702    '''Replace all atoms in drawing array with an ID matching the specified value'''
     703    atomData = data['Drawing']['Atoms']
     704    indx = FindAtomIndexByIDs(atomData,loc,[ID,])
     705    for ind in indx:
     706        atomData[ind] = MakeDrawAtom(data,atom,atomData[ind])
     707
     708def MakeDrawAtom(data,atom,oldatom=None):
     709    'needs a description'
     710    AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
     711        'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK']
     712    AA1letter = ['A','R','N','D','C','Q','E','G','H','I',
     713        'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' ']
     714    generalData = data['General']
     715    Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     716    SGData = generalData['SGData']
     717    deftype = G2obj.validateAtomDrawType(GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
     718    if generalData['Type'] in ['nuclear','faulted',]:
     719        if oldatom:
     720            opr = oldatom[5]
     721            if atom[9] == 'A':                   
     722                X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17])
     723                atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0]
     724            else:
     725                X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])
     726                atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0]
     727        else:
     728            atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+
     729                ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0]
     730        ct,cs = [1,8]         #type & color
     731    elif  generalData['Type'] == 'magnetic':
     732        if oldatom:
     733            opr = oldatom[8]
     734            mom = np.array(atom[7:10])
     735            if generalData['Super']:
     736                SSGData = generalData['SSGData']
     737                Mom = G2spc.ApplyStringOpsMom(opr,SGData,SSGData,mom)
     738            else:
     739                Mom = G2spc.ApplyStringOpsMom(opr,SGData,None,mom)
     740            if atom[12] == 'A':                   
     741                X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[14:20])
     742                atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:14]+list(U)+oldatom[20:]][0]
     743            else:
     744                X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])
     745                atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0]
     746        else:
     747            atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+
     748                ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
     749        ct,cs = [1,11]         #type & color
     750    elif generalData['Type'] == 'macromolecular':
     751        try:
     752            oneLetter = AA3letter.index(atom[1])
     753        except ValueError:
     754            oneLetter = -1
     755        atomInfo = [[atom[1].strip()+atom[0],]+
     756            [AA1letter[oneLetter]+atom[0],]+atom[2:5]+
     757            atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
     758        ct,cs = [4,11]         #type & color
     759    atNum = generalData['AtomTypes'].index(atom[ct])
     760    atomInfo[cs] = list(generalData['Color'][atNum])
     761    return atomInfo
     762   
    700763def GetAtomsById(atomData,atomLookUp,IdList):
    701764    '''gets a list of atoms from Atom table that match a set of atom IDs
     
    41244187    return Ind
    41254188               
    4126 def PeaksUnique(data,Ind,Sel):
     4189def PeaksUnique(data,Ind,Sel,dlg):
    41274190    '''Finds the symmetry unique set of peaks from those selected. Selects
    41284191    the one closest to the center of the unit cell.
     
    41334196    :param list Ind: list of selected peak indices
    41344197    :param int Sel: selected column to find peaks closest to
     4198    :param wx object dlg: progress bar dialog box
    41354199
    41364200    :returns: the list of symmetry unique peaks from among those given in Ind
     
    41644228                        Indx[jnd] = False
    41654229                        dups.append(jnd)
    4166             # select the unique peak closest to cell center
    41674230            cntr = mapPeaks[ind][Sel]
    41684231            icntr = ind
     
    41724235                    icntr = jnd
    41734236            Unique.append(icntr)
     4237        dlg.Update(ind,newmsg='Map peak no. %d processed'%ind) 
    41744238    return Unique
    41754239
  • trunk/GSASIIphsGUI.py

    r4836 r4838  
    11031103
    11041104#### Phase editing routines ################################################################################
    1105 def DrawAtomsReplaceByID(data,loc,atom,ID):
    1106     '''Replace all atoms in drawing array with an ID matching the specified value'''
    1107     atomData = data['Drawing']['Atoms']
    1108     indx = G2mth.FindAtomIndexByIDs(atomData,loc,[ID,])
    1109     for ind in indx:
    1110         atomData[ind] = MakeDrawAtom(data,atom,atomData[ind])
    1111 
    1112 def MakeDrawAtom(data,atom,oldatom=None):
    1113     'needs a description'
    1114     AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
    1115         'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK']
    1116     AA1letter = ['A','R','N','D','C','Q','E','G','H','I',
    1117         'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' ']
    1118     generalData = data['General']
    1119     Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
    1120     SGData = generalData['SGData']
    1121     deftype = G2obj.validateAtomDrawType(GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
    1122     if generalData['Type'] in ['nuclear','faulted',]:
    1123         if oldatom:
    1124             opr = oldatom[5]
    1125             if atom[9] == 'A':                   
    1126                 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17])
    1127                 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0]
    1128             else:
    1129                 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])
    1130                 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0]
    1131         else:
    1132             atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+
    1133                 ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0]
    1134         ct,cs = [1,8]         #type & color
    1135     elif  generalData['Type'] == 'magnetic':
    1136         if oldatom:
    1137             opr = oldatom[8]
    1138             mom = np.array(atom[7:10])
    1139             if generalData['Super']:
    1140                 SSGData = generalData['SSGData']
    1141                 Mom = G2spc.ApplyStringOpsMom(opr,SGData,SSGData,mom)
    1142             else:
    1143                 Mom = G2spc.ApplyStringOpsMom(opr,SGData,None,mom)
    1144             if atom[12] == 'A':                   
    1145                 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[14:20])
    1146                 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:14]+list(U)+oldatom[20:]][0]
    1147             else:
    1148                 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])
    1149                 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0]
    1150         else:
    1151             atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+
    1152                 ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
    1153         ct,cs = [1,11]         #type & color
    1154     elif generalData['Type'] == 'macromolecular':
    1155         try:
    1156             oneLetter = AA3letter.index(atom[1])
    1157         except ValueError:
    1158             oneLetter = -1
    1159         atomInfo = [[atom[1].strip()+atom[0],]+
    1160             [AA1letter[oneLetter]+atom[0],]+atom[2:5]+
    1161             atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
    1162         ct,cs = [4,11]         #type & color
    1163     atNum = generalData['AtomTypes'].index(atom[ct])
    1164     atomInfo[cs] = list(generalData['Color'][atNum])
    1165     return atomInfo
     1105# def DrawAtomsReplaceByID(data,loc,atom,ID):
     1106#     '''Replace all atoms in drawing array with an ID matching the specified value'''
     1107#     atomData = data['Drawing']['Atoms']
     1108#     indx = G2mth.FindAtomIndexByIDs(atomData,loc,[ID,])
     1109#     for ind in indx:
     1110#         atomData[ind] = MakeDrawAtom(data,atom,atomData[ind])
     1111
     1112# def MakeDrawAtom(data,atom,oldatom=None):
     1113#     'needs a description'
     1114#     AA3letter = ['ALA','ARG','ASN','ASP','CYS','GLN','GLU','GLY','HIS','ILE',
     1115#         'LEU','LYS','MET','PHE','PRO','SER','THR','TRP','TYR','VAL','MSE','HOH','WAT','UNK']
     1116#     AA1letter = ['A','R','N','D','C','Q','E','G','H','I',
     1117#         'L','K','M','F','P','S','T','W','Y','V','M',' ',' ',' ']
     1118#     generalData = data['General']
     1119#     Amat,Bmat = G2lat.cell2AB(generalData['Cell'][1:7])
     1120#     SGData = generalData['SGData']
     1121#     deftype = G2obj.validateAtomDrawType(GSASIIpath.GetConfigValue('DrawAtoms_default'),generalData)
     1122#     if generalData['Type'] in ['nuclear','faulted',]:
     1123#         if oldatom:
     1124#             opr = oldatom[5]
     1125#             if atom[9] == 'A':                   
     1126#                 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[11:17])
     1127#                 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:11]+list(U)+oldatom[17:]][0]
     1128#             else:
     1129#                 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])
     1130#                 atomInfo = [atom[:2]+list(X)+oldatom[5:9]+atom[9:]+oldatom[17:]][0]
     1131#         else:
     1132#             atomInfo = [atom[:2]+atom[3:6]+['1',]+[deftype]+
     1133#                 ['',]+[[255,255,255],]+atom[9:]+[[],[]]][0]
     1134#         ct,cs = [1,8]         #type & color
     1135#     elif  generalData['Type'] == 'magnetic':
     1136#         if oldatom:
     1137#             opr = oldatom[8]
     1138#             mom = np.array(atom[7:10])
     1139#             if generalData['Super']:
     1140#                 SSGData = generalData['SSGData']
     1141#                 Mom = G2spc.ApplyStringOpsMom(opr,SGData,SSGData,mom)
     1142#             else:
     1143#                 Mom = G2spc.ApplyStringOpsMom(opr,SGData,None,mom)
     1144#             if atom[12] == 'A':                   
     1145#                 X,U = G2spc.ApplyStringOps(opr,SGData,atom[3:6],atom[14:20])
     1146#                 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:14]+list(U)+oldatom[20:]][0]
     1147#             else:
     1148#                 X = G2spc.ApplyStringOps(opr,SGData,atom[3:6])
     1149#                 atomInfo = [atom[:2]+list(X)+list(Mom)+oldatom[8:12]+atom[12:]+oldatom[20:]][0]
     1150#         else:
     1151#             atomInfo = [atom[:2]+atom[3:6]+atom[7:10]+['1',]+[deftype]+
     1152#                 ['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
     1153#         ct,cs = [1,11]         #type & color
     1154#     elif generalData['Type'] == 'macromolecular':
     1155#         try:
     1156#             oneLetter = AA3letter.index(atom[1])
     1157#         except ValueError:
     1158#             oneLetter = -1
     1159#         atomInfo = [[atom[1].strip()+atom[0],]+
     1160#             [AA1letter[oneLetter]+atom[0],]+atom[2:5]+
     1161#             atom[6:9]+['1',]+[deftype]+['',]+[[255,255,255],]+atom[12:]+[[],[]]][0]
     1162#         ct,cs = [4,11]         #type & color
     1163#     atNum = generalData['AtomTypes'].index(atom[ct])
     1164#     atomInfo[cs] = list(generalData['Color'][atNum])
     1165#     return atomInfo
    11661166   
    11671167def getAtomSelections(AtmTbl,cn=0,action='action',includeView=False,ask=True):
     
    33183318                if 'Atoms' in data['Drawing'] and replot:
    33193319                    ci = colLabels.index('I/A')
    3320                     DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)
     3320                    G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)
    33213321                    G2plt.PlotStructure(G2frame,data)
    33223322                if SGData['SpGrp'] != 'P 1':    #no need to update P 1 structures!
     
    33433343                ID = atomData[r][ci+8]
    33443344                if 'Atoms' in data['Drawing']:
    3345                     DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)
     3345                    G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)
    33463346                    G2plt.PlotStructure(G2frame,data)
    33473347                SetupGeneral()
     
    35073507            SetPhaseWindow(Atoms,Scroll=Atoms.GetScrollPos(wx.VERTICAL))
    35083508
    3509 #### onSetOrigin.
     3509#### FillAtomsGrid main code
    35103510        if not data['Drawing']:                 #if new drawing - no drawing data!
    35113511            SetupDrawingData()
     
    38093809            FillAtomsGrid(Atoms)
    38103810            ID = atomData[indx[0]][ci+8]
    3811             DrawAtomsReplaceByID(data,ci+8,atomData[indx[0]],ID)
     3811            G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[indx[0]],ID)
    38123812            G2plt.PlotStructure(G2frame,data)
    38133813        event.StopPropagation()
     
    39493949                        for r in indx:
    39503950                            ID = atomData[r][ci+8]
    3951                             DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)
     3951                            G2mth.DrawAtomsReplaceByID(data,ci+8,atomData[r],ID)
    39523952                FillAtomsGrid(Atoms)
    39533953            dlg.Destroy()
     
    75187518           
    75197519    def DrawAtomAdd(drawingData,atom):
    7520         drawingData['Atoms'].append(MakeDrawAtom(data,atom))
     7520        drawingData['Atoms'].append(G2mth.MakeDrawAtom(data,atom))
    75217521       
    75227522    def OnRestraint(event):
     
    85208520        for atom in atomData:
    85218521            ID = atom[ci+8]
    8522             DrawAtomsReplaceByID(data,ci+8,atom,ID)
     8522            G2mth.DrawAtomsReplaceByID(data,ci+8,atom,ID)
    85238523        UpdateDrawAtoms()
    85248524        drawAtoms.ClearSelection()
     
    1057010570                for atom in atomData:
    1057110571                    ID = atom[cia+8]
    10572                     DrawAtomsReplaceByID(data,cia+8,atom,ID)
     10572                    G2mth.DrawAtomsReplaceByID(data,cia+8,atom,ID)
    1057310573                FindBondsDraw(data)
    1057410574                G2plt.PlotStructure(G2frame,data,False)
     
    1249112491                    return
    1249212492                wx.BeginBusyCursor()
     12493                pgbar = wx.ProgressDialog('Unique peaks','Map peak no. 0 processed',len(Ind)+1,
     12494                    style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE)
     12495
    1249312496                try:
    12494                     Ind = G2mth.PeaksUnique(data,Ind,sel)
     12497                    Ind = G2mth.PeaksUnique(data,Ind,sel,pgbar)
    1249512498                    print (' No. unique peaks: %d Unique peak fraction: %.3f'%(len(Ind),float(len(Ind))/len(mapPeaks)))
    1249612499                    tbl = MapPeaks.GetTable().data
Note: See TracChangeset for help on using the changeset viewer.