Changeset 5062


Ignore:
Timestamp:
Nov 1, 2021 11:24:15 AM (2 years ago)
Author:
toby
Message:

Start on isodisplace import cleanup & formatting; plotting changes for conv plots

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIobj.py

    r5041 r5062  
    13311331import random as ran
    13321332import sys
    1333 import os.path as ospath
     1333import os.path
    13341334if '2' in platform.python_version_tuple()[0]:
    13351335    import cPickle
     
    16391639            shortname = hist[:11] + ' ('+ hId + ')'
    16401640        ShortHistNames[hId] = shortname
     1641
     1642def AddPhase2Index(rdObj,filename):
     1643    '''Add a phase to the index during reading
     1644    Used where constraints are generated during import (ISODISTORT CIFs)       
     1645    '''
     1646    ranId = rdObj.Phase['ranId']
     1647    ph = 'from  '+filename #  phase is not named yet
     1648    if ranId in PhaseRanIdLookup: return
     1649    maxph = -1
     1650    for r in PhaseRanIdLookup:
     1651        maxph = max(maxph,PhaseRanIdLookup[r])
     1652    PhaseRanIdLookup[ranId] = pId = str(maxph + 1)
     1653    PhaseIdLookup[pId] = (ph,ranId)
     1654    shortname = 'from '+ os.path.splitext((os.path.split(filename))[1])[0]
     1655    while shortname in ShortPhaseNames.values():
     1656        shortname = ph[:8] + ' ('+ pId + ')'
     1657    ShortPhaseNames[pId] = shortname
     1658    AtomIdLookup[pId] = {}
     1659    AtomRanIdLookup[pId] = {}
     1660    for iatm,at in enumerate(rdObj.Phase['Atoms']):
     1661        ranId = at[-1]
     1662        while ranId in AtomRanIdLookup[pId]: # check for dups
     1663            print ("\n\n*** Phase "+str(ph)+" atom "+str(iatm)+" has repeated ranId. Fixing.\n")
     1664            at[-1] = ranId = ran.randint(0,sys.maxsize)
     1665        AtomRanIdLookup[pId][ranId] = str(iatm)
     1666        #if Phases[ph]['General']['Type'] == 'macromolecular':
     1667        #    label = '%s_%s_%s_%s'%(at[ct-1],at[ct-3],at[ct-4],at[ct-2])
     1668        #else:
     1669        #    label = at[ct-1]
     1670        label = at[0]
     1671        AtomIdLookup[pId][str(iatm)] = (label,ranId)
    16411672
    16421673def LookupAtomId(pId,ranId):
     
    25092540        '''
    25102541        if filename:
    2511             ext = ospath.splitext(filename)[1]
     2542            ext = os.path.splitext(filename)[1]
    25122543            if not ext and self.strictExtension: return False
    25132544            for ext in self.extensionlist:               
  • trunk/GSASIIphsGUI.py

    r5061 r5062  
    66896689            topSizer = wx.BoxSizer(wx.VERTICAL)   
    66906690            bottomSizer = wx.BoxSizer(wx.VERTICAL)
    6691             topSizer.Add(wx.StaticText(ISODIST,label=' ISODISTORT distortion modes for %s:'%data['General']['Name']))
    6692             topSizer.Add(wx.StaticText(ISODIST,label='''
    6693 For use of ISODISTORT, please cite:
     6691            topSizer.Add(wx.StaticText(ISODIST,
     6692                         label=''' For use of ISODISTORT, please cite:
    66946693  H. T. Stokes, D. M. Hatch, and B. J. Campbell, ISODISTORT, ISOTROPY Software Suite, iso.byu.edu.
    6695   B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for Exploring Structural Distortions."
    6696   J. Appl. Cryst. 39, 607-614 (2006).
     6694  B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for
     6695  Exploring Structural Distortions." J. Appl. Cryst. 39, 607-614 (2006).
    66976696  '''))
     6697            topSizer.Add(wx.StaticText(ISODIST,label=' ISODISTORT distortion modes for %s\n:'%data['General']['Name']))
    66986698            lineSizer = wx.BoxSizer(wx.HORIZONTAL)           
    66996699            lineSizer.Add(wx.StaticText(ISODIST,label=' Adjust magnitude of distortion modes (-0.1 to +0.1):  '),0,WACV)
     
    67336733For use of ISODISTORT, please cite:
    67346734  H. T. Stokes, D. M. Hatch, and B. J. Campbell, ISODISTORT, ISOTROPY Software Suite, iso.byu.edu.
    6735   B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for Exploring Structural Distortions."
    6736   J. Appl. Cryst. 39, 607-614 (2006).
     6735  B. J. Campbell, H. T. Stokes, D. E. Tanner, and D. M. Hatch, "ISODISPLACE: An Internet Tool for
     6736  Exploring Structural Distortions." J. Appl. Cryst. 39, 607-614 (2006).
    67376737  '''))
    67386738        topSizer.Add(wx.StaticText(ISODIST,label=' Subset selection if desired:'))
  • trunk/GSASIIplot.py

    r5052 r5062  
    890890            page.canvas.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))
    891891           
    892 def PlotFPAconvolutors(G2frame,NISTpk):
     892def PlotFPAconvolutors(G2frame,NISTpk,conv2T=None,convI=None,convList=None):
    893893    '''Plot the convolutions used for the current peak computed with
    894894    :func:`GSASIIfpaGUI.doFPAcalc`
     
    907907    #GSASIIpath.IPyBreak()
    908908    i = -1
    909     for conv in NISTpk.convolvers:
     909    if convList is None:
     910        convList = NISTpk.convolvers
     911    for conv in convList:
    910912        if 'smoother' in conv: continue
    911913        if 'crystallite_size' in conv: continue
     
    922924        color = refColors[i%len(refColors)]
    923925        Plot.plot(ttArr,FFT,color,label=conv[5:])
     926    if conv2T is not None and convI is not None:
     927        color = refColors[(i+1)%len(refColors)]
     928        Plot.plot(conv2T,convI,color,label='Convolution')
    924929    legend = Plot.legend(loc='best')
    925930    SetupLegendPick(legend,new)
  • trunk/imports/G2phase_CIF.py

    r5058 r5062  
    651651                else:
    652652                    self.errors = "Error while processing ISODISTORT constraints"
    653                     self.ISODISTORT_proc(blk,atomlbllist,ranIdlookup)
     653                    self.ISODISTORT_proc(blk,atomlbllist,ranIdlookup,filename)
    654654                    self.errors = ""
    655655            returnstat = True
     
    667667        return False
    668668       
    669     def ISODISTORT_proc(self,blk,atomlbllist,ranIdlookup):
     669    def ISODISTORT_proc(self,blk,atomlbllist,ranIdlookup,filename):
    670670        '''Process ISODISTORT items to create constraints etc.
    671671        Constraints are generated from information extracted from
     
    685685        self.Constraints = []
    686686        explaination = {}
     687        G2obj.AddPhase2Index(self,filename)   # put phase info into Var index
    687688        #----------------------------------------------------------------------
    688689        # read in the ISODISTORT displacement modes
     
    722723                    error = True
    723724                    continue
    724                 else:
    725                     anum = atomlbllist.index(albl)
     725                # else:
     726                #     anum = atomlbllist.index(albl)
    726727                var = varLookup.get(vlbl)
    727728                if not var:
     
    865866                    error = True
    866867                    continue
    867                 else:
    868                     anum = atomlbllist.index(albl)
     868                # else:
     869                #     anum = atomlbllist.index(albl)
    869870                var = varLookup.get(vlbl)
    870871                if not var:
     
    985986            print( 70*'=')
    986987            print('\nVar2ModeMatrix' ,'IsoVarList' )
     988            def fmtConstr(i,head,l,var,k):
     989                if len(head) + len(l) > 65:
     990                    print(head+l)
     991                    head = 20*' '
     992                    l = ''
     993                if k == 0: return
     994                if k < 0 and i > 0:
     995                    l += '  -  '
     996                    k = -k
     997                elif i > 0:
     998                    l += '  +  '
     999                if k == 1:
     1000                    l += '%s ' % str(var)
     1001                else:
     1002                    l += '%.3f * %s' % (k,str(var))
     1003                return head,l
    9871004            for i,row in enumerate(displacivemodeInvmatrix):
    988                 l = ''
     1005                head = str(i) + ': ' + str(modeVarList[i]) + ' = '
     1006                line = ''
    9891007                for j,(lbl,k) in enumerate(zip(coordVarLbl,row)):
    990                     if k == 0: continue
    991                     if l: l += ' + '
    992                     #l += lbl+' * '+str(k)
    993                     l += str(G2varObj[j])+' * '+str(k)
    994                 print( str(i) + ': '+str(modeVarList[i])+' = '+l)
     1008                    head,line = fmtConstr(j,head,line,G2varObj[j],k)
     1009                print(head+line)
    9951010
    9961011            # Get the ISODISTORT offset values
     
    10101025            # compute the mode values from the reported coordinate deltas
    10111026            for i,(row,n) in enumerate(zip(displacivemodeInvmatrix,normlist)):
    1012                 l = ''
    1013                 for lbl,k in zip(coordVarLbl,row):
    1014                     if k == 0: continue
    1015                     if l: l += ' + '
    1016                     l += lbl+' * '+str(k)
    1017                 print('a'+str(i)+' = '+str(modeVarList[i])+' = ('+l+')/'+str(n))
     1027                line = ''
     1028                head = 'a'+str(i)+': '+str(modeVarList[i])+' = ('
     1029                for j,(lbl,k) in enumerate(zip(coordVarLbl,row)):
     1030                    head,line = fmtConstr(j,head,line,lbl,k)
     1031                print(head+line+') / '+('%.3f'%n))
     1032                breakpoint()
    10181033            print('\nCalculation checks\n')
    10191034            for i,(row,n) in enumerate(zip(displacivemodeInvmatrix,normlist)):
Note: See TracChangeset for help on using the changeset viewer.