Changeset 64


Ignore:
Timestamp:
May 14, 2010 2:08:46 PM (12 years ago)
Author:
vondreel
Message:

refactoring
remove SH/L from peak list
modify powder plot to offset delta curve

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIcomp.py

    r63 r64  
    2626    app.MainLoop()
    2727    msg = wx.MessageDialog(None, message="Unable to load the GSAS powder computation module, pypowder",
    28                      caption="Import Error",
    29                      style=wx.ICON_ERROR | wx.OK | wx.STAY_ON_TOP)
     28        caption="Import Error",style=wx.ICON_ERROR | wx.OK | wx.STAY_ON_TOP)
    3029    msg.ShowModal()
    3130    # this error is non-recoverable, so just quit
     
    178177                for peak in peaks:
    179178                    dip = peak[-1]
    180                     f = pyp.pypsvfcj(peak[2],xi-peak[0],peak[0],peak[4],peak[6],peak[8],0.0)
     179                    f = pyp.pypsvfcj(peak[2],xi-peak[0],peak[0],peak[4],peak[6],instVal[-2],0.0)
    181180                    yc[i] += f[0]*peak[2]
    182181                    if f[0] > 0.0:
     
    201200                    if Ka2:
    202201                       pos2 = 2.0*asind(lamratio*sind(peak[0]/2.0))
    203                        f2 = pyp.pypsvfcj(peak[2],xi-pos2,peak[0],peak[4],peak[6],peak[8],0.0)
     202                       f2 = pyp.pypsvfcj(peak[2],xi-pos2,peak[0],peak[4],peak[6],instVal[-2],0.0)
    204203                       yc[i] += f2[0]*peak[2]*instVal[3]
    205204                       if f[0] > 0.0:
     
    222221                           if insref[5]:              #SH/L
    223222                               dp[Bv+j] += f2[5]*instVal[3]                       
    224                     for j in range(0,Np,2):          #14s
     223                    for j in range(0,Np,2):
    225224                        if peak[j+1]: dp.append(f[j/2+1])
    226225                yd[i] = y[i]-yc[i]
     
    244243        if elm <= 0.0:
    245244            print norm
    246             return False,0,0,0
     245            return False,0,0,0,False
    247246    for i in xrange(len(V)):
    248247        norm[i] = 1.0/math.sqrt(norm[i])
     
    294293        delsig = delt[0]*tand(peak[0]/2.0)**2+delt[1]*tand(peak[0]/2.0)+delt[2]
    295294        delgam = delt[3]/cosd(peak[0]/2.0)+delt[4]*tand(peak[0]/2.0)
    296         delshl = delt[5]   
    297295        for j in range(0,len(peak[:-1]),2):
    298296            if peak[j+1]:
     
    307305            print 'ERROR - negative gamma'
    308306            return False,0,0,0,False
    309         peak[8] += delshl           
    310         if peak[8] < 0.0:
    311             print 'ERROR - negative SH/L'
    312             return False,0,0,0,False           
    313307    runtime = time.time()-begin   
    314308    data = [x,y,w,yc,yb,yd]
     
    11331127                    peak[8] = 1./math.sqrt(dsq)
    11341128        return
    1135     delt = 0.05                                     #lowest d-spacing cushion - can be fixed?
     1129    delt = 0.005                                     #lowest d-spacing cushion - can be fixed?
    11361130    amin = 2.5
    11371131    amax = 5.0*getDmax(peaks)
  • trunk/GSASIIgrid.py

    r63 r64  
    2525] = [wx.NewId() for _init_coll_IMAGE_Items in range(6)]
    2626
     27[ wxID_INSTPRMRESET,
     28] = [wx.NewId() for _init_coll_INST_Items in range(1)]
     29
    2730[ wxID_MASKCOPY,
    2831] = [wx.NewId() for _init_coll_MASK_Items in range(1)]
     
    4346    def _init_coll_ImageMenu(self,parent):
    4447        parent.Append(menu=self.ImageEdit, title='Image Operations')
     48       
     49    def _init_coll_InstMenu(self,parent):
     50        parent.Append(menu=self.InstEdit, title='Inst. Parm. Operations')
    4551       
    4652    def _init_coll_MaskMenu(self,parent):
     
    7682            id=wxID_MASKCOPY, kind=wx.ITEM_NORMAL,text='Copy mask')
    7783
     84    def _init_coll_Inst_Items(self,parent):
     85        parent.Append(help='Reset instrument profile parameters to default',
     86            id=wxID_INSTPRMRESET, kind=wx.ITEM_NORMAL,text='Reset profile')
     87
    7888    def _init_coll_Peak_Items(self,parent):
    7989        self.UnDo = parent.Append(help='Undo last least squares refinement',
     
    98108        self.ImageMenu = wx.MenuBar()
    99109        self.MaskMenu = wx.MenuBar()
     110        self.InstMenu = wx.MenuBar()
    100111        self.PeakMenu = wx.MenuBar()
    101112        self.IndexMenu = wx.MenuBar()
     
    103114        self.ImageEdit = wx.Menu(title='')
    104115        self.MaskEdit = wx.Menu(title='')
     116        self.InstEdit = wx.Menu(title='')
    105117        self.PeakEdit = wx.Menu(title='')
    106118        self.IndexEdit = wx.Menu(title='')
     
    111123        self._init_coll_MaskMenu(self.MaskMenu)
    112124        self._init_coll_Mask_Items(self.MaskEdit)
     125        self._init_coll_InstMenu(self.InstMenu)
     126        self._init_coll_Inst_Items(self.InstEdit)
    113127        self._init_coll_PeakMenu(self.PeakMenu)
    114128        self._init_coll_Peak_Items(self.PeakEdit)
     
    430444       for r in range(self.dataDisplay.GetNumberRows()):
    431445           for c in range(self.dataDisplay.GetNumberCols()):
    432                if self.dataDisplay.GetColLabelValue(c) in ['position','intensity','sigma','gamma','SH/L']:
     446               if self.dataDisplay.GetColLabelValue(c) in ['position','intensity','sigma','gamma']:
    433447                   if float(self.dataDisplay.GetCellValue(r,c)) < 0.:
    434448                       self.dataDisplay.SetCellBackgroundColour(r,c,wx.RED)
     
    502516    rowLabels = []
    503517    for i in range(len(data)): rowLabels.append(str(i+1))
    504     colLabels = ['position','refine','intensity','refine','sigma','refine','gamma','refine','SH/L','refine']
     518    colLabels = ['position','refine','intensity','refine','sigma','refine','gamma','refine']
    505519    Types = [wg.GRID_VALUE_FLOAT+':10,4',wg.GRID_VALUE_BOOL,
    506520        wg.GRID_VALUE_FLOAT+':10,1',wg.GRID_VALUE_BOOL,
    507         wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL,
    508521        wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL,
    509522        wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_BOOL]
     
    526539    self.dataDisplay.SetMargins(0,0)
    527540    self.dataDisplay.AutoSizeColumns(False)
    528     self.dataFrame.setSizePosLeft([650,350])
     541    self.dataFrame.setSizePosLeft([550,350])
    529542       
    530543def UpdateBackgroundGrid(self,data):
     
    607620        self.dataDisplay.Destroy()
    608621    Ka2 = False
    609     Xwid = 720
     622    Xwid = 700
    610623    if len(data[0]) == 13:
    611624        Ka2 = True
    612         Xwid = 800       
    613     self.dataFrame.setSizePosLeft([Xwid,150])
     625        Xwid = 840       
     626    self.dataFrame.setSizePosLeft([Xwid,170])
    614627    self.dataFrame.SetMenuBar(self.dataFrame.BlankMenu)
    615628    InstId = GetPatternTreeItemId(self,self.PatternId, 'Instrument Parameters')
    616     def RefreshInstrumentGrid(event):
    617         if event.GetRow() == 1:
     629   
     630    def RefreshInstrumentGrid(event,doAnyway=False):
     631        if doAnyway or event.GetRow() == 1:
    618632            peaks = self.PatternTree.GetItemPyData(GetPatternTreeItemId(self,self.PatternId, 'Peak List'))
    619633            ins = data[1]
     
    623637                        peak[4] = ins[6]*tand(peak[0]/2.0)**2+ins[7]*tand(peak[0]/2.0)+ins[8]
    624638                        peak[6] = ins[9]/cosd(peak[0]/2.0)+ins[10]*tand(peak[0]/2.0)
    625                         peak[8] = ins[11]
    626639                    else:
    627640                        peak[4] = ins[4]*tand(peak[0]/2.0)**2+ins[5]*tand(peak[0]/2.0)+ins[6]
    628641                        peak[6] = ins[7]/cosd(peak[0]/2.0)+ins[8]*tand(peak[0]/2.0)
    629                         peak[8] = ins[9]
     642                       
     643    def OnReset(event):
     644        if Ka2:
     645            data[1][6:12] = data[0][6:12]
     646        else:
     647            data[1][4:10] = data[0][4:10]
     648        RefreshInstrumentGrid(event,doAnyway=True)          #to get peaks updated
     649        UpdateInstrumentGrid(self, data)
    630650       
    631651    self.InstrumentTable = []
    632652    if 'P' in data[1][0]:                   #powder data
     653        self.dataFrame.SetMenuBar(self.dataFrame.InstMenu)
     654        if not self.dataFrame.GetStatusBar():
     655            Status = self.dataFrame.CreateStatusBar()
     656        self.Bind(wx.EVT_MENU, OnReset, id=wxID_INSTPRMRESET)
    633657        if Ka2:
    634658            Types = [wg.GRID_VALUE_CHOICE+":PXC,PNC,PNT",wg.GRID_VALUE_FLOAT+':10,6',wg.GRID_VALUE_FLOAT+':10,6',               #type, lam-1 & lam-2
     
    642666                wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,3',wg.GRID_VALUE_FLOAT+':10,5',wg.GRID_VALUE_FLOAT+':10,2']
    643667        colLabels = data[3]
    644         rowLabels = ['original','changed','refine']
     668        rowLabels = ['default','changed','refine']
    645669        self.InstrumentTable = Table(data[:-1],rowLabels=rowLabels,colLabels=colLabels,types=Types)
    646670        self.dataFrame.SetLabel('Instrument Parameters')
     
    789813        print controls[5]
    790814        ibrav = bravaisSymb.index(controls[5])
    791         dmin = G2cmp.getDmin(peaks)-0.05
     815        dmin = G2cmp.getDmin(peaks)-0.005
    792816        Lhkl,M20,X20 = G2cmp.refinePeaks(peaks,ibrav,A)
    793817        controls[6:12] = G2cmp.A2cell(A)
  • trunk/GSASIIplot.py

    r63 r64  
    207207                gam = ins[3]/cosd(xy[0]/2.0)+ins[4]*tand(xy[0]/2.0)           
    208208                data = self.PatternTree.GetItemPyData(self.PickId)
    209                 XY = [xy[0],0, xy[1],1, sig,0, gam,0, ins[5],0]       #default refine intensity 1st   
     209                XY = [xy[0],0, xy[1],1, sig,0, gam,0]       #default refine intensity 1st   
    210210                data.append(XY)
    211211                G2gd.UpdatePeakGrid(self,data)
     
    357357                Z = xye[3]+offset*N
    358358                W = xye[4]+offset*N
    359                 D = xye[5]+offset*N
     359                D = xye[5]+offset*N-Ymax*.02
    360360                if self.Weight:
    361361                    W2 = np.sqrt(xye[2])
    362                     D *= W2
     362                    D *= W2-Ymax*.02
    363363                Plot.plot(X,Y,colors[N%6]+'+',picker=3.,clip_on=False)
    364364                Plot.plot(X,Z,colors[(N+1)%6],picker=False)
     
    450450    if instParms[0][0] == 'PXC':
    451451        lam = instParms[1][1]
    452         if len(instParms[1]) == 12:
     452        if len(instParms[1]) == 13:
    453453            GU,GV,GW,LX,LY = instParms[0][6:11]
    454454        else:
Note: See TracChangeset for help on using the changeset viewer.