Changeset 5123


Ignore:
Timestamp:
Jan 5, 2022 9:45:01 PM (2 years ago)
Author:
toby
Message:

1st pass at fixing Mogul imports

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r5122 r5123  
    52605260            # initialize fullrmc dictionary if needed
    52615261            RMCPdict = data['RMC']['fullrmc'] = data['RMC'].get('fullrmc',{})
    5262             # always update, in case atoms have been updated
     5262            # update, if atoms list has been updated
    52635263            Atypes = [atype.split('+')[0].split('-')[0] for atype in data['General']['AtomTypes']]
    52645264            aTypes = dict(zip(Atypes,len(Atypes)*[0.10,]))
    5265             atSeq = list(aTypes.keys())
    5266             lenA = len(atSeq)
    5267             Pairs= []
    5268             for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i,lenA) if 'Va' not in atSeq[j]]
     5265            if len(data['RMC']['fullrmc'].get('aTypes',-1)) != len(aTypes):
     5266                #print('atypes has changed')
     5267                atSeq = list(aTypes.keys())
     5268                lenA = len(atSeq)
     5269                Pairs= []
     5270                for pair in [[' %s-%s'%(atSeq[i],atSeq[j]) for j in range(i,lenA) if 'Va' not in atSeq[j]]
    52695271                                 for i in range(lenA) if 'Va' not in atSeq[i]]:
    5270                 Pairs += pair
    5271             Pairs = {pairs:[0.0,0.0,0.0] for pairs in Pairs}
    5272             RMCPdict.update({'aTypes':aTypes,'atSeq':atSeq,'Pairs':Pairs})
     5272                    Pairs += pair
     5273                Pairs = {pairs:[0.0,0.0,0.0] for pairs in Pairs}
     5274                RMCPdict.update({'aTypes':aTypes,'atSeq':atSeq,'Pairs':Pairs})
    52735275            RMCPdict['files'] = RMCPdict.get('files',
    52745276                            {'Neutron real space data; G(r): ':['Select',1.,'G(r)',0,True],
  • trunk/GSASIIrestrGUI.py

    r4965 r5123  
    104104       
    105105    def getMOGULFile():
     106        # Type,Classification, No. of hits, Query value, Mean, Std. dev.
     107        colNums = [0,2,3,5,6,7]
    106108        dlg = wx.FileDialog(G2frame,message='Choose MOGUL csv file',
    107109            defaultDir='.',defaultFile="",wildcard="MOGUL csv file (*.csv)|*.csv",
     
    114116                head = mogul.readline()
    115117                if 'Type' not in head:
    116                     print (head)
    117                     print ('**** ERROR - not a MOGUL csv file selected, try again ****')
     118                    print ('Note: header line is\n',head)
     119                    print ('**** ERROR - file selected is not a MOGUL csv file, try again ****')
    118120                    mogul = []
     121                else:
     122                    for i,k in enumerate(('Type','Classification',
     123                            'No. of hits','Query value','Mean','Std. dev.')):
     124                        try:
     125                            colNums[i] = head.split(',').index(k)
     126                        except ValueError:
     127                            pass
    119128        finally:
    120129            dlg.Destroy()
    121         return mogul        #advanced past 1st line
     130        return mogul,colNums        #file pointer advanced past 1st line & col pointers
    122131       
    123132    def OnPlotAARestraint(event):
     
    360369
    361370    def AddMogulBondRestraint(bondRestData):
    362         mogul = getMOGULFile()
     371        mogul,colNums = getMOGULFile()
    363372        for line in mogul:
    364373            items = line.split(',')
    365             if 'bond' == items[0]:
    366                 oName,tName = items[2].split()
     374            if 'bond' == items[colNums[0]]:
     375                oName,tName = items[colNums[1]].split()
    367376                oInd = Names.index(oName)
    368377                tInd = Names.index(tName)
    369                 if items[3] != 'No hits':
    370                     dist = float(items[6])
    371                     esd = float(items[7])
     378                if items[colNums[2]] != 'No hits':
     379                    dist = float(items[colNums[4]])
     380                    esd = float(items[colNums[5]])
    372381                else:
    373                     dist = float(items[5])
     382                    dist = float(items[colNums[3]])
    374383                    esd = 0.02
    375384                newBond = [[Ids[oInd],Ids[tInd]],['1','1'],dist,esd]
     
    513522       
    514523    def AddMogulAngleRestraint(angleRestData):
    515         mogul = getMOGULFile()
     524        mogul,colNums = getMOGULFile()
    516525        for line in mogul:
    517526            items = line.split(',')
    518             if 'angle' == items[0]:
    519                 aName,bName,cName = items[2].split()
     527            if 'angle' == items[colNums[0]]:
     528                aName,bName,cName = items[colNums[1]].split()
    520529                aInd = Names.index(aName)
    521530                bInd = Names.index(bName)
    522531                cInd = Names.index(cName)
    523                 if items[3] != 'No hits':
    524                     angle = float(items[6])
    525                     esd = float(items[7])
     532                if items[colNums[2]] != 'No hits':
     533                    angle = float(items[colNums[4]])
     534                    esd = float(items[colNums[5]])
    526535                else:
    527                     angle = float(items[5])
     536                    angle = float(items[colNums[3]])
    528537                    esd = 2.00
    529538                newAngle = [[Ids[aInd],Ids[bInd],Ids[cInd]],['1','1','1'],angle,esd]
Note: See TracChangeset for help on using the changeset viewer.