Changeset 1884


Ignore:
Timestamp:
Jun 9, 2015 4:02:06 PM (8 years ago)
Author:
vondreele
Message:

remove some unused imports
add merohedral/pseudomerohedral Twin Laws to G2ddataGUI and G2strIO (not in G2strmath yet).
allow ReImport? atoms to fill otherwise empty Atom List
clarify HKL importers as Shelx HKL 4 & HKL 5 files.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIddataGUI.py

    r1878 r1884  
    1818'''
    1919import wx
    20 import math
    21 import copy
    22 import time
    23 import sys
    2420import GSASIIpath
    2521GSASIIpath.SetVersionNumber("$Revision$")
     
    781777        return flackSizer
    782778       
     779    def twinSizer():
     780       
     781        def OnAddTwin(event):
     782            twinMat = np.array([[1,0,0],[0,1,0],[0,0,1]])
     783            twinVal = [1.0,False]
     784            UseList[G2frame.hist]['Twins'].append([twinMat,twinVal])
     785            addtwin.SetValue(False)
     786            wx.CallLater(100,RepaintHistogramInfo)
     787           
     788        def OnMat(event):
     789            Obj = event.GetEventObject()
     790            it,im = Indx[Obj.GetId()]
     791            newMat = Obj.GetValue().split()
     792            try:
     793                uvw = [int(newMat[i]) for i in range(3)]
     794            except ValueError:
     795                uvw = UseList[G2frame.hist]['Twins'][it][0][im]
     796            UseList[G2frame.hist]['Twins'][it][0][im] = uvw
     797            Obj.SetValue('%d %d %d'%(uvw[0],uvw[1],uvw[2]))
     798           
     799        def OnTwinVal(event):
     800            Obj = event.GetEventObject()
     801            it = Indx[Obj.GetId()]
     802            try:
     803                val = float(Obj.GetValue())
     804                if 0. > val > 1.:\
     805                    raise ValueError
     806            except ValueError:
     807                val = UseList[G2frame.hist]['Twins'][it][1][0]
     808            UseList[G2frame.hist]['Twins'][it][1][0] = val
     809            Obj.SetValue('%.3f'%(val))
     810           
     811        def OnTwinRef(event):
     812            Obj = event.GetEventObject()
     813            it = Indx[Obj.GetId()]
     814            UseList[G2frame.hist]['Twins'][it][1][1] = Obj.GetValue()
     815                       
     816        def OnTwinDel(event):
     817            Obj = event.GetEventObject()
     818            it = Indx[Obj.GetId()]
     819            del UseList[G2frame.hist]['Twins'][it]
     820            wx.CallLater(100,RepaintHistogramInfo)           
     821           
     822        twinsizer = wx.BoxSizer(wx.VERTICAL)
     823        topsizer = wx.BoxSizer(wx.HORIZONTAL)         
     824        topsizer.Add(wx.StaticText(DData,wx.ID_ANY,' Merohedral/pseudomerohedral twins: '),0,WACV)
     825        addtwin = wx.CheckBox(DData,wx.ID_ANY,label=' Add Twin Law')
     826        addtwin.Bind(wx.EVT_CHECKBOX, OnAddTwin)
     827        topsizer.Add(addtwin,0,WACV)
     828        twinsizer.Add(topsizer)
     829        Indx = {}
     830        for it,Twin in enumerate(UseList[G2frame.hist]['Twins']):
     831            twinMat,twinVal = Twin
     832            matSizer = wx.BoxSizer(wx.HORIZONTAL)
     833            matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV)
     834            Style = wx.TE_READONLY
     835            if it:
     836                Style = wx.TE_PROCESS_ENTER
     837            for im,Mat in enumerate(twinMat):
     838                mat = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(Mat[0],Mat[1],Mat[2]),
     839                    style=Style)
     840                if it:
     841                    Indx[mat.GetId()] = [it,im]
     842                    mat.Bind(wx.EVT_TEXT_ENTER,OnMat)
     843                    mat.Bind(wx.EVT_KILL_FOCUS,OnMat)
     844                matSizer.Add(mat,0,WACV|wx.LEFT,5)
     845            twinsizer.Add(matSizer,0,WACV|wx.LEFT,5)
     846            valSizer = wx.BoxSizer(wx.HORIZONTAL)
     847            valSizer.Add(wx.StaticText(DData,-1,label=' Twin element fraction:'),0,WACV)
     848            twinval = wx.TextCtrl(DData,-1,'%.3f'%(Twin[1][0]),style=wx.TE_PROCESS_ENTER)
     849            Indx[twinval.GetId()] = it
     850            twinval.Bind(wx.EVT_TEXT_ENTER,OnTwinVal)
     851            twinval.Bind(wx.EVT_KILL_FOCUS,OnTwinVal)
     852            valSizer.Add(twinval,0,WACV)
     853            if it:
     854                twinref = wx.CheckBox(DData,wx.ID_ANY,label=' Refine?')
     855                Indx[twinref.GetId()] = it
     856                twinref.SetValue(Twin[1][1])
     857                twinref.Bind(wx.EVT_CHECKBOX, OnTwinRef)
     858                valSizer.Add(twinref,0,WACV)
     859                twindel = wx.CheckBox(DData,wx.ID_ANY,label=' Delete?')
     860                Indx[twindel.GetId()] = it
     861                twindel.Bind(wx.EVT_CHECKBOX, OnTwinDel)
     862                valSizer.Add(twindel,0,WACV)
     863            twinsizer.Add(valSizer,0,WACV|wx.LEFT,5)
     864        return twinsizer
     865       
    783866    def OnSelect(event):
    784867        G2frame.hist = keyList[select.GetSelection()]
     
    9381021            if 'Flack' not in UseList[G2frame.hist]:
    9391022                UseList[G2frame.hist]['Flack'] = [0.0,False]
     1023            if 'Twins' not in UseList[G2frame.hist]:
     1024                UseList[G2frame.hist]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
    9401025#end patch
    9411026            bottomSizer.Add(ExtSizer('HKLF'),0,WACV|wx.BOTTOM,5)
     
    9431028            if not SGData['SGInv']:        #not operational yet - no test data
    9441029                bottomSizer.Add(FlackSizer(),0,WACV|wx.BOTTOM,5)
     1030            bottomSizer.Add(twinSizer(),0,WACV|wx.BOTTOM,5)
    9451031        return bottomSizer
    9461032               
  • trunk/GSASIIobj.py

    r1875 r1884  
    13011301        'Eg$' : 'Secondary type I extinction',
    13021302        'Flack' : 'Flack parameter',
     1303        'TwinFr' : 'Twin fraction',
    13031304        #Histogram vars (:h:<var>)
    13041305        'Absorption' : 'Absorption coef.',
  • trunk/GSASIIphsGUI.py

    r1875 r1884  
    2828import wx.lib.scrolledpanel as wxscroll
    2929import matplotlib as mpl
    30 import math
    3130import copy
    3231import time
     
    20792078        atomData = data['Atoms']
    20802079        atomNames = []
     2080        All = False
    20812081        for atom in atomData:
    2082             atomNames.append(atom[:ct+1])
     2082            atomNames.append(''.join(atom[:ct+1]).capitalize())  #eliminate spurious differences
    20832083        for atom in rd.Phase['Atoms']:
    20842084            try:
    2085                 idx = atomNames.index(atom[:ct+1])
     2085                idx = atomNames.index(''.join(atom[:ct+1]).capitalize())  #eliminate spurious differences
    20862086                atId = atom[cia+8]
    20872087                atomData[idx][:-1] = atom[:-1]
    20882088                atomData[idx][cia+8] = atId
    20892089            except ValueError:
    2090                 print atom[:ct+1], 'not in Atom array; not updated'
     2090                if All:
     2091                    atomData.append(atom)
     2092                else:
     2093                    dlg = wx.MessageDialog(G2frame,'Some atoms not in List; do you want to append them all',   \
     2094                        'Unknown atom '+atom[0],wx.YES_NO|wx.ICON_QUESTION)
     2095                    try:
     2096                        result = dlg.ShowModal()
     2097                        if result in [wx.ID_YES,]:
     2098                            All = True
     2099                            atomData.append(atom)
     2100                        else:
     2101                            print atom[:ct+1], 'not in Atom array; not updated'
     2102                    finally:
     2103                        dlg.Destroy()
    20912104        wx.CallAfter(FillAtomsGrid,Atoms)
    20922105       
     
    23192332           
    23202333################################################################################
    2321 #Structure drawing GUI stuff               
     2334#### Structure drawing GUI stuff               
    23222335################################################################################
    23232336
     
    38353848                'Extinction':['Lorentzian','None',
    38363849                {'Tbar':0.1,'Cos2TM':0.955,'Eg':[1.e-7,False],'Es':[1.e-7,False],'Ep':[1.e-7,False]},],
    3837                 'Flack':[0.0,False]}                       
     3850                'Flack':[0.0,False],'Twins':[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]}                       
    38383851            UpdateHKLFdata(histoName)
    38393852            data['Histograms'] = UseList
     
    38603873        sourceDict = UseList[hist]
    38613874        if 'HKLF' in sourceDict['Histogram']:
    3862             copyNames = ['Scale','Extinction','Babinet','Flack']
     3875            copyNames = ['Scale','Extinction','Babinet','Flack','Twins']
    38633876        else:  #PWDR 
    38643877            copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet']
     
    38843897            copyNames = ['Scale','Extinction','Babinet','Flack']
    38853898        else:  #PWDR 
    3886             copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet']
     3899            copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet','Twins']
    38873900        babNames = ['BabA','BabU']
    38883901        for name in copyNames:
    3889             if name in ['Scale','Extinction','HStrain','Flack']:
     3902            if name in ['Scale','Extinction','HStrain','Flack','Twins']:
    38903903                if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']:
    38913904                    copyDict[name] = {name:[sourceDict[name][:2]]}
    38923905                    for item in ['Eg','Es','Ep']:
    38933906                        copyDict[name][item] = sourceDict[name][2][item][1]
     3907                elif name == 'Twins':
     3908                    for it,twin in enumerate(sourceDict['Twins']):
     3909                        copyDict[name][it] = twin[1][1]
    38943910                else:
    38953911                    copyDict[name] = sourceDict[name][1]
     
    39193935                        UseList[item]
    39203936                        for name in copyNames:
    3921                             if name in ['Scale','Extinction','HStrain','Flack']:
     3937                            if name in ['Scale','Extinction','HStrain','Flack','Twins']:
    39223938                                if name == 'Extinction' and 'HKLF' in sourceDict['Histogram']:
    39233939                                    UseList[item][name][:2] = copy.deepcopy(sourceDict[name][:2])
    39243940                                    for itm in ['Eg','Es','Ep']:
    39253941                                        UseList[item][name][2][itm][1] = copy.deepcopy(copyDict[name][itm])
     3942                                elif name == 'Twins':
     3943                                    for it,twin in enumerate(sourceDict['Twins']):
     3944                                        UseList[item]['Twins'][it][1][1] = copyDict['Twins'][it]
    39263945                                else:
    39273946                                    UseList[item][name][1] = copy.deepcopy(copyDict[name])
     
    39513970        copyDict = {}
    39523971        if 'HKLF' in sourceDict['Histogram']:
    3953             copyNames = ['Scale','Extinction','Babinet','Flack']
     3972            copyNames = ['Scale','Extinction','Babinet','Flack','Twins']
    39543973        else:  #PWDR 
    39553974            copyNames = ['Scale','Pref.Ori.','Size','Mustrain','HStrain','Extinction','Babinet']
  • trunk/GSASIIstrIO.py

    r1876 r1884  
    20272027        print >>pFile,varstr
    20282028       
    2029    
    20302029    hapDict = {}
    20312030    hapVary = []
     
    22432242                if hapData.get('Flack',[0,False])[1]:
    22442243                    hapVary.append(pfx+'Flack')
     2244                Twins = hapData.get('Twins',[[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],])
     2245                sumTwFr = 0.
     2246                for it,twin in enumerate(Twins):
     2247                    controlDict[pfx+'TwinLaw;'+str(it)] = twin[0]
     2248                    hapDict[pfx+'TwinFr;'+str(it)] = twin[1][0]
     2249                    sumTwFr += twin[1][0]
     2250                    if twin[1][1]:
     2251                        hapVary.append(pfx+'TwinFr;'+str(it))
     2252                for it,twin in enumerate(Twins):    #force sum to unity
     2253                    hapDict[pfx+'TwinFr;'+str(it)] /= sumTwFr
    22452254                if Print:
    22462255                    print >>pFile,'\n Phase: ',phase,' in histogram: ',histogram
     
    22572266                    if not SGData['SGInv']:
    22582267                        print >>pFile,' Flack parameter: %10.3f'%(hapData['Flack'][0]),' Refine?',hapData['Flack'][1]
     2268                    if len(Twins) > 1:
     2269                        for it,twin in enumerate(Twins):
     2270                            print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr;'+str(it)]),twin[1][1]
     2271                       
    22592272                Histogram['Reflection Lists'] = phase       
    22602273               
     
    24092422        print >>pFile,ptstr
    24102423        print >>pFile,sigstr
     2424       
     2425    def PrintTwinsAndSig(pfx,hapData,TwinSig):
     2426        print >>pFile,'\n Twin Law fractions : '
     2427        ptlbls = ' names :'
     2428        ptstr =  ' values:'
     2429        sigstr = ' sig   :'
     2430        for item in hapData:
     2431            ptlbls += '%12s'%(item)
     2432            ptstr += '%12.3f'%(hapData[item][0])
     2433            if pfx+item in TwinSig:
     2434                sigstr += '%12.3f'%(TwinSig[pfx+item])
     2435            else:
     2436                sigstr += 12*' '
     2437        print >>pFile,ptlbls
     2438        print >>pFile,ptstr
     2439        print >>pFile,sigstr
     2440       
    24112441   
    24122442    PhFrExtPOSig = {}
     
    24142444    ScalExtSig = {}
    24152445    BabSig = {}
     2446    TwinFrSig = {}
    24162447    wtFrSum = {}
    24172448    for phase in Phases:
     
    24962527                        if pfx+item in sigDict:
    24972528                            ScalExtSig[pfx+item] = sigDict[pfx+item]
    2498                 for name in ['BabA','BabU']:
    2499                     hapData['Babinet'][name][0] = parmDict[pfx+name]
    2500                     if pfx+name in sigDict:
    2501                         BabSig[pfx+name] = sigDict[pfx+name]               
     2529                for item in ['BabA','BabU']:
     2530                    hapData['Babinet'][item][0] = parmDict[pfx+item]
     2531                    if pfx+item in sigDict:
     2532                        BabSig[pfx+item] = sigDict[pfx+item]
     2533                item = 'TwinFr'
     2534                it = 0
     2535                while True:
     2536                    try:
     2537                        hapData['TwinFr'][1][0] = parmDict[pfx+'TwinFr;'+str(it)]
     2538                        if pfx+'TwinFr;'+str(it) in sigDict:
     2539                            TwinFrSig[pfx+'TwinFr;'+str(it)] = sigDict[pfx+'TwinFr;'+str(it)]
     2540                        it += 1
     2541                    except KeyError:
     2542                        break
    25022543
    25032544    if Print:
     
    25612602                    if pfx+'Flack' in ScalExtSig:
    25622603                        print >>pFile,' Flack parameter : %10.3f, sig %10.3f'%(hapData['Flack'][0],ScalExtSig[pfx+'Flack'])
     2604                    if pfx+'TwinFr;1' in TwinFrSig:
     2605                        PrintTwinFrAndSig(pfx,hapData['TwinFr'],TwinFrSig)
    25632606
    25642607################################################################################
  • trunk/GSASIIstrMath.py

    r1880 r1884  
    1212########### SVN repository information ###################
    1313import time
    14 import math
    1514import copy
    1615import numpy as np
     
    3635atan2d = lambda y,x: 180.*np.arctan2(y,x)/np.pi
    3736   
    38 ateln2 = 8.0*math.log(2.0)
     37ateln2 = 8.0*np.log(2.0)
    3938twopi = 2.0*np.pi
    4039twopisq = 2.0*np.pi**2
  • trunk/imports/G2sfact.py

    r1832 r1884  
    8585            return False
    8686
    87 class HKLF2_ReaderClass(G2IO.ImportStructFactor):
    88     'Routines to import F**2, sig(F**2) reflections from a HKLF file'
    89     def __init__(self):
    90         if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
    91             formatName = 'HKL F2'
    92             longFormatName = 'Simple [hkl, Fo2, sig(Fo2)] Structure factor text file'
     87class HKLF4_ReaderClass(G2IO.ImportStructFactor):
     88    'Routines to import F**2, sig(F**2) reflections from a HKLF 4 file'
     89    def __init__(self):
     90        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
     91            formatName = 'HKL 4'
     92            longFormatName = 'Shelx HKL4 [hkl, Fo2, sig(Fo2)] Structure factor text file'
    9393        else:
    9494            formatName = u'HKL F\u00b2'
    95             longFormatName = u'Simple [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'
     95            longFormatName = u'Shelx HKL4 [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'
    9696        super(self.__class__,self).__init__( # fancy way to self-reference
    9797            extensionlist=('.hkl','.HKL'),
     
    203203           
    204204class SHELX5_ReaderClass(G2IO.ImportStructFactor):
    205     'Routines to import F**2, sig(F**2) reflections from a fixed format SHELX HKLF5 file'
    206     def __init__(self):
    207         if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
    208             formatName = 'SHELX HKL F2'
    209             longFormatName = 'SHELX HKLF5 [hkl, Fo2, sig(Fo2)] Structure factor text file'
     205    'Routines to import F**2, sig(F**2) twin index reflections from a fixed format SHELX HKLF5 file'
     206    def __init__(self):
     207        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
     208            formatName = 'SHELX HKL5 F2'
     209            longFormatName = 'SHELX HKLF5 [hklm, Fo2, sig(Fo2), Tind] Structure factor text file'
    210210        else:
    211211            formatName = u'SHELX HKL F\u00b2'
    212             longFormatName = u'SHELX HKLF5 [hkl, Fo\u00b2, sig(Fo\u00b2)] Structure factor text file'       
     212            longFormatName = u'SHELX HKLF5 [hklm, Fo\u00b2, sig(Fo\u00b2), Tind] Structure factor text file'       
    213213        super(self.__class__,self).__init__( # fancy way to self-reference
    214214            extensionlist=('.hkl','.HKL'),
     
    222222        numCols = 0
    223223        for i,line in enumerate(filepointer):
    224             numCols = max(numCols,len(line))
     224            numCols = max(numCols,len(line.split()))
    225225            if i > 20:
    226226                break
    227         self.Super = (numCols-33)/4     #= 0,1,2,or 3
    228         print numCols,self.Super
     227        self.Super = numCols-6     #= 0,1,2,or 3
     228        if self.Super > 1:
     229            raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
    229230        return True #ColumnValidator(self, filepointer)
    230231
     
    235236                self.errors = '  Error reading line '+str(line+1)
    236237                if self.Super == 0:
    237                     h,k,l,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:20],S[20:28]
     238                    h,k,l,Fo,sigFo,Tw = S.split()
    238239                    h,k,l = [int(h),int(k),int(l)]
    239240                elif self.Super == 1:
    240                     h,k,l,m1,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:16],S[16:24],S[24:32]
     241                    h,k,l,m1,Fo,sigFo,Tw = S.split()
    241242                    h,k,l,m1 = [int(h),int(k),int(l),int(m1)]
    242                 elif self.Super == 2:
    243                     h,k,l,m1,m2,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:16],S[16:20],S[20:28],S[28:36]
    244                     h,k,l,m1,m2 = [int(h),int(k),int(l),int(m1),int(m2)]
    245                 elif self.Super == 3:
    246                     h,k,l,m1,m2,m3,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:16],S[16:20],S[20:24],S[24:32],S[32:40]
    247                     h,k,l,m1,m2,m3 = [int(h),int(k),int(l),int(m1),int(m2),int(m3)]
    248243                if not any([h,k,l]):
    249244                    break
     
    252247                # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
    253248                if self.Super == 0:
    254                     self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0])
     249                    self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0,Tw])
    255250                elif self.Super == 1:
    256                     self.RefDict['RefList'].append([h,k,l,m1,0,0,Fo,sigFo,0,Fo,0,0,0])
    257                 elif self.Super == 2:
    258                     self.RefDict['RefList'].append([h,k,l,m1,m2,0,0,Fo,sigFo,0,Fo,0,0,0])
    259                 elif self.Super == 3:
    260                     self.RefDict['RefList'].append([h,k,l,m1,m2,m3,0,0,Fo,sigFo,0,Fo,0,0,0])
     251                    self.RefDict['RefList'].append([h,k,l,m1,0,0,Fo,sigFo,0,Fo,0,0,0,Tw])
    261252                #self.RefDict['FF'].append({}) # now done in OnImportSfact
    262253            self.errors = 'Error after reading reflections (unexpected!)'
Note: See TracChangeset for help on using the changeset viewer.