Changeset 2311 for trunk


Ignore:
Timestamp:
Jun 7, 2016 2:30:49 PM (9 years ago)
Author:
vondreele
Message:

add tracking of 5 user selected reflection phases during charge flipping. Could be instructive...

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/GSASIImath.py

    r2301 r2311  
    27882788                Ehkl[h,k,l] = E*phasem
    27892789#    Ehkl[Hmax] = 0.00001           #this to preserve F[0,0,0]
     2790    testHKL = np.array(flipData['testHKL'])+Hmax
    27902791    CEhkl = copy.copy(Ehkl)
    27912792    MEhkl = ma.array(Ehkl,mask=(Ehkl==0.0))
     
    27942795    Ncyc = 0
    27952796    old = np.seterr(all='raise')
     2797    twophases = []
    27962798    while True:       
    27972799        CErho = np.real(fft.fftn(fft.fftshift(CEhkl)))*(1.+0j)
     
    28022804        CFhkl = np.where(CFhkl,CFhkl,1.0)           #avoid divide by zero
    28032805        phase = CFhkl/np.absolute(CFhkl)
     2806        twophases.append([np.angle(phase[h,k,l]) for h,k,l in testHKL])
    28042807        CEhkl = np.absolute(Ehkl)*phase
    28052808        Ncyc += 1
     
    28232826    mapData['minmax'] = [np.max(mapData['rho']),np.min(mapData['rho'])]
    28242827    mapData['Type'] = reflDict['Type']
    2825     return mapData
     2828    return mapData,twophases
    28262829   
    28272830def findSSOffset(SGData,SSGData,A,Fhklm):   
     
    31143117        incre = np.array(rho.shape,dtype=np.float)
    31153118        step = max(1.0,1./res)+1
    3116         steps = np.array(3*[step,])
     3119        steps = np.array((3*[step,]),dtype='int32')
    31173120    except KeyError:
    31183121        print '**** ERROR - Fourier map not defined'
  • TabularUnified trunk/GSASIIphsGUI.py

    r2285 r2311  
    203203        if 'Flip' not in generalData:
    204204            generalData['Flip'] = {'RefList':'','Resolution':0.5,'Norm element':'None',
    205                 'k-factor':0.1,'k-Max':20.}
     205                'k-factor':0.1,'k-Max':20.,}
     206        if 'testHKL' not in generalData['Flip']:
     207            generalData['Flip']['testHKL'] = [[0,0,2],[2,0,0],[1,1,1],[0,2,0],[1,2,3]]
    206208        if 'doPawley' not in generalData:
    207209            generalData['doPawley'] = False
     
    937939                    pass
    938940                kMax.SetValue("%.1f"%(Flip['k-Max']))          #reset in case of error
     941               
     942            def OnTestHKL(event):
     943                Obj = event.GetEventObject()
     944                name = Obj.GetName()
     945                try:
     946                    vals = Obj.GetValue().split()
     947                    id = int(name.split('hkl')[1])
     948                    HKL = [int(val) for val in vals]
     949                    Flip['testHKL'][id] = HKL
     950                except ValueError:
     951                    HKL = Flip['testHKL'][id]
     952                Obj.SetValue('%3d %3d %3d'%(HKL[0],HKL[1],HKL[2]))
    939953
    940954            refsList = data['Histograms'].keys()
     
    971985            line2Sizer.Add(kMax,0,WACV)
    972986            flipSizer.Add(line2Sizer,0,WACV)
     987            line3Sizer = wx.BoxSizer(wx.HORIZONTAL)
     988            line3Sizer.Add(wx.StaticText(General,label=' Test HKLs:'),0,WACV)
     989            if len(Flip['testHKL']) < 5:
     990                Flip['testHKL'] += [[1,1,1],[0,2,0],[1,2,3]]
     991            HKL = Flip['testHKL']
     992            for ih,hkl in enumerate(Flip['testHKL']):               
     993                hkl = wx.TextCtrl(General,value='%3d %3d %3d'%(HKL[ih][0],HKL[ih][1],HKL[ih][2]),
     994                    style=wx.TE_PROCESS_ENTER,name='hkl%d'%(ih))
     995                hkl.Bind(wx.EVT_TEXT_ENTER,OnTestHKL)       
     996                hkl.Bind(wx.EVT_KILL_FOCUS,OnTestHKL)
     997                line3Sizer.Add(hkl,0,WACV)
     998            flipSizer.Add(line3Sizer)
    973999            return flipSizer
    9741000           
     
    72017227        screenSize = wx.ClientDisplayRect()
    72027228        Size = pgbar.GetSize()
     7229        testNames = ['%3d%3d%3d'%(h,k,l) for h,k,l in flipData['testHKL']]
    72037230        if 50 < Size[0] < 500: # sanity check on size, since this fails w/Win & wx3.0
    72047231            pgbar.SetSize((int(Size[0]*1.2),Size[1])) # increase size a bit along x
    72057232            pgbar.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    72067233        try:
    7207             mapData.update(G2mth.ChargeFlip(data,ReflData,pgbar))
     7234            result = G2mth.ChargeFlip(data,ReflData,pgbar)
     7235            mapData.update(result[0])
     7236            X = range(len(result[1]))
     7237            Y = 180.*np.array(result[1]).T/np.pi
     7238            XY = [[X,y] for y in Y]
     7239            G2plt.PlotXY(G2frame,XY,labelX='charge flip cycle',labelY='phase, deg',newPlot=True,
     7240                Title='Test HKL phases',lines=True,names=testNames)
    72087241        finally:
    72097242            pgbar.Destroy()
  • TabularUnified trunk/GSASIIplot.py

    r2310 r2311  
    24302430           
    24312431def PlotXY(G2frame,XY,XY2=None,labelX=None,labelY=None,newPlot=False,
    2432     Title='',lines=False,names=[]):
     2432    Title='',lines=False,names=[],names2=[]):
    24332433    '''simple plot of xy data, used for diagnostic purposes
    24342434    '''
     
    24802480        Page.Offset = [0,0]
    24812481   
    2482     if len(XY2) > 1:
     2482    if XY2 and len(XY2) > 1:
    24832483        Page.Choice = (' key press','l: offset left','r: offset right','d: offset down',
    24842484            'u: offset up','o: reset offset',)
     
    25052505        Ymax = max(Ymax,max(Y))
    25062506        if lines:
    2507             Plot.plot(X,Y,colors[ixy%6],picker=False)
     2507            if len(names):
     2508                Plot.plot(X,Y,colors[ixy%6],picker=False,label=names[ixy])
     2509            else:
     2510                Plot.plot(X,Y,colors[ixy%6],picker=False)
    25082511        else:
    25092512            Plot.plot(X,Y,colors[ixy%6]+'+',picker=False)
    2510     if len(XY2):
     2513    if XY2 and len(XY2):
    25112514        for ixy,xy in enumerate(XY2):
    25122515            X,Y = XY2[ixy]
    25132516            dX = Page.Offset[0]*(ixy+1)*Xmax/500.
    25142517            dY = Page.Offset[1]*(ixy+1)*Ymax/100.
    2515             if len(names):
    2516                 Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False,label=names[ixy])
     2518            if len(names2):
     2519                Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False,label=names2[ixy])
    25172520            else:
    25182521                Plot.plot(X+dX,Y+dY,colors[ixy%6],picker=False)
Note: See TracChangeset for help on using the changeset viewer.