Changeset 362


Ignore:
Timestamp:
Sep 4, 2011 8:04:31 AM (10 years ago)
Author:
vondreele
Message:

add shift factor to LS controls

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r360 r362  
    508508def UpdateControls(self,data):
    509509    #patch
     510    if 'shift factor' not in data:
     511        data['shift factor'] = 1.       
    510512    if 'deriv type' not in data:
    511513        data['deriv type'] = 'analytical'
    512514        data['min dM/M'] = 0.0001
     515        data['shift factor'] = 1.
    513516    #end patch
    514517    '''
     
    524527       
    525528    def OnConvergence(event):
     529        Obj = event.GetObject()
    526530        try:
    527             value = max(1.e-9,min(1.0,float(Cnvrg.GetValue())))
     531            value = max(1.e-9,min(1.0,float(Obj.GetValue())))
    528532        except ValueError:
    529533            value = 0.0001
    530534        data['min dM/M'] = value
    531         Cnvrg.SetValue('%.2g'%(value))
     535        Obj.SetValue('%.2g'%(value))
    532536       
    533537    def OnDerivType(event):
    534         data['deriv type'] = derivSel.GetValue()
     538        Obj = event.GetObject()
     539        data['deriv type'] = Obj.GetValue()
    535540        derivSel.SetValue(data['deriv type'])
     541       
     542    def OnFactor(event):
     543        Obj = event.GetObject()
     544        try:
     545            value = min(max(float(Obj.GetValue()),0.001),100.)
     546        except ValueError:
     547            value = 1.0
     548        data['shift factor'] = value
     549        Obj.SetValue('%.3f'%(value))
    536550       
    537551    if self.dataDisplay:
     
    546560    mainSizer.Add((5,5),0)
    547561    mainSizer.Add(wx.StaticText(self.dataDisplay,label=' Refinement Controls:'),0,wx.ALIGN_CENTER_VERTICAL)
    548     LSSizer = wx.FlexGridSizer(cols=4,vgap=5,hgap=5)
     562    LSSizer = wx.FlexGridSizer(cols=6,vgap=5,hgap=5)
    549563    LSSizer.Add(wx.StaticText(self.dataDisplay,label='Refinement derivatives: '),0,wx.ALIGN_CENTER_VERTICAL)
    550564    Choice=['analytic','numeric']
     
    559573    Cnvrg.Bind(wx.EVT_KILL_FOCUS,OnConvergence)
    560574    LSSizer.Add(Cnvrg,0,wx.ALIGN_CENTER_VERTICAL)
    561    
    562    
     575    LSSizer.Add(wx.StaticText(self.dataDisplay,label=' Initial shift factor: '),0,wx.ALIGN_CENTER_VERTICAL)
     576    Factr = wx.TextCtrl(self.dataDisplay,-1,value='%.3f'%(data['shift factor']),style=wx.TE_PROCESS_ENTER)
     577    Factr.Bind(wx.EVT_TEXT_ENTER,OnFactor)
     578    Factr.Bind(wx.EVT_KILL_FOCUS,OnFactor)
     579    LSSizer.Add(Factr,0,wx.ALIGN_CENTER_VERTICAL)
     580       
    563581    mainSizer.Add(LSSizer)
    564582    mainSizer.Add((5,5),0)
  • trunk/GSASIIphsGUI.py

    r360 r362  
    26662666                ext,mul = G2spc.GenHKLf([h,k,l],SGData)[:2]
    26672667                if not ext:
    2668                     PawleyPeaks.append([h,k,l,mul,d,False,10000.0,1.0])
     2668                    PawleyPeaks.append([h,k,l,mul,d,False,1000.0,1.0])
    26692669        finally:
    26702670            wx.EndBusyCursor()
  • trunk/GSASIIstruct.py

    r360 r362  
    4444        Controls = dictionary of control items
    4545    '''
     46    Controls = {'deriv type':'analytical','min dM/M':0.0001,'shift factor':1.}
    4647    file = open(GPXfile,'rb')
    4748    while True:
     
    5253        datum = data[0]
    5354        if datum[0] == 'Controls':
    54             Controls = datum[1]
     55            Controls.update(datum[1])
    5556    file.close()
    5657    return Controls
     
    6061    print ' Derivative type: ',Controls['deriv type']
    6162    print ' Minimum delta-M/M for convergence: ','%.2g'%(Controls['min dM/M'])
     63    print ' Initial shift factor: ','%.3f'%(Controls['shift factor'])
    6264   
    6365def GetPhaseNames(GPXfile):
     
    12011203        tanth = tand(refl[5]/2.)
    12021204        if calcControls[phfx+'SizeType'] == 'isotropic':
    1203             gam = 1.8*wave/(np.pi*parmDict[phfx+'Size:0']*costh)
    1204             gamDict[phfx+'Size:0'] = -gam/parmDict[phfx+'Size:0']
     1205            gam = 180.*wave/(np.pi*parmDict[phfx+'Size:0']*costh)
     1206            gamDict[phfx+'Size:0'] = gam/parmDict[phfx+'Size:0']
    12051207        elif calcControls[phfx+'SizeType'] == 'uniaxial':
    12061208            H = np.array(refl[:3])
     
    12091211            Si = parmDict[phfx+'Size:0']
    12101212            Sa = parmDict[phfx+'Size:1']
    1211             gami = (1.8*wave/np.pi)/(Si*Sa)
     1213            gami = (180.*wave/np.pi)/(Si*Sa)
    12121214            sqtrm = np.sqrt((cosP*Sa)**2+(sinP*Si)**2)
    12131215            gam = gami*sqtrm/costh           
    12141216            gamDict[phfx+'Size:0'] = gami*Si*sinP**2/(sqtrm*costh)-gam/Si
    1215             gamDict[phfx+'Size:1'] = gami*Sa*cosP**2/(sqtrm*costh)-gam/Sa         
     1217            gamDict[phfx+'Size:1'] = gam/Sa-gami*Sa*cosP**2/(sqtrm*costh)         
    12161218        else:           #ellipsoidal crystallites - do numerically?
    12171219            H = np.array(refl[:3])
     
    14891491        dlg.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    14901492        Ftol = Controls['min dM/M']
     1493        Factor = Controls['shift factor']
    14911494        try:
    14921495            if Controls['deriv type'] == 'analytic':
    1493                 result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True,ftol=Ftol,col_deriv=True,
     1496                result = so.leastsq(errRefine,values,Dfun=dervRefine,full_output=True,
     1497                    ftol=Ftol,col_deriv=True,factor=Factor,
    14941498                    args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
    14951499                ncyc = int(result[2]['nfev']/2)               
    14961500            else:           #'numeric'
    1497                 result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,
     1501                result = so.leastsq(errRefine,values,full_output=True,ftol=Ftol,epsfcn=1.e-8,factor=Factor,
    14981502                    args=([Histograms,Phases],parmDict,varyList,calcControls,pawleyLookup,dlg))
    14991503                ncyc = int(result[2]['nfev']/len(varyList))
Note: See TracChangeset for help on using the changeset viewer.