Changeset 3157


Ignore:
Timestamp:
Nov 21, 2017 1:52:20 PM (5 years ago)
Author:
vondreele
Message:

add Lorentzian term 'Z' to CW profile instrument parameters - constant term
change sig-q function to d*sig-q from sig-q/d2 for TOF profile instrument parameters
add filter to SumDialog? for PWDR & IMG data

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r3136 r3157  
    684684    Comments = G2frame.GPXtree.GetItemPyData(G2gd.GetGPXtreeItemId(G2frame,Id, 'Comments'))
    685685    if 'PWDR' in name:
    686         names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth']
    687         codes = [0 for i in range(11)]
     686        names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','Z','SH/L','Azimuth']
     687        codes = [0 for i in range(12)]
    688688    elif 'SASD' in name:
    689689        names = ['Type','Lam','Zero','Azimuth']
  • trunk/GSASIIdataGUI.py

    r3154 r3157  
    30103010       
    30113011    class SumDialog(wx.Dialog):
    3012         '''Allows user to supply scale factor(s) when summing data -
    3013         TODO: CAN WE PREVIEW RESULT HERE?'''
    3014         #TODO: also add filter box for selection of items
     3012        '''Allows user to supply scale factor(s) when summing data
     3013        '''
    30153014        def __init__(self,parent,title,text,dataType,data,dataList):
    30163015            wx.Dialog.__init__(self,parent,-1,title,size=(400,250),
     
    30193018                style=wx.DEFAULT_FRAME_STYLE ^ wx.CLOSE_BOX)
    30203019            self.G2plotNB = G2plt.G2PlotNoteBook(self.plotFrame,G2frame=self)
     3020            self.text = text
    30213021            self.data = data
     3022            self.selectData = copy.copy(data[:-1])
     3023            self.selectVals = len(data)*[0.0,]
    30223024            self.dataList = dataList
     3025            self.filterlist = range(len(self.dataList)) # list of the choice numbers that have been filtered (list of int indices)
    30233026            self.dataType = dataType
     3027            self.filter = ''
     3028            self.panel = None
     3029            self.Draw()
     3030           
     3031        def Draw(self):           
     3032            if self.panel:
     3033                self.panel.DestroyChildren()  #safe: wx.Panel
     3034                self.panel.Destroy()
    30243035            size = (450,350)
    3025             panel = wxscroll.ScrolledPanel(self, wx.ID_ANY,size=size,
     3036            self.panel = wxscroll.ScrolledPanel(self, wx.ID_ANY,size=size,
    30263037                style = wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER)
    30273038            mainSizer = wx.BoxSizer(wx.VERTICAL)
    3028             topLabl = wx.StaticText(panel,-1,text)
     3039            topSizer = wx.BoxSizer(wx.HORIZONTAL)
     3040            topSizer.Add(wx.StaticText(self.panel,label=self.text+'  Filter:  '),0,WACV)
     3041            self.filterBox = wx.TextCtrl(self.panel,value=self.filter,style=wx.TE_PROCESS_ENTER)
     3042            self.filterBox.Bind(wx.EVT_TEXT_ENTER,self.Filter)
     3043            topSizer.Add(self.filterBox,0,WACV)
    30293044            mainSizer.Add((10,10),1)
    3030             mainSizer.Add(topLabl,0,wx.ALIGN_CENTER_VERTICAL|wx.LEFT,10)
     3045            mainSizer.Add(topSizer,0,wx.ALIGN_CENTER_VERTICAL|wx.LEFT,10)
    30313046            mainSizer.Add((10,10),1)
    30323047            self.dataGridSizer = wx.FlexGridSizer(cols=2,hgap=2,vgap=2)
    3033             for id,item in enumerate(self.data[:-1]):
    3034                 name = wx.TextCtrl(panel,-1,item[1],size=wx.Size(300,20))
     3048            for id,item in enumerate(self.selectData):
     3049                name = wx.TextCtrl(self.panel,-1,item,size=wx.Size(300,20))
    30353050                name.SetEditable(False)
    30363051#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
    3037                 scale = wx.TextCtrl(panel,id,'%.3f'%(item[0]),style=wx.TE_PROCESS_ENTER)
     3052                scale = wx.TextCtrl(self.panel,id,'%.3f'%(self.selectVals[id]),style=wx.TE_PROCESS_ENTER)
    30383053                scale.Bind(wx.EVT_TEXT_ENTER,self.OnScaleChange)
    30393054                scale.Bind(wx.EVT_KILL_FOCUS,self.OnScaleChange)
     
    30413056                self.dataGridSizer.Add(name,0,wx.RIGHT,10)
    30423057            if self.dataType:
    3043                 self.dataGridSizer.Add(wx.StaticText(panel,-1,'Sum result name: '+self.dataType),0, \
     3058                self.dataGridSizer.Add(wx.StaticText(self.panel,-1,'Sum result name: '+self.dataType),0, \
    30443059                    wx.LEFT|wx.TOP|wx.ALIGN_CENTER_VERTICAL,10)
    3045                 self.name = wx.TextCtrl(panel,-1,self.data[-1],size=wx.Size(300,20),style=wx.TE_PROCESS_ENTER)
     3060                self.name = wx.TextCtrl(self.panel,-1,self.data[-1],size=wx.Size(300,20),style=wx.TE_PROCESS_ENTER)
    30463061                self.name.Bind(wx.EVT_TEXT_ENTER,self.OnNameChange)
    30473062                self.name.Bind(wx.EVT_KILL_FOCUS,self.OnNameChange)
    30483063                self.dataGridSizer.Add(self.name,0,wx.RIGHT|wx.TOP,10)
    3049                 self.dataGridSizer.Add(wx.StaticText(panel,label='All scales value: '),0,  \
     3064                self.dataGridSizer.Add(wx.StaticText(self.panel,label='All scales value: '),0,  \
    30503065                    wx.LEFT|wx.TOP|wx.ALIGN_CENTER_VERTICAL,10)
    30513066#        azmthOff = G2G.ValidatedTxtCtrl(G2frame.dataDisplay,data,'azmthOff',nDig=(10,2),typeHint=float,OnLeave=OnAzmthOff)
    3052                 allScale = wx.TextCtrl(panel,value='',style=wx.TE_PROCESS_ENTER)
     3067                allScale = wx.TextCtrl(self.panel,value='',style=wx.TE_PROCESS_ENTER)
    30533068                allScale.Bind(wx.EVT_TEXT_ENTER,self.OnAllScale)
    30543069                allScale.Bind(wx.EVT_KILL_FOCUS,self.OnAllScale)
    30553070                self.dataGridSizer.Add(allScale,0,WACV)
    30563071            mainSizer.Add(self.dataGridSizer,0,wx.EXPAND)
    3057             OkBtn = wx.Button(panel,-1,"Ok")
    3058             OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
    3059             cancelBtn = wx.Button(panel,-1,"Cancel")
     3072            self.OkBtn = wx.Button(self.panel,-1,"Ok")
     3073            self.OkBtn.Bind(wx.EVT_BUTTON, self.OnOk)
     3074            cancelBtn = wx.Button(self.panel,-1,"Cancel")
    30603075            cancelBtn.Bind(wx.EVT_BUTTON, self.OnCancel)
    30613076            btnSizer = wx.FlexGridSizer(0,3,10,20)
    30623077            if self.dataType =='PWDR':
    3063                 TestBtn = wx.Button(panel,-1,"Test")
     3078                TestBtn = wx.Button(self.panel,-1,"Test")
    30643079                TestBtn.Bind(wx.EVT_BUTTON, self.OnTest)
    30653080                btnSizer.Add(TestBtn)
    3066             btnSizer.Add(OkBtn)
     3081            btnSizer.Add(self.OkBtn)
    30673082            btnSizer.Add(cancelBtn)
    30683083           
    3069             panel.SetSizer(mainSizer)
    3070             panel.SetAutoLayout(1)
    3071             panel.SetupScrolling()
     3084            self.panel.SetSizer(mainSizer)
     3085            self.panel.SetAutoLayout(1)
     3086            self.panel.SetupScrolling()
    30723087            mainSizer.Add((10,10),1)
    30733088            mainSizer.Add(btnSizer,0,wx.CENTER)
    3074             panel.SetSizer(mainSizer)
    3075             panel.Fit()
     3089            self.panel.SetSizer(mainSizer)
     3090            self.panel.Fit()
    30763091            self.Fit()
     3092
     3093        def Filter(self,event):
     3094            '''Read text from filter control and select entries that match.
     3095            '''
     3096            txt = self.filterBox.GetValue()
     3097            if txt:
     3098                txt = txt.lower()
     3099                ChoiceList = []
     3100                ChoiceVals = []
     3101                for i,item in enumerate(self.selectData):
     3102                    if item.lower().find(txt) != -1:
     3103                        ChoiceList.append(item)
     3104                        ChoiceVals.append(self.selectVals[i])
     3105                self.selectData = ChoiceList
     3106                self.selectVals = ChoiceVals
     3107            else:
     3108                self.selectData = copy.copy(self.data[:-1])
     3109                self.selectVals = len(self.data)*[0.0,]
     3110            self.Draw()
    30773111
    30783112        def OnScaleChange(self,event):
     
    30813115            value = self.FindWindowById(id).GetValue()
    30823116            try:
    3083                 self.data[id][0] = float(value)
    3084                 self.FindWindowById(id).SetValue('%.3f'%(self.data[id][0]))
     3117                self.selectVals[id] = float(value)
     3118                self.FindWindowById(id).SetValue('%.3f'%(self.selectVals[id]))
    30853119            except ValueError:
    30863120                if value and '-' not in value[0]:
     
    30953129                self.FindWindowById(id).SetValue('%.3f'%(scale))
    30963130                entries = self.dataGridSizer.GetChildren()
    3097                 for i,item in enumerate(self.data[:-1]):
    3098                     item[0] = scale
    3099                     entries[2*i].GetWindow().SetValue('%.3f'%(scale))
    3100                  
     3131                for i,item in enumerate(self.selectVals):
     3132                    self.selectVals[i] = scale
     3133                    entries[2*i].GetWindow().SetValue('%.3f'%(self.selectVals[i]))                 
    31013134            except ValueError:
    31023135                print ('bad input - numbers only')
    31033136                self.FindWindowById(id).SetValue('')
    3104                    
    31053137           
    31063138        def OnNameChange(self,event):
     
    31153147            Ysum = []
    31163148            Vsum = []
    3117             result = self.data
    3118             for i,item in enumerate(result[:-1]):
    3119                 scale,name = item
    3120                 data = self.dataList[i]
     3149            for i,item in enumerate(self.selectData):
     3150                name = item
     3151                scale = self.selectVals[i]
     3152                id = self.data.index(name)
     3153                data = self.dataList[id]
    31213154                if scale:
    31223155                    x,y,w,yc,yb,yd = data   #numpy arrays!
     
    31723205        def GetData(self):
    31733206            if self.dataType == 'PWDR':
    3174                 return self.data,self.result
     3207                return self.selectData+[self.data[-1],],self.result
    31753208            else:
    3176                 return self.data
     3209                return self.selectData+[self.data[-1],],self.selectVals
    31773210                       
    31783211    def OnPwdrSum(self,event):
     
    31893222                Names.append(name)
    31903223                if 'PWDR' in name:
    3191                     TextList.append([0.0,name])
     3224                    TextList.append(name)
    31923225                    DataList.append(self.GPXtree.GetItemPyData(item)[1])    # (x,y,w,yc,yb,yd)
    31933226                    if not Inst:
     
    32563289                Names.append(name)
    32573290                if 'IMG' in name:
    3258                     TextList.append([0.0,name])
     3291                    TextList.append(name)
    32593292                    DataList.append(self.GPXtree.GetImageLoc(item))        #Size,Image,Tag
    32603293                    IdList.append(item)
     
    32693302                if dlg.ShowModal() == wx.ID_OK:
    32703303                    imSize = 0
    3271                     result = dlg.GetData()
     3304                    result,scales = dlg.GetData()
    32723305                    First = True
    32733306                    Found = False
    3274                     for i,item in enumerate(result[:-1]):
    3275                         scale,name = item
     3307                    for i,name in enumerate(result[:-1]):
     3308                        scale = scales[i]
    32763309                        if scale:
    32773310                            Found = True                               
  • trunk/GSASIIfiles.py

    r3136 r3157  
    9191             sfloat(s[20:30])/100.,sfloat(s[55:65]),sfloat(s[40:50])) #get lam1, lam2, zero, pola & ratio
    9292        if not v[1]:
    93             names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','SH/L','Azimuth']
     93            names = ['Type','Lam','Zero','Polariz.','U','V','W','X','Y','Z','SH/L','Azimuth']
    9494            v = (v[0],v[2],v[4])
    95             codes = [0,0,0,0]
     95            codes = [0,0,0,0,0]
    9696            rd.Sample.update({'Type':'Debye-Scherrer','Absorption':[0.,False],'DisplaceX':[0.,False],'DisplaceY':[0.,False]})
    9797        else:
    98             names = ['Type','Lam1','Lam2','Zero','I(L2)/I(L1)','Polariz.','U','V','W','X','Y','SH/L','Azimuth']
    99             codes = [0,0,0,0,0,0]
     98            names = ['Type','Lam1','Lam2','Zero','I(L2)/I(L1)','Polariz.','U','V','W','X','Y','Z','SH/L','Azimuth']
     99            codes = [0,0,0,0,0,0,0]
    100100            rd.Sample.update({'Type':'Bragg-Brentano','Shift':[0.,False],'Transparency':[0.,False],
    101101                'SurfRoughA':[0.,False],'SurfRoughB':[0.,False]})
     
    108108            v = Iparm['INS  1PRCF 2'].split()
    109109            if v1[0] == 3:
    110                 data.extend([float(v[0]),float(v[1]),float(v[2])+float(v[3],azm)])  #get LX, LY, S+H/L & azimuth
     110                data.extend([float(v[0]),float(v[1]),0.0,float(v[2])+float(v[3],azm)])  #get LX, LY, Z, S+H/L & azimuth
    111111            else:
    112                 data.extend([0.0,0.0,0.002,azm])                                      #OK defaults if fxn #3 not 1st in iprm file
     112                data.extend([0.0,0.0,0.0,0.002,azm])                                      #OK defaults if fxn #3 not 1st in iprm file
    113113        else:
    114114            v1 = Iparm['INS  1PRCF1 '].split()
     
    118118            v = Iparm['INS  1PRCF12'].split()
    119119            if v1[0] == 3:
    120                 data.extend([float(v[0]),float(v[1]),float(v[2])+float(v[3],azm)])  #get LX, LY, S+H/L & azimuth
     120                data.extend([float(v[0]),float(v[1]),0.0,float(v[2])+float(v[3],azm)])  #get LX, LY, Z, S+H/L & azimuth
    121121            else:
    122                 data.extend([0.0,0.0,0.002,azm])                                      #OK defaults if fxn #3 not 1st in iprm file
     122                data.extend([0.0,0.0,0.0,0.002,azm])                                      #OK defaults if fxn #3 not 1st in iprm file
    123123        codes.extend([0,0,0,0,0,0,0])
    124124        Iparm1 = makeInstDict(names,data,codes)
     
    128128    elif 'T' in DataType:
    129129        names = ['Type','fltPath','2-theta','difC','difA', 'difB','Zero','alpha','beta-0','beta-1',
    130             'beta-q','sig-0','sig-1','sig-2','sig-q', 'X','Y','Azimuth',]
    131         codes = [0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,]
     130            'beta-q','sig-0','sig-1','sig-2','sig-q', 'X','Y','Z','Azimuth',]
     131        codes = [0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,]
    132132        azm = 0.
    133133        if 'INS  1DETAZM' in Iparm:
     
    153153                data.extend([sfloat(s[1]),sfloat(s[2]),sfloat(s[3])]) #alpha, beta-0, beta-1
    154154                s = Iparm['INS  1PRCF 2'].split()
    155                 data.extend([0.0,0.0,sfloat(s[1]),sfloat(s[2]),0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     155                data.extend([0.0,0.0,sfloat(s[1]),sfloat(s[2]),0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    156156            elif abs(pfType) in [3,4,5]:
    157157                data.extend([sfloat(s[0]),sfloat(s[1]),sfloat(s[2])]) #alpha, beta-0, beta-1
    158158                if abs(pfType) == 4:
    159                     data.extend([0.0,0.0,sfloat(s[3]),0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     159                    data.extend([0.0,0.0,sfloat(s[3]),0.0,0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    160160                else:
    161161                    s = Iparm['INS  1PRCF 2'].split()
    162                     data.extend([0.0,0.0,sfloat(s[0]),sfloat(s[1]),0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     162                    data.extend([0.0,0.0,sfloat(s[0]),sfloat(s[1]),0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    163163            elif abs(pfType) == 2:
    164164                data.extend([sfloat(s[1]),0.0,1./sfloat(s[3])]) #alpha, beta-0, beta-1
    165                 data.extend([0.0,0.0,sfloat(s[1]),0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     165                data.extend([0.0,0.0,sfloat(s[1]),0.0,0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    166166        else:
    167167            s = Iparm['INS  1PRCF1 '].split()
     
    171171                data.extend([sfloat(s[1]),sfloat(s[2]),sfloat(s[3])]) #alpha, beta-0, beta-1
    172172                s = Iparm['INS  1PRCF12'].split()
    173                 data.extend([0.0,0.0,sfloat(s[1]),sfloat(s[2]),0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     173                data.extend([0.0,0.0,sfloat(s[1]),sfloat(s[2]),0.0,0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    174174            elif abs(pfType) in [3,4,5]:
    175175                data.extend([sfloat(s[0]),sfloat(s[1]),sfloat(s[2])]) #alpha, beta-0, beta-1
    176176                if abs(pfType) == 4:
    177                     data.extend([0.0,0.0,sfloat(s[3]),0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     177                    data.extend([0.0,0.0,sfloat(s[3]),0.0,0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    178178                else:
    179179                    s = Iparm['INS  1PRCF12'].split()
    180                     data.extend([0.0,0.0,sfloat(s[0]),sfloat(s[1]),0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y
     180                    data.extend([0.0,0.0,sfloat(s[0]),sfloat(s[1]),0.0,0.0,0.0,0.0,azm])    #beta-q, sig-0, sig-1, sig-2, sig-q, X, Y, Z
    181181        Inst1 = makeInstDict(names,data,codes)
    182182        Inst1['Bank'] = [Bank,Bank,0]
  • trunk/GSASIImath.py

    r3136 r3157  
    38113811    '''get CW peak profile gamma
    38123812   
    3813     :param dict ins: instrument parameters with at least 'X' & 'Y'
     3813    :param dict ins: instrument parameters with at least 'X', 'Y' & 'Z'
    38143814      as values only
    38153815    :param float pos: 2-theta of peak
     
    38173817   
    38183818    '''
    3819     return ins['X']/cosd(pos/2.0)+ins['Y']*tand(pos/2.0)
     3819    return ins['X']/cosd(pos/2.0)+ins['Y']*tand(pos/2.0)+ins['Z']
    38203820   
    38213821def getCWgamDeriv(pos):
    3822     '''get derivatives of CW peak profile gamma wrt X & Y
     3822    '''get derivatives of CW peak profile gamma wrt X, Y & Z
    38233823   
    38243824    :param float pos: 2-theta of peak
     
    38273827   
    38283828    '''
    3829     return 1./cosd(pos/2.0),tand(pos/2.0)
     3829    return 1./cosd(pos/2.0),tand(pos/2.0),1.0
    38303830   
    38313831def getTOFsig(ins,dsp):
     
    38393839   
    38403840    '''
    3841     return ins['sig-0']+ins['sig-1']*dsp**2+ins['sig-2']*dsp**4+ins['sig-q']/dsp**2
     3841    return ins['sig-0']+ins['sig-1']*dsp**2+ins['sig-2']*dsp**4+ins['sig-q']*dsp
    38423842   
    38433843def getTOFsigDeriv(dsp):
     
    38493849   
    38503850    '''
    3851     return 1.0,dsp**2,dsp**4,1./dsp**2
     3851    return 1.0,dsp**2,dsp**4,dsp
    38523852   
    38533853def getTOFgamma(ins,dsp):
    38543854    '''get TOF peak profile gamma
    38553855   
    3856     :param dict ins: instrument parameters with at least 'X' & 'Y'
     3856    :param dict ins: instrument parameters with at least 'X', 'Y' & 'Z'
    38573857      as values only
    38583858    :param float dsp: d-spacing of peak
     
    38613861   
    38623862    '''
    3863     return ins['X']*dsp+ins['Y']*dsp**2
     3863    return ins['Z']+ins['X']*dsp+ins['Y']*dsp**2
    38643864   
    38653865def getTOFgammaDeriv(dsp):
    3866     '''get derivatives of TOF peak profile gamma wrt X & Y
     3866    '''get derivatives of TOF peak profile gamma wrt X, Y & Z
    38673867   
    38683868    :param float dsp: d-spacing of peak
     
    38713871   
    38723872    '''
    3873     return dsp,dsp**2
     3873    return dsp,dsp**2,1.0
    38743874   
    38753875def getTOFbeta(ins,dsp):
     
    39373937        ind = 1
    39383938    ins = {}
    3939     if 'C' in Parms['Type'][0]:                            #CW data - TOF later in an elif
    3940         for x in ['U','V','W','X','Y']:
     3939    if 'C' in Parms['Type'][0]:                            #CW data - TOF later in an else
     3940        for x in ['U','V','W','X','Y','Z']:
    39413941            ins[x] = Parms[x][ind]
    39423942        if ifQ:                              #qplot - convert back to 2-theta
     
    39523952            dsp = pos/Parms['difC'][1]
    39533953        if 'Pdabc' in Parms2:
    3954             for x in ['sig-0','sig-1','sig-2','sig-q','X','Y']:
     3954            for x in ['sig-0','sig-1','sig-2','sig-q','X','Y','Z']:
    39553955                ins[x] = Parms[x][ind]
    39563956            Pdabc = Parms2['Pdabc'].T
     
    39583958            bet = np.interp(dsp,Pdabc[0],Pdabc[2])
    39593959        else:
    3960             for x in ['alpha','beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','X','Y']:
     3960            for x in ['alpha','beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','X','Y','Z']:
    39613961                ins[x] = Parms[x][ind]
    39623962            alp = getTOFalpha(ins,dsp)
  • trunk/GSASIIpwd.py

    r3136 r3157  
    656656   
    657657    sig = lambda Th,U,V,W: np.sqrt(max(0.001,U*tand(Th)**2+V*tand(Th)+W))
    658     sigTOF = lambda dsp,S0,S1,S2,Sq: np.sqrt(S0+S1*dsp**2+S2*dsp**4+Sq/dsp**2)
    659     gam = lambda Th,X,Y: (X/cosd(Th)+Y*tand(Th))
    660     gamTOF = lambda dsp,X,Y: X*dsp+Y*dsp**2
     658    sigTOF = lambda dsp,S0,S1,S2,Sq: np.sqrt(S0+S1*dsp**2+S2*dsp**4+Sq*dsp)
     659    gam = lambda Th,X,Y,Z: Z+X/cosd(Th)+Y*tand(Th)
     660    gamTOF = lambda dsp,X,Y,Z: Z+X*dsp+Y*dsp**2
    661661    if 'C' in Inst['Type'][0]:
    662662        s = sig(pos/2.,Inst['U'][1],Inst['V'][1],Inst['W'][1])
    663         g = gam(pos/2.,Inst['X'][1],Inst['Y'][1])
     663        g = gam(pos/2.,Inst['X'][1],Inst['Y'][1],Inst['Z'][1])
    664664        return getgamFW(g,s)/100.  #returns FWHM in deg
    665665    else:
    666666        dsp = pos/Inst['difC'][0]
    667667        s = sigTOF(dsp,Inst['sig-0'][1],Inst['sig-1'][1],Inst['sig-2'][1],Inst['sig-q'][1])
    668         g = gamTOF(dsp,Inst['X'][1],Inst['Y'][1])
     668        g = gamTOF(dsp,Inst['X'][1],Inst['Y'][1],Inst['Z'][1])
    669669        return getgamFW(g,s)
    670670   
     
    12111211                if gamName in varyList:
    12121212                    gam = parmDict[gamName]
    1213                     dgdX = dgdY = 0
     1213                    dgdX = dgdY = dgdZ = 0
    12141214                else:
    12151215                    gam = G2mth.getCWgam(parmDict,tth)
    1216                     dgdX,dgdY = G2mth.getCWgamDeriv(tth)
     1216                    dgdX,dgdY,dgdZ = G2mth.getCWgamDeriv(tth)
    12171217                gam = max(gam,0.001)             #avoid neg gamma
    12181218                Wd,fmin,fmax = getWidthsCW(pos,sig,gam,shl)
     
    12571257                if 'Y' in varyList:
    12581258                    dMdv[varyList.index('Y')] += dgdY*dervDict['gam']
     1259                if 'Z' in varyList:
     1260                    dMdv[varyList.index('Z')] += dgdZ*dervDict['gam']
    12591261                if 'SH/L' in varyList:
    12601262                    dMdv[varyList.index('SH/L')] += dervDict['shl']         #problem here
     
    13041306                if gamName in varyList:
    13051307                    gam = parmDict[gamName]
    1306                     dsdX = dsdY = 0
     1308                    dsdX = dsdY = dsdZ = 0
    13071309                else:
    13081310                    gam = G2mth.getTOFgamma(parmDict,dsp)
    1309                     dsdX,dsdY = G2mth.getTOFgammaDeriv(dsp)
     1311                    dsdX,dsdY,dsdZ = G2mth.getTOFgammaDeriv(dsp)
    13101312                gam = max(gam,0.001)             #avoid neg gamma
    13111313                Wd,fmin,fmax = getWidthsTOF(pos,alp,bet,sig,gam)
     
    13541356                    dMdv[varyList.index('X')] += dsdX*dervDict['gam']
    13551357                if 'Y' in varyList:
    1356                     dMdv[varyList.index('Y')] += dsdY*dervDict['gam']         #problem here
     1358                    dMdv[varyList.index('Y')] += dsdY*dervDict['gam']
     1359                if 'Z' in varyList:
     1360                    dMdv[varyList.index('Z')] += dsdZ*dervDict['gam']
    13571361                iPeak += 1
    13581362            except KeyError:        #no more peaks to process
     
    16231627            insNames.append(parm)
    16241628            insVals.append(Inst[parm][1])
    1625             if parm in ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     1629            if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    16261630                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',] and Inst[parm][2]:
    16271631                    insVary.append(parm)
    16281632        instDict = dict(zip(insNames,insVals))
    1629         instDict['X'] = max(instDict['X'],0.01)
    1630         instDict['Y'] = max(instDict['Y'],0.01)
     1633#        instDict['X'] = max(instDict['X'],0.01)
     1634#        instDict['Y'] = max(instDict['Y'],0.01)
    16311635        if 'SH/L' in instDict:
    16321636            instDict['SH/L'] = max(instDict['SH/L'],0.002)
     
    16651669        sigstr = 'esds  :'
    16661670        for parm in Inst:
    1667             if parm in  ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     1671            if parm in  ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    16681672                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',]:
    16691673                ptlbls += "%s" % (parm.center(12))
     
    27822786        'pos2':20.6426,'int2':1573.7,'sig2':1.0,'gam2':1.0,
    27832787        'pos3':26.9568,'int3':925.1,'sig3':1.0,'gam3':1.0,
    2784         'U':1.163,'V':-0.605,'W':0.093,'X':0.0,'Y':2.183,'SH/L':0.002,
     2788        'U':1.163,'V':-0.605,'W':0.093,'X':0.0,'Y':2.183,'Z':0.0,'SH/L':0.002,
    27852789        'Back0':5.384,'Back1':-0.015,'Back2':.004,
    27862790        }
     
    27932797        'pos4':36.1119,'int4':115829.8,'sig4':1.0,'gam4':1.0,
    27942798        'pos5':39.0122,'int5':6916.9,'sig5':1.0,'gam5':1.0,
    2795         'U':22.75,'V':-17.596,'W':10.594,'X':1.577,'Y':5.778,'SH/L':0.002,
     2799        'U':22.75,'V':-17.596,'W':10.594,'X':1.577,'Y':5.778,'Z':0.0,'SH/L':0.002,
    27962800        'Back0':36.897,'Back1':-0.508,'Back2':.006,
    27972801        'Lam1':1.540500,'Lam2':1.544300,'I(L2)/I(L1)':0.5,
     
    28002804    parmDict2 = {
    28012805        'pos0':5.7,'int0':1000.0,'sig0':0.5,'gam0':0.5,
    2802         'U':2.,'V':-2.,'W':5.,'X':0.5,'Y':0.5,'SH/L':0.02,
     2806        'U':2.,'V':-2.,'W':5.,'X':0.5,'Y':0.5,'Z':0.0,'SH/L':0.02,
    28032807        'Back0':5.,'Back1':-0.02,'Back2':.004,
    28042808#        'Lam1':1.540500,'Lam2':1.544300,'I(L2)/I(L1)':0.5,
     
    28532857    plotter = plot.PlotNotebook()
    28542858#    test0()
    2855 #    for name in ['int0','pos0','sig0','gam0','U','V','W','X','Y','SH/L','I(L2)/I(L1)']:
     2859#    for name in ['int0','pos0','sig0','gam0','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)']:
    28562860    for name,shft in [['int0',0.1],['pos0',0.0001],['sig0',0.01],['gam0',0.00001],
    2857         ['U',0.1],['V',0.01],['W',0.01],['X',0.0001],['Y',0.0001],['SH/L',0.00005]]:
     2861        ['U',0.1],['V',0.01],['W',0.01],['X',0.0001],['Y',0.0001],['Z',0.0001],['SH/L',0.00005]]:
    28582862        test2(name,shft)
    28592863    for name,shft in [['pos',0.0001],['sig',0.01],['gam',0.0001],['shl',0.00005]]:
  • trunk/GSASIIpwdGUI.py

    r3155 r3157  
    972972                insNames.append(parm)
    973973                insVals.append(Inst[parm][1])
    974                 if parm in ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     974                if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    975975                    'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',] and Inst[parm][2]:
    976976                        Inst[parm][2] = False
     
    14181418        good = []
    14191419        for key in keys:
    1420             if key in ['Type','Bank','U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     1420            if key in ['Type','Bank','U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    14211421                'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','Polariz.',
    14221422                'Lam','Azimuth','2-theta','fltPath','difC','difA','difB','Zero','Lam1','Lam2']:
     
    17951795                        refFlgElem.append([item,2])
    17961796                        instSizer.Add(RefineBox(item),0,WACV)
    1797                 for item in ['U','V','W','X','Y','SH/L']:
     1797                for item in ['U','V','W','X','Y','Z','SH/L']:
    17981798                    nDig = (10,3)
    17991799                    if item == 'SH/L':
     
    18241824                refFlgElem.append(None)                   
    18251825                if 'Pdabc' in Inst2:
    1826                     Items = ['sig-0','sig-1','sig-2','sig-q','X','Y']
     1826                    Items = ['sig-0','sig-1','sig-2','sig-q','X','Y','Z']
    18271827                    subSizer.Add(wx.StaticText(G2frame.dataWindow,-1,'  difC: '),0,WACV)
    18281828                    txt = '%8.2f'%(insVal['difC'])
     
    18341834                    subSizer.Add(wx.StaticText(G2frame.dataWindow,-1,'  alpha, beta: fixed by table'),0,WACV)
    18351835                else:
    1836                     Items = ['difC','difA','difB','Zero','alpha','beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','X','Y']
     1836                    Items = ['difC','difA','difB','Zero','alpha','beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q','X','Y','Z']
    18371837                mainSizer.Add((5,5),0)
    18381838                mainSizer.Add(subSizer)
     
    19301930            patched += 1
    19311931    if patched: print (patched,' instrument parameters changed from tuples')
     1932    if 'Z' not in data:
     1933        data['Z'] = [0.0,0.0,False]
    19321934    #end of patch
    19331935    labelLst,elemKeysLst,dspLst,refFlgElem = [],[],[],[]
  • trunk/GSASIIscriptable.py

    r3136 r3157  
    16681668                insNames.append(parm)
    16691669                insVals.append(Inst[parm][1])
    1670                 if parm in ['U','V','W','X','Y','SH/L','I(L2)/I(L1)','alpha',
     1670                if parm in ['U','V','W','X','Y','Z','SH/L','I(L2)/I(L1)','alpha',
    16711671                    'beta-0','beta-1','beta-q','sig-0','sig-1','sig-2','sig-q',] and Inst[parm][2]:
    16721672                        Inst[parm][2] = False
  • trunk/GSASIIstrIO.py

    r3136 r3157  
    28602860        return bakType,backDict,backVary           
    28612861       
    2862     def GetInstParms(hId,Inst):     
     2862    def GetInstParms(hId,Inst):
     2863        #patch
     2864        if 'Z' not in Inst:
     2865            Inst['Z'] = [0.0,0.0,False]
    28632866        dataType = Inst['Type'][0]
    28642867        instDict = {}
  • trunk/GSASIIstrMath.py

    r3149 r3157  
    30733073        X = parmDict[hfx+'X']
    30743074        Y = parmDict[hfx+'Y']
     3075        Z = parmDict[hfx+'Z']
    30753076        tanPos = tand(refl[5+im]/2.0)
    30763077        Ssig,Sgam = GetSampleSigGam(refl,im,wave,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    30773078        sig = U*tanPos**2+V*tanPos+W+Ssig     #save peak sigma
    30783079        sig = max(0.001,sig)
    3079         gam = X/cosd(refl[5+im]/2.0)+Y*tanPos+Sgam     #save peak gamma
     3080        gam = X/cosd(refl[5+im]/2.0)+Y*tanPos+Sgam+Z     #save peak gamma
    30803081        gam = max(0.001,gam)
    30813082        return sig,gam
     
    30833084    def GetReflSigGamTOF(refl,im,G,GB,phfx,calcControls,parmDict):
    30843085        sig = parmDict[hfx+'sig-0']+parmDict[hfx+'sig-1']*refl[4+im]**2+   \
    3085             parmDict[hfx+'sig-2']*refl[4+im]**4+parmDict[hfx+'sig-q']/refl[4+im]**2
    3086         gam = parmDict[hfx+'X']*refl[4+im]+parmDict[hfx+'Y']*refl[4+im]**2
     3086            parmDict[hfx+'sig-2']*refl[4+im]**4+parmDict[hfx+'sig-q']*refl[4+im]
     3087        gam = parmDict[hfx+'X']*refl[4+im]+parmDict[hfx+'Y']*refl[4+im]**2+parmDict[hfx+'Z']
    30873088        Ssig,Sgam = GetSampleSigGam(refl,im,0.0,G,GB,SGData,hfx,phfx,calcControls,parmDict)
    30883089        sig += Ssig
     
    37943795                names = {hfx+'Scale':[dIdsh,'int'],hfx+'Polariz.':[dIdpola,'int'],phfx+'Scale':[dIdsp,'int'],
    37953796                    hfx+'U':[tanth**2,'sig'],hfx+'V':[tanth,'sig'],hfx+'W':[1.0,'sig'],
    3796                     hfx+'X':[1.0/costh,'gam'],hfx+'Y':[tanth,'gam'],hfx+'SH/L':[1.0,'shl'],
     3797                    hfx+'X':[1.0/costh,'gam'],hfx+'Y':[tanth,'gam'],hfx+'Z':[1.0,'gam'],hfx+'SH/L':[1.0,'shl'],
    37973798                    hfx+'I(L2)/I(L1)':[1.0,'L1/L2'],hfx+'Zero':[dpdZ,'pos'],hfx+'Lam':[dpdw,'pos'],
    37983799                    hfx+'Shift':[dpdSh,'pos'],hfx+'Transparency':[dpdTr,'pos'],hfx+'DisplaceX':[dpdX,'pos'],
     
    38073808                names = {hfx+'Scale':[dIdsh,'int'],phfx+'Scale':[dIdsp,'int'],
    38083809                    hfx+'difC':[dpdDC,'pos'],hfx+'difA':[dpdDA,'pos'],hfx+'difB':[dpdDB,'pos'],
    3809                     hfx+'Zero':[dpdZ,'pos'],hfx+'X':[refl[4+im],'gam'],hfx+'Y':[refl[4+im]**2,'gam'],
     3810                    hfx+'Zero':[dpdZ,'pos'],hfx+'X':[refl[4+im],'gam'],hfx+'Y':[refl[4+im]**2,'gam'],hfx+'Z':[1.0,'gam'],
    38103811                    hfx+'alpha':[1./refl[4+im],'alp'],hfx+'beta-0':[1.0,'bet'],hfx+'beta-1':[1./refl[4+im]**4,'bet'],
    38113812                    hfx+'beta-q':[1./refl[4+im]**2,'bet'],hfx+'sig-0':[1.0,'sig'],hfx+'sig-1':[refl[4+im]**2,'sig'],
    3812                     hfx+'sig-2':[refl[4+im]**4,'sig'],hfx+'sig-q':[1./refl[4+im]**2,'sig'],
     3813                    hfx+'sig-2':[refl[4+im]**4,'sig'],hfx+'sig-q':[refl[4+im],'sig'],
    38133814                    hfx+'Absorption':[dFdAb,'int'],phfx+'Extinction':[dFdEx,'int'],}
    38143815            for name in names:
  • trunk/defaultIparms.py

    r2659 r3157  
    4242    'Type:PXC;Bank:1\n',
    4343    'Lam1:1.5405;Lam2:1.5443;Zero:0.0;Polariz.:0.7;Azimuth:0.0;I(L2)/I(L1):0.5\n',
    44     'U:2.0;V:-2.0;W:5.0;X:0.0;Y:0.0;SH/L:0.002\n',
     44    'U:2.0;V:-2.0;W:5.0;X:0.0;Y:0.0;Z:0.0;SH/L:0.002\n',
    4545])
    4646
     
    5050    'Type:PXC;Bank:1\n',
    5151    'Lam:0.413263;Polariz.:0.99;Azimuth:0.0;Zero:0.0\n',
    52     'U:1.163;V:-0.126;W:0.063;X:0.0;Y:0.0;SH/L:0.002\n',
     52    'U:1.163;V:-0.126;W:0.063;X:0.0;Y:0.0;Z:0.0;SH/L:0.002\n',
    5353])
    5454
     
    5959    'Lam:0.69968;Zero:0.0;Polariz.:0.99;Azimuth:0.0\n',
    6060    'U:5.9840407759;V:-1.28771353531;W:0.118521878603\n',
    61     'X:-0.0977791308891;Y:4.40147397286;SH/L:0.0264356231583\n',
     61    'X:-0.0977791308891;Y:4.40147397286;Z:0.0;SH/L:0.0264356231583\n',
    6262])
    6363
     
    6868    'Lam:1.909;Zero:0.0;Polariz.:0.0;Azimuth:0.0\n',
    6969    'U:257.182710995;V:-640.525145369;W:569.378664828\n',
    70     'X:0.0;Y:0.0;SH/L:0.002\n',
     70    'X:0.0;Y:0.0;Z:0.0;SH/L:0.002\n',
    7171])
    7272
     
    8080    'beta-0:0.0332763989665;beta-1:0.000964057827372;beta-q:0.0\n',
    8181    'sig-0:0.0;sig-1:15.1402867268;sig-2:0.0;sig-q:0.0\n',
    82     'X:0.0;Y:0.0\n',
     82    'X:0.0;Y:0.0;Z:0.0\n',
    8383])
    8484
     
    9292    'beta-0:0.03;beta-1:0.004;beta-q:0.0\n',
    9393    'sig-0:0.0;sig-1:80.0;sig-2:0.0;sig-q:0.0\n',
    94     'X:0.0;Y:0.0\n',
     94    'X:0.0;Y:0.0;Z:0.0\n',
    9595])
    9696
     
    103103    'beta-0:0.138077840635;beta-1:0.0029606795286;beta-q:0.0\n',
    104104    'sig-0:24.8202075678;sig-1:-82.07196132;sig-2:269.925504862;sig-q:0.0\n',
    105     'X:-1.80259010604;Y:4.47209435997\n',
     105    'X:-1.80259010604;Y:4.47209435997;Z:0.0\n',
    106106])
    107107
     
    114114    'beta-0:0.;beta-1:0.005;beta-q:0.0\n',
    115115    'sig-0:0.;sig-1:-50.;sig-2:0.;sig-q:0.0\n',
    116     'X:0.;Y:0.\n',
     116    'X:0.;Y:0.;Z:0.\n',
    117117])
Note: See TracChangeset for help on using the changeset viewer.