Changeset 384


Ignore:
Timestamp:
Oct 7, 2011 1:12:38 PM (10 years ago)
Author:
vondreele
Message:

add constraint & restraint items to tree - now empty
fix noncentro calcs & special position position refinements

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r380 r384  
    545545            sub = self.PatternTree.AppendItem(parent=self.root,text='Notebook')
    546546            self.PatternTree.SetItemPyData(sub,[''])
     547        if not G2gd.GetPatternTreeItemId(self,self.root,'Controls'):
    547548            sub = self.PatternTree.AppendItem(parent=self.root,text='Controls')
    548549            self.PatternTree.SetItemPyData(sub,{})
     550        if not G2gd.GetPatternTreeItemId(self,self.root,'Covariance'):
    549551            sub = self.PatternTree.AppendItem(parent=self.root,text='Covariance')
     552            self.PatternTree.SetItemPyData(sub,{})
     553        if not G2gd.GetPatternTreeItemId(self,self.root,'Constraints'):
     554            sub = self.PatternTree.AppendItem(parent=self.root,text='Constraints')
     555            self.PatternTree.SetItemPyData(sub,{})
     556        if not G2gd.GetPatternTreeItemId(self,self.root,'Restraints'):
     557            sub = self.PatternTree.AppendItem(parent=self.root,text='Restraints')
    550558            self.PatternTree.SetItemPyData(sub,{})
    551559           
     
    10521060                    self.dirname = dlg.GetDirectory()
    10531061                    G2IO.ProjFileOpen(self)
    1054                     #patch
    1055                     if not G2gd.GetPatternTreeItemId(self,self.root,'Covariance'):
    1056                         sub = self.PatternTree.AppendItem(parent=self.root,text='Covariance')
    1057                         self.PatternTree.SetItemPyData(sub,{})
    1058                     #end patch
    10591062                    self.PatternTree.SetItemText(self.root,'Loaded Data: '+self.GSASprojectfile)
    10601063                    self.PatternTree.Expand(self.root)
     
    10731076                    if Id:
    10741077                        self.PatternTree.SelectItem(Id)
     1078                    self.CheckNotebook()
    10751079            finally:
    10761080                dlg.Destroy()
     1081
    10771082
    10781083    def OnFileClose(self, event):
  • trunk/GSASIIIO.py

    r348 r384  
    882882            self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,Id,'Index Peak List'),[])
    883883            self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,Id,'Unit Cells List'),[])             
     884            self.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(self,Id,'Reflection Lists'),{})             
    884885        else:
    885886            Id = self.PatternTree.AppendItem(parent=self.root,text=name+" Azm= %.2f"%(azm))
     
    892893            self.PatternTree.SetItemPyData(self.PatternTree.AppendItem(Id,text='Index Peak List'),[])
    893894            self.PatternTree.SetItemPyData(self.PatternTree.AppendItem(Id,text='Unit Cells List'),[])
     895            self.PatternTree.SetItemPyData(self.PatternTree.AppendItem(Id,text='Reflection Lists'),{})             
    894896        self.PatternTree.SetItemPyData(Id,[[''],[np.array(X),np.array(Y),np.array(W),np.zeros(N),np.zeros(N),np.zeros(N)]])
    895897    self.PatternTree.SelectItem(Id)
  • trunk/GSASIIgrid.py

    r383 r384  
    5252] = [wx.NewId() for _init_coll_INDEX_Items in range(4)]
    5353
     54[ wxID_CONSTRAINTADD,
     55] = [wx.NewId() for _init_coll_Constraint_Items in range(1)]
     56
     57[ wxID_RESTRAINTADD,
     58] = [wx.NewId() for _init_coll_Restraint_Items in range(1)]
     59
    5460[ wxID_SELECTPHASE,
    5561] = [wx.NewId() for _init_coll_Refl_Items in range(1)]
     
    7076    def _init_coll_AtomsMenu(self,parent):
    7177        parent.Append(menu=self.AtomEdit, title='Edit')
     78       
     79    def _init_coll_ConstraintMenu(self,parent):
     80        parent.Append(menu=self.ConstraintEdit, title='Edit')
     81       
     82    def _init_coll_RestraintMenu(self,parent):
     83        parent.Append(menu=self.RestraintEdit, title='Edit')
    7284       
    7385    def _init_coll_DataMenu(self,parent):
     
    127139            help='Reload atom drawing list')
    128140           
     141    def _init_coll_Constraint_Items(self,parent):
     142        parent.Append(id=wxID_CONSTRAINTADD, kind=wx.ITEM_NORMAL,text='Add constraint',
     143            help='constraint dummy menu item')
     144       
     145    def _init_coll_Restraint_Items(self,parent):
     146        parent.Append(id=wxID_RESTRAINTADD, kind=wx.ITEM_NORMAL,text='Add restraint',
     147            help='restraint dummy menu item')
     148                   
    129149    def _init_coll_Data_Items(self,parent):
    130150        parent.Append(id=wxID_PWDRADD, kind=wx.ITEM_NORMAL,text='Add powder histograms',
     
    253273       
    254274        self.AtomsMenu = wx.MenuBar()
     275        self.ConstraintMenu = wx.MenuBar()
     276        self.RestraintMenu = wx.MenuBar()
    255277        self.DataMenu = wx.MenuBar()
    256278        self.TextureMenu = wx.MenuBar()
     
    266288        self.PDFMenu = wx.MenuBar()
    267289        self.AtomEdit = wx.Menu(title='')
     290        self.ConstraintEdit = wx.Menu(title='')
     291        self.RestraintEdit = wx.Menu(title='')
    268292        self.DataEdit = wx.Menu(title='')
    269293        self.TextureEdit = wx.Menu(title='')
     
    280304        self._init_coll_AtomsMenu(self.AtomsMenu)
    281305        self._init_coll_Atom_Items(self.AtomEdit)
     306        self._init_coll_ConstraintMenu(self.ConstraintMenu)
     307        self._init_coll_Constraint_Items(self.ConstraintEdit)
     308        self._init_coll_RestraintMenu(self.RestraintMenu)
     309        self._init_coll_Restraint_Items(self.RestraintEdit)
    282310        self._init_coll_DataMenu(self.DataMenu)
    283311        self._init_coll_Data_Items(self.DataEdit)
     
    600628        else:
    601629            self.dataDisplay.AppendText(line+'\n')
     630           
     631def UpdateConstraints(self,data):
     632   
     633   
     634    if self.dataDisplay:
     635        self.dataDisplay.Destroy()
     636    self.dataFrame.SetLabel('Constraints')
     637    self.dataDisplay = wx.Panel(self.dataFrame)
     638    self.dataFrame.SetMenuBar(self.dataFrame.ConstraintMenu)
     639    mainSizer = wx.BoxSizer(wx.VERTICAL)
     640    mainSizer.Add((5,5),0)
     641    mainSizer.Add(wx.StaticText(self.dataDisplay,label=' Refinement constraints:'),0,wx.ALIGN_CENTER_VERTICAL)
     642   
     643   
     644    mainSizer.Layout()   
     645    self.dataDisplay.SetSizer(mainSizer)
     646    self.dataDisplay.SetSize(mainSizer.Fit(self.dataFrame))
     647    self.dataFrame.setSizePosLeft(mainSizer.Fit(self.dataFrame))
     648   
     649   
     650def UpdateRestraints(self,data):
     651
     652
     653    if self.dataDisplay:
     654        self.dataDisplay.Destroy()
     655    self.dataFrame.SetLabel('Restraints')
     656    self.dataDisplay = wx.Panel(self.dataFrame)
     657    self.dataFrame.SetMenuBar(self.dataFrame.RestraintMenu)
     658    mainSizer = wx.BoxSizer(wx.VERTICAL)
     659    mainSizer.Add((5,5),0)
     660    mainSizer.Add(wx.StaticText(self.dataDisplay,label=' Refinement restraints:'),0,wx.ALIGN_CENTER_VERTICAL)
     661   
     662   
     663    mainSizer.Layout()   
     664    self.dataDisplay.SetSizer(mainSizer)
     665    self.dataDisplay.SetSize(mainSizer.Fit(self.dataFrame))
     666    self.dataFrame.setSizePosLeft(mainSizer.Fit(self.dataFrame))
    602667             
    603668def UpdateHKLControls(self,data):
     
    713778            self.dataDisplay.Clear()
    714779            Id = GetPatternTreeItemId(self,self.root, 'Notebook')
    715             if Id: self.PatternTree.SetItemPyData(Id,data)
    716         if self.dataFrame.GetLabel() == 'Covariance':
    717             data = [self.dataDisplay.GetValue()]
    718             self.dataDisplay.Clear()
    719             Id = GetPatternTreeItemId(self,self.root, 'Covariance')
    720780            if Id: self.PatternTree.SetItemPyData(Id,data)
    721781        if 'Phase Data for' in self.dataFrame.GetLabel():
     
    760820            data = self.PatternTree.GetItemPyData(item)
    761821            G2plt.PlotCovariance(self)
     822        elif self.PatternTree.GetItemText(item) == 'Constraints':
     823            data = self.PatternTree.GetItemPyData(item)
     824            UpdateConstraints(self,data)
     825        elif self.PatternTree.GetItemText(item) == 'Restraints':
     826            data = self.PatternTree.GetItemPyData(item)
     827            UpdateRestraints(self,data)
    762828        elif 'IMG' in self.PatternTree.GetItemText(item):
    763829            self.Image = item
  • trunk/GSASIIlattice.py

    r380 r384  
    233233    Convert Uij to beta-ij tensors
    234234    input:
    235     Uij - numpy array [Uij]
    236     G - reciprocal metric tensor
     235        Uij - numpy array [Uij]
     236        G - reciprocal metric tensor
    237237    returns:
    238238    beta-ij - numpy array [beta-ij]
     
    11311131]),
    11321132]
     1133    global LaueTestData             #generated by GSAS
     1134    LaueTestData = {
     1135    'R 3 m':[(4.,4.,6.,90.,90.,120.),((1,0,1,6),(1,0,-2,6),(0,0,3,2),(1,1,0,6),(2,0,-1,6),(2,0,2,6),
     1136        (1,1,3,12),(1,0,4,6),(2,1,1,12),(2,1,-2,12),(3,0,0,6),(1,0,-5,6),(2,0,-4,6),(3,0,-3,6),(3,0,3,6),
     1137        (0,0,6,2),(2,2,0,6),(2,1,4,12),(2,0,5,6),(3,1,-1,12),(3,1,2,12),(1,1,6,12),(2,2,3,12),(2,1,-5,12))],
     1138    'R 3':[(4.,4.,6.,90.,90.,120.),((1,0,1,6),(1,0,-2,6),(0,0,3,2),(1,1,0,6),(2,0,-1,6),(2,0,2,6),(1,1,3,6),
     1139        (1,1,-3,6),(1,0,4,6),(3,-1,1,6),(2,1,1,6),(3,-1,-2,6),(2,1,-2,6),(3,0,0,6),(1,0,-5,6),(2,0,-4,6),
     1140        (2,2,0,6),(3,0,3,6),(3,0,-3,6),(0,0,6,2),(3,-1,4,6),(2,0,5,6),(2,1,4,6),(4,-1,-1,6),(3,1,-1,6),
     1141        (3,1,2,6),(4,-1,2,6),(2,2,-3,6),(1,1,-6,6),(1,1,6,6),(2,2,3,6),(2,1,-5,6),(3,-1,-5,6))],
     1142    'P 3':[(4.,4.,6.,90.,90.,120.),((0,0,1,2),(1,0,0,6),(1,0,1,6),(0,0,2,2),(1,0,-1,6),(1,0,2,6),(1,0,-2,6),
     1143        (1,1,0,6),(0,0,3,2),(1,1,1,6),(1,1,-1,6),(1,0,3,6),(1,0,-3,6),(2,0,0,6),(2,0,-1,6),(1,1,-2,6),
     1144        (1,1,2,6),(2,0,1,6),(2,0,-2,6),(2,0,2,6),(0,0,4,2),(1,1,-3,6),(1,1,3,6),(1,0,-4,6),(1,0,4,6),
     1145        (2,0,-3,6),(2,1,0,6),(2,0,3,6),(3,-1,0,6),(2,1,1,6),(3,-1,-1,6),(2,1,-1,6),(3,-1,1,6),(1,1,4,6),
     1146        (3,-1,2,6),(3,-1,-2,6),(1,1,-4,6),(0,0,5,2),(2,1,2,6),(2,1,-2,6),(3,0,0,6),(3,0,1,6),(2,0,4,6),
     1147        (2,0,-4,6),(3,0,-1,6),(1,0,-5,6),(1,0,5,6),(3,-1,-3,6),(2,1,-3,6),(2,1,3,6),(3,-1,3,6),(3,0,-2,6),
     1148        (3,0,2,6),(1,1,5,6),(1,1,-5,6),(2,2,0,6),(3,0,3,6),(3,0,-3,6),(0,0,6,2),(2,0,-5,6),(2,1,-4,6),
     1149        (2,2,-1,6),(3,-1,-4,6),(2,2,1,6),(3,-1,4,6),(2,1,4,6),(2,0,5,6),(1,0,-6,6),(1,0,6,6),(4,-1,0,6),
     1150        (3,1,0,6),(3,1,-1,6),(3,1,1,6),(4,-1,-1,6),(2,2,2,6),(4,-1,1,6),(2,2,-2,6),(3,1,2,6),(3,1,-2,6),
     1151        (3,0,4,6),(3,0,-4,6),(4,-1,-2,6),(4,-1,2,6),(2,2,-3,6),(1,1,6,6),(1,1,-6,6),(2,2,3,6),(3,-1,5,6),
     1152        (2,1,5,6),(2,1,-5,6),(3,-1,-5,6))],
     1153    'P 3 m 1':[(4.,4.,6.,90.,90.,120.),((0,0,1,2),(1,0,0,6),(1,0,-1,6),(1,0,1,6),(0,0,2,2),(1,0,-2,6),
     1154        (1,0,2,6),(1,1,0,6),(0,0,3,2),(1,1,1,12),(1,0,-3,6),(1,0,3,6),(2,0,0,6),(1,1,2,12),(2,0,1,6),
     1155        (2,0,-1,6),(0,0,4,2),(2,0,-2,6),(2,0,2,6),(1,1,3,12),(1,0,-4,6),(1,0,4,6),(2,0,3,6),(2,1,0,12),
     1156        (2,0,-3,6),(2,1,1,12),(2,1,-1,12),(1,1,4,12),(2,1,2,12),(0,0,5,2),(2,1,-2,12),(3,0,0,6),(1,0,-5,6),
     1157        (3,0,1,6),(3,0,-1,6),(1,0,5,6),(2,0,4,6),(2,0,-4,6),(2,1,3,12),(2,1,-3,12),(3,0,-2,6),(3,0,2,6),
     1158        (1,1,5,12),(3,0,-3,6),(0,0,6,2),(2,2,0,6),(3,0,3,6),(2,1,4,12),(2,2,1,12),(2,0,5,6),(2,1,-4,12),
     1159        (2,0,-5,6),(1,0,-6,6),(1,0,6,6),(3,1,0,12),(3,1,-1,12),(3,1,1,12),(2,2,2,12),(3,1,2,12),
     1160        (3,0,4,6),(3,1,-2,12),(3,0,-4,6),(1,1,6,12),(2,2,3,12))],
     1161    'P 3 1 m':[(4.,4.,6.,90.,90.,120.),((0,0,1,2),(1,0,0,6),(0,0,2,2),(1,0,1,12),(1,0,2,12),(1,1,0,6),
     1162        (0,0,3,2),(1,1,-1,6),(1,1,1,6),(1,0,3,12),(2,0,0,6),(2,0,1,12),(1,1,2,6),(1,1,-2,6),(2,0,2,12),
     1163        (0,0,4,2),(1,1,-3,6),(1,1,3,6),(1,0,4,12),(2,1,0,12),(2,0,3,12),(2,1,1,12),(2,1,-1,12),(1,1,-4,6),
     1164        (1,1,4,6),(0,0,5,2),(2,1,-2,12),(2,1,2,12),(3,0,0,6),(1,0,5,12),(2,0,4,12),(3,0,1,12),(2,1,-3,12),
     1165        (2,1,3,12),(3,0,2,12),(1,1,5,6),(1,1,-5,6),(3,0,3,12),(0,0,6,2),(2,2,0,6),(2,1,-4,12),(2,0,5,12),
     1166        (2,2,-1,6),(2,2,1,6),(2,1,4,12),(3,1,0,12),(1,0,6,12),(2,2,2,6),(3,1,-1,12),(2,2,-2,6),(3,1,1,12),
     1167        (3,1,-2,12),(3,0,4,12),(3,1,2,12),(1,1,-6,6),(2,2,3,6),(2,2,-3,6),(1,1,6,6))],
     1168    }
     1169   
    11331170    global FLnhTestData
    11341171    FLnhTestData = [{
     
    13151352            #for hkllist,dref in sgtbxlattinp.sgtbx8[key][1]: print '  ',hkllist,dref
    13161353            #print center, Laue, Axis, system
     1354           
     1355def test9():
     1356    import GSASIIspc as G2spc
     1357    if NeedTestData: TestData()
     1358    for spc in LaueTestData:
     1359        data = LaueTestData[spc]
     1360        cell = data[0]
     1361        hklm = np.array(data[1])
     1362        H = hklm[-1][:3]
     1363        hklO = hklm.T[:3].T
     1364        A = cell2A(cell)
     1365        dmin = 1./np.sqrt(calc_rDsq(H,A))
     1366        SGData = G2spc.SpcGroup(spc)[1]
     1367        hkls = np.array(GenHLaue(dmin,SGData,A))
     1368        hklN = hkls.T[:3].T
     1369        print spc,hklO.shape,hklN.shape
     1370        for H in hklO:
     1371            if H not in hklN:
     1372                print H,' missing from hkl from GSASII'
     1373       
     1374       
     1375   
    13171376
    13181377if __name__ == '__main__':
  • trunk/GSASIIstruct.py

    r383 r384  
    12561256    bij = Mast*Uij.T
    12571257    for refl in refList:
    1258         fb = [0,0]
     1258        fbs = np.array([0,0])
    12591259        H = refl[:3]
    12601260        SQ = 1./(2.*refl[4])**2
     
    12731273        Tcorr = Tiso*Tuij
    12741274        fa = np.array([(FF+FP)*occ*cosp*Tcorr,-FPP*occ*sinp*Tcorr])
    1275         fa = np.sum(np.sum(fa,axis=1),axis=1)        #real
     1275        fas = np.sum(np.sum(fa,axis=1),axis=1)        #real
    12761276        if not SGData['SGInv']:
    12771277            fb = np.array([(FF+FP)*occ*sinp*Tcorr,FPP*occ*cosp*Tcorr])
    1278             fb = np.sum(np.sum(fb,axis=1),axis=1)        #imaginary
    1279         refl[9] = fa[0]**2+fb[1]**2+fb[0]+fa[1]**2
    1280         refl[10] = atan2d(fb[0],fa[0])
     1278            fbs = np.sum(np.sum(fb,axis=1),axis=1)
     1279        fasq = fas**2
     1280        fbsq = fbs**2        #imaginary
     1281        refl[9] = np.sum(fasq)+np.sum(fbsq)
     1282        refl[10] = atan2d(fbs[0],fas[0])
    12811283    return refList
    12821284   
     
    13731375    ''' takes atom x,y,z shift and applies it to corresponding atom x,y,z value
    13741376    '''
    1375     for vary in varyList:
    1376         if 'dA' in vary:
    1377             parm = ''.join(vary.split('d'))
    1378             parmDict[parm] += parmDict[vary]
     1377    for item in parmDict:
     1378        if 'dA' in item:
     1379            parm = ''.join(item.split('d'))
     1380            parmDict[parm] += parmDict[item]
    13791381   
    13801382def SHPOcal(refl,g,phfx,hfx,SGData,calcControls,parmDict):
     
    19181920    def errRefine(values,HistoPhases,parmdict,varylist,calcControls,pawleyLookup,dlg):       
    19191921        parmdict.update(zip(varylist,values))
     1922        Values2Dict(parmdict, varylist, values)
    19201923        G2mv.Dict2Map(parmDict)
    19211924        Histograms,Phases = HistoPhases
     
    20062009        chisq = np.sum(result[2]['fvec']**2)
    20072010        Values2Dict(parmDict, varyList, result[0])
     2011        G2mv.Dict2Map(parmDict)
    20082012        ApplyXYZshifts(parmDict,varyList)
    2009         G2mv.Dict2Map(parmDict)
    20102013       
    20112014        Rwp = np.sqrt(chisq/Histograms['sumwYo'])*100.      #to %
Note: See TracChangeset for help on using the changeset viewer.