Changeset 1910


Ignore:
Timestamp:
Jun 26, 2015 2:13:27 PM (8 years ago)
Author:
vondreele
Message:

fix reading run-on numbers in Shelx HKLF 4 files
implement all I/O for nonmerohedral twin data from HKLF 5 files
Twin GUI stuff set for mero & nonmero twins

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1909 r1910  
    833833                UseList[histoName] = SetDefaultDData(reflData['Type'],histoName)
    834834                G,g = G2lat.cell2Gmat(generalData['Cell'][1:7])
     835                UseList[histoName]['Twins'] = [[np.array([[1,0,0],[0,1,0],[0,0,1]]),[1.0,False]],]
     836                for iT in range(reflData['TwMax']):
     837                    UseList[histoName]['Twins'].append([[],0.0])
    835838                for iref,ref in enumerate(reflData['RefList']):
    836839                    hkl = ref[:3]
  • trunk/GSASIIddataGUI.py

    r1906 r1910  
    844844                twinMat,twinVal = Twin
    845845                matSizer = wx.BoxSizer(wx.HORIZONTAL)
    846                 matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV)
    847846                if it:
    848847                    Style = wx.TE_PROCESS_ENTER
     
    851850                    Style = wx.TE_READONLY
    852851                    TwVal = Twin[1][0]
    853                 for im,Mat in enumerate(twinMat):
    854                     mat = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(Mat[0],Mat[1],Mat[2]),
    855                         style=Style)
    856                     if it:
    857                         Indx[mat.GetId()] = [it,im]
    858                         mat.Bind(wx.EVT_TEXT_ENTER,OnMat)
    859                         mat.Bind(wx.EVT_KILL_FOCUS,OnMat)
    860                     else:
    861                         mat.SetBackgroundColour(VERY_LIGHT_GREY)
    862                     matSizer.Add(mat,0,WACV|wx.LEFT,5)
     852                if len(Twin[0]):
     853                    matSizer.Add(wx.StaticText(DData,-1,' Twin Law: '),0,WACV)
     854                    for im,Mat in enumerate(twinMat):
     855                        mat = wx.TextCtrl(DData,wx.ID_ANY,'%3d %3d %3d'%(Mat[0],Mat[1],Mat[2]),
     856                            style=Style)
     857                        if it:
     858                            Indx[mat.GetId()] = [it,im]
     859                            mat.Bind(wx.EVT_TEXT_ENTER,OnMat)
     860                            mat.Bind(wx.EVT_KILL_FOCUS,OnMat)
     861                        else:
     862                            mat.SetBackgroundColour(VERY_LIGHT_GREY)
     863                        matSizer.Add(mat,0,WACV|wx.LEFT,5)
     864                else:
     865                    matSizer.Add(wx.StaticText(DData,-1,' Nonmerohedral twin component %d:'%(it)),0,WACV)
    863866                twinsizer.Add(matSizer,0,WACV|wx.LEFT,5)
    864867                valSizer = wx.BoxSizer(wx.HORIZONTAL)
     
    872875                    twinval.SetBackgroundColour(VERY_LIGHT_GREY)
    873876                valSizer.Add(twinval,0,WACV)
    874                 if it:
     877                if it and len(Twin[0]):
    875878                    twindel = wx.CheckBox(DData,wx.ID_ANY,label=' Delete?')
    876879                    Indx[twindel.GetId()] = it
    877880                    twindel.Bind(wx.EVT_CHECKBOX, OnTwinDel)
    878881                    valSizer.Add(twindel,0,WACV)
    879                 else:
     882                elif not it:
    880883                    twinref = wx.CheckBox(DData,wx.ID_ANY,label=' Refine?')
    881884                    twinref.SetValue(Twin[1][1])
  • trunk/GSASIIstrIO.py

    r1897 r1910  
    22652265                controlDict[pfx+'TwinLaw'] = []               
    22662266                for it,twin in enumerate(Twins):
    2267                     controlDict[pfx+'TwinLaw'].append(twin[0])
     2267                    if len(twin[0]):
     2268                        controlDict[pfx+'TwinLaw'].append(twin[0])
     2269                    else:
     2270                        controlDict[pfx+'TwinLaw'].append(np.zeros((3,3)))
    22682271                    if it:
    22692272                        hapDict[pfx+'TwinFr:'+str(it)] = twin[1]
     
    22932296                    if len(Twins) > 1:
    22942297                        for it,twin in enumerate(Twins):
    2295                             print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
     2298                            if len(twin[0]):
     2299                                print >>pFile,' Twin law: %s'%(str(twin[0]).replace('\n',',')),' Twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
     2300                            else:
     2301                                print >>pFile,' Nonmerohedral twin fr.: %5.3f Refine? '%(hapDict[pfx+'TwinFr:'+str(it)]),Twins[0][1][1]
    22962302                       
    22972303                Histogram['Reflection Lists'] = phase       
  • trunk/GSASIIstrMath.py

    r1902 r1910  
    819819        Flack = 1.-2.*parmDict[phfx+'Flack']
    820820    TwinLaw = np.array([[[1,0,0],[0,1,0],[0,0,1]],])
     821    TwinDict = refDict.get('TwinDict',{})           
    821822    if 'S' in calcControls[hfx+'histType']:
    822823        TwinLaw = calcControls[phfx+'TwinLaw']
     
    847848                refDict['FF']['FF'][iref] *= dat.values()
    848849#reflection processing begins here - big arrays!
    849     iBeg = 0           
     850    iBeg = 0
    850851    while iBeg < nRef:
    851852        iFin = min(iBeg+blkSize,nRef)
  • trunk/imports/G2sfact.py

    r1909 r1910  
    110110                self.errors = '  Error reading line '+str(line+1)
    111111                if S[0] == '#': continue       #ignore comments, if any
    112                 h,k,l,Fo,sigFo = S.split()[:5]
     112                h,k,l,Fo,sigFo = S[:4],S[4:8],S[8:12],S[12:20],S[20:28]
    113113                h,k,l = [int(h),int(k),int(l)]
    114114                if not any([h,k,l]):
     
    132132            return False
    133133           
     134class SHELX5_ReaderClass(G2IO.ImportStructFactor):
     135    'Routines to import F**2, sig(F**2) twin/incommensurate reflections from a fixed format SHELX HKLF5 file'
     136    def __init__(self):
     137        if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
     138            formatName = 'SHELX HKLF 5 F2 Tw/Incom'
     139            longFormatName = 'SHELX HKLF 5 [hklm, Fo2, sig(Fo2), Tind] Twin/incommensurate structure factor text file'
     140        else:
     141            formatName = u'SHELX HKLF 5 F\u00b2 Tw/Incom'
     142            longFormatName = u'SHELX HKLF 5 [hklm, Fo\u00b2, sig(Fo\u00b2), Tind] Twin/incommensurate structure factor text file'       
     143        super(self.__class__,self).__init__( # fancy way to self-reference
     144            extensionlist=('.hkl','.HKL'),
     145            strictExtension=False,
     146            formatName=formatName,
     147            longFormatName=longFormatName)
     148        self.Super = 0
     149
     150    def ContentsValidator(self, filepointer):
     151        'Discover how many characters are in the SHELX file - could be 32-44 depending on satellites'
     152        numCols = 0
     153        for i,line in enumerate(filepointer):
     154            numCols = max(numCols,len(line.split()))
     155            if i > 20:
     156                break
     157        self.Super = numCols-6     #= 0,1,2,or 3
     158        if self.Super > 1:
     159            raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
     160        return True #ColumnValidator(self, filepointer)
     161
     162    def Reader(self,filename,filepointer, ParentFrame=None, **unused):
     163        'Read the file'
     164        TwDict = {}
     165        TwSet = {}
     166        TwMax = 0
     167        try:
     168            for line,S in enumerate(filepointer):
     169                self.errors = '  Error reading line '+str(line+1)
     170                if self.Super == 0:
     171                    h,k,l,Fo,sigFo,Tw = S[:4],S[4:8],S[8:12],S[12:20],S[20:28],S[28:32]
     172                    h,k,l = [int(h),int(k),int(l)]
     173                elif self.Super == 1:
     174                    h,k,l,m1,Fo,sigFo,Tw = S[:4],S[4:8],S[8:12],S[12:16],S[16:24],S[24:32],S[32:36]
     175                    h,k,l,m1 = [int(h),int(k),int(l),int(m1)]
     176                Tw = Tw.strip()
     177                if not any([h,k,l]):
     178                    break
     179                if Tw not in ['','0','1']:
     180                    TwId = -int(Tw)-1
     181                    TwMax = max(TwMax,TwId)
     182                    TwSet[TwId] = [h,k,l]
     183                else:
     184                    if TwSet:
     185                        TwDict[len(self.RefDict['RefList'])] = TwSet
     186                        TwSet = {}   
     187                    Fo = float(Fo)
     188                    sigFo = float(sigFo)
     189                    # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
     190                    if self.Super == 0:
     191                        self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0])
     192                    elif self.Super == 1:
     193                        self.RefDict['RefList'].append([h,k,l,m1,0,0,Fo,sigFo,0,Fo,0,0,0])
     194            self.errors = 'Error after reading reflections (unexpected!)'
     195            self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
     196            self.RefDict['Type'] = 'SXC'
     197            self.RefDict['Super'] = self.Super
     198            self.RefDict['TwDict'] = TwDict
     199            self.RefDict['TwMax'] = TwMax
     200            self.UpdateParameters(Type='SXC',Wave=None) # histogram type
     201            return True
     202        except Exception as detail:
     203            self.errors += '\n  '+str(detail)
     204            print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
     205            import traceback
     206            traceback.print_exc(file=sys.stdout)
     207            return False
     208
    134209class M90_ReaderClass(G2IO.ImportStructFactor):
    135210    'Routines to import F**2, sig(F**2) reflections from a JANA M90 file'
     
    204279            return False
    205280           
    206 class SHELX5_ReaderClass(G2IO.ImportStructFactor):
    207     'Routines to import F**2, sig(F**2) twin index reflections from a fixed format SHELX HKLF5 file'
    208     def __init__(self):
    209         if 'linux' in sys.platform:  # wx 3.0.0.0 on gtk does not like Unicode in menus
    210             formatName = 'SHELX HKLF 5 F2'
    211             longFormatName = 'SHELX HKLF 5 [hklm, Fo2, sig(Fo2), Tind] Structure factor text file'
    212         else:
    213             formatName = u'SHELX HKLF 5 F\u00b2'
    214             longFormatName = u'SHELX HKLF 5 [hklm, Fo\u00b2, sig(Fo\u00b2), Tind] Structure factor text file'       
    215         super(self.__class__,self).__init__( # fancy way to self-reference
    216             extensionlist=('.hkl','.HKL'),
    217             strictExtension=False,
    218             formatName=formatName,
    219             longFormatName=longFormatName)
    220         self.Super = 0
    221 
    222     def ContentsValidator(self, filepointer):
    223         'Discover how many characters are in the SHELX file - could be 32-44 depending on satellites'
    224         numCols = 0
    225         for i,line in enumerate(filepointer):
    226             numCols = max(numCols,len(line.split()))
    227             if i > 20:
    228                 break
    229         self.Super = numCols-6     #= 0,1,2,or 3
    230         if self.Super > 1:
    231             raise self.ImportException("Supersymmetry too high; GSAS-II limited to (3+1) supersymmetry")           
    232         return True #ColumnValidator(self, filepointer)
    233 
    234     def Reader(self,filename,filepointer, ParentFrame=None, **unused):
    235         'Read the file'
    236         try:
    237             for line,S in enumerate(filepointer):
    238                 self.errors = '  Error reading line '+str(line+1)
    239                 if self.Super == 0:
    240                     h,k,l,Fo,sigFo,Tw = S[:4],S[4:8],S[8:12],S[12:20],S[20:28],S[28:32]
    241                     h,k,l = [int(h),int(k),int(l)]
    242                 elif self.Super == 1:
    243                     h,k,l,m1,Fo,sigFo,Tw = S[:4],S[4:8],S[8:12],S[12:16],S[16:24],S[24:32],S[32:36]
    244                     h,k,l,m1 = [int(h),int(k),int(l),int(m1)]
    245                 if not any([h,k,l]):
    246                     break
    247                 Fo = float(Fo)
    248                 sigFo = float(sigFo)
    249                 # h,k,l,m,dsp,Fo2,sig,Fc2,Fot2,Fct2,phase,...
    250                 if self.Super == 0:
    251                     self.RefDict['RefList'].append([h,k,l,0,0,Fo,sigFo,0,Fo,0,0,0])
    252                 elif self.Super == 1:
    253                     self.RefDict['RefList'].append([h,k,l,m1,0,0,Fo,sigFo,0,Fo,0,0,0])
    254                 #self.RefDict['FF'].append({}) # now done in OnImportSfact
    255             self.errors = 'Error after reading reflections (unexpected!)'
    256             self.RefDict['RefList'] = np.array(self.RefDict['RefList'])
    257             self.RefDict['Type'] = 'SXC'
    258             self.RefDict['Super'] = self.Super
    259             self.UpdateParameters(Type='SXC',Wave=None) # histogram type
    260             return True
    261         except Exception as detail:
    262             self.errors += '\n  '+str(detail)
    263             print '\n\n'+self.formatName+' read error: '+str(detail) # for testing
    264             import traceback
    265             traceback.print_exc(file=sys.stdout)
    266             return False
    267 
    268281class NT_HKLF2_ReaderClass(G2IO.ImportStructFactor):
    269282    'Routines to import neutron TOF F**2, sig(F**2) reflections from a HKLF file'
Note: See TracChangeset for help on using the changeset viewer.