Changeset 522


Ignore:
Timestamp:
Mar 20, 2012 1:38:12 PM (10 years ago)
Author:
vondreele
Message:

begin map search routines - GUI so far
make map move outside unit cell when view point is moved

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r519 r522  
    3838htmlFirstUse = True
    3939
    40 [ wxID_FOURCALC,
    41 ] = [wx.NewId() for item in range(1)]
     40[ wxID_FOURCALC,wxID_FOURSEARCH,
     41] = [wx.NewId() for item in range(2)]
    4242
    4343[ wxID_PWDRADD, wxID_HKLFADD, wxID_DATADELETE,
     
    437437        self.DataGeneral.Append(menu=self.GeneralCalc,title='Compute')
    438438        self.DataGeneral.Append(menu=MyHelp(self,helpType='General'),title='&Help')
    439         self.GeneralCalc.Append(help='Compute Fourier maps',id=wxID_FOURCALC, kind=wx.ITEM_NORMAL,
    440             text='Fourier maps')
     439        self.GeneralCalc.Append(help='Compute Fourier map',id=wxID_FOURCALC, kind=wx.ITEM_NORMAL,
     440            text='Fourier map')
     441        self.GeneralCalc.Append(help='Search Fourier map',id=wxID_FOURSEARCH, kind=wx.ITEM_NORMAL,
     442            text='Search map')
    441443       
    442444# Phase / Atoms tab
  • trunk/GSASIIphsGUI.py

    r521 r522  
    2727import numpy as np
    2828import numpy.linalg as nl
     29import numpy.ma as ma
    2930
    3031VERY_LIGHT_GREY = wx.Colour(235,235,235)
     
    253254        if 'Map' not in generalData:
    254255            generalData['Map'] = {'MapType':'','RefList':'','Resolution':1.0,
    255                 'rhoMax':100.,'rho':[],'rhoMax':0.,'mapSize':10.0}
     256                'rhoMax':100.,'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.}
    256257#        if 'SH Texture' not in generalData:
    257258#            generalData['SH Texture'] = data['SH Texture']
     
    320321        generalData = data['General']
    321322        Map = generalData['Map'] 
    322             # {'MapType':'','RefList':'','Resolution':1.0,'rho':[],'rhoMax':0.,'mapSize':10.0}
     323            # {'MapType':'','RefList':'','Resolution':1.0,'rho':[],'rhoMax':0.,'mapSize':10.0,'cutOff':50.}
    323324       
    324325        def NameSizer():
     
    628629                mapRes.SetValue("%.2f"%(Map['Resolution']))          #reset in case of error
    629630           
     631            def OnCutOff(event):
     632                try:
     633                    res = float(cutOff.GetValue())
     634                    if 1.0 <= res <= 100.:
     635                        Map['cutOff'] = res
     636                except ValueError:
     637                    pass
     638                cutOff.SetValue("%.1f"%(Map['cutOff']))          #reset in case of error
     639           
     640            #patch
     641            if 'cutOff' not in Map:
     642                Map['cutOff'] = 100.0
    630643            mapTypes = ['Fobs','Fcalc','delt-F','2*Fo-Fc','Patterson']
    631644            refList = data['Histograms'].keys()
     
    633646                 mapTypes = ['Patterson',]
    634647                 Map['MapType'] = 'Patterson'
    635             mapSizer = wx.BoxSizer(wx.HORIZONTAL)
    636             mapSizer.Add(wx.StaticText(dataDisplay,label=' Fourier map controls: Map type: '),0,wx.ALIGN_CENTER_VERTICAL)
     648            mapSizer = wx.BoxSizer(wx.VERTICAL)
     649            lineSizer = wx.BoxSizer(wx.HORIZONTAL)
     650            lineSizer.Add(wx.StaticText(dataDisplay,label=' Fourier map controls: Map type: '),0,wx.ALIGN_CENTER_VERTICAL)
    637651            mapType = wx.ComboBox(dataDisplay,-1,value=Map['MapType'],choices=mapTypes,
    638652                style=wx.CB_READONLY|wx.CB_DROPDOWN)
    639653            mapType.Bind(wx.EVT_COMBOBOX,OnMapType)
    640             mapSizer.Add(mapType,0,wx.ALIGN_CENTER_VERTICAL)
    641             mapSizer.Add(wx.StaticText(dataDisplay,label=' Reflection set from: '),0,wx.ALIGN_CENTER_VERTICAL)
     654            lineSizer.Add(mapType,0,wx.ALIGN_CENTER_VERTICAL)
     655            lineSizer.Add(wx.StaticText(dataDisplay,label=' Reflection set from: '),0,wx.ALIGN_CENTER_VERTICAL)
    642656            refList = wx.ComboBox(dataDisplay,-1,value=Map['RefList'],choices=refList,
    643657                style=wx.CB_READONLY|wx.CB_DROPDOWN)
    644658            refList.Bind(wx.EVT_COMBOBOX,OnRefList)
    645             mapSizer.Add(refList,0,wx.ALIGN_CENTER_VERTICAL)
    646             mapSizer.Add(wx.StaticText(dataDisplay,label=' Resolution: '),0,wx.ALIGN_CENTER_VERTICAL)
     659            lineSizer.Add(refList,0,wx.ALIGN_CENTER_VERTICAL)
     660            mapSizer.Add(lineSizer,0,wx.ALIGN_CENTER_VERTICAL)
     661            line2Sizer = wx.BoxSizer(wx.HORIZONTAL)
     662            line2Sizer.Add(wx.StaticText(dataDisplay,label=' Resolution: '),0,wx.ALIGN_CENTER_VERTICAL)
    647663            mapRes =  wx.TextCtrl(dataDisplay,value='%.2f'%(Map['Resolution']),style=wx.TE_PROCESS_ENTER)
    648664            mapRes.Bind(wx.EVT_TEXT_ENTER,OnResVal)       
    649665            mapRes.Bind(wx.EVT_KILL_FOCUS,OnResVal)
    650             mapSizer.Add(mapRes,0,wx.ALIGN_CENTER_VERTICAL)
     666            line2Sizer.Add(mapRes,0,wx.ALIGN_CENTER_VERTICAL)
     667            line2Sizer.Add(wx.StaticText(dataDisplay,label=' Peak cutoff %: '),0,wx.ALIGN_CENTER_VERTICAL)
     668            cutOff =  wx.TextCtrl(dataDisplay,value='%.1f'%(Map['cutOff']),style=wx.TE_PROCESS_ENTER)
     669            cutOff.Bind(wx.EVT_TEXT_ENTER,OnCutOff)       
     670            cutOff.Bind(wx.EVT_KILL_FOCUS,OnCutOff)
     671            line2Sizer.Add(cutOff,0,wx.ALIGN_CENTER_VERTICAL)
     672            mapSizer.Add(line2Sizer,0,wx.ALIGN_CENTER_VERTICAL)
    651673            return mapSizer
    652674               
     
    33553377        import scipy.fftpack as fft
    33563378        generalData = data['General']
    3357 #        for item in generalData:
    3358 #            print item,generalData[item]
    33593379        if not generalData['Map']['MapType']:
    33603380            print '**** ERROR - Fourier map not defined'
     
    34393459#                print line+'\n'
    34403460### keep this               
    3441                
     3461   
     3462    def OnSearchMaps(event):
     3463        generalData = data['General']
     3464        phaseName = generalData['Name']
     3465        SGData = generalData['SGData']
     3466        cell = generalData['Cell'][1:8]       
     3467        A = G2lat.cell2A(cell[:6])
     3468        drawingData = data['Drawing']
     3469        try:
     3470            mapData = generalData['Map']
     3471            contLevel = drawingData['contourLevel']*mapData['rhoMax']
     3472            rho = ma.array(mapData['rho'],mask=(mapData['rho']<contLevel))
     3473        except KeyError:
     3474            print '**** ERROR - Fourier map not defined'
     3475            return
     3476        indx = np.array(ma.nonzero(rho)).T
     3477        steps = 1./np.array(rho.shape)
     3478        rhoXYZ = indx*steps
     3479        print rhoXYZ
     3480        print 'search Fourier map'
    34423481       
    34433482    def OnTextureRefine(event):
     
    34683507            G2frame.dataFrame.SetMenuBar(G2frame.dataFrame.DataGeneral)
    34693508            G2frame.dataFrame.Bind(wx.EVT_MENU, OnFourierMaps, id=G2gd.wxID_FOURCALC)
     3509            G2frame.dataFrame.Bind(wx.EVT_MENU, OnSearchMaps, id=G2gd.wxID_FOURSEARCH)
    34703510            UpdateGeneral()
    34713511        elif text == 'Data':
     
    35163556    G2frame.dataFrame.SetMenuBar(G2frame.dataFrame.DataGeneral)
    35173557    G2frame.dataFrame.Bind(wx.EVT_MENU, OnFourierMaps, id=G2gd.wxID_FOURCALC)
     3558    G2frame.dataFrame.Bind(wx.EVT_MENU, OnSearchMaps, id=G2gd.wxID_FOURSEARCH)
    35183559    SetupGeneral()
    35193560    GeneralData = data['General']
  • trunk/GSASIIplot.py

    r521 r522  
    22672267    thermal motion ellipsoids and polyhedra
    22682268    '''
     2269    ForthirdPI = 4.0*math.pi/3.0
    22692270    generalData = data['General']
    22702271    cell = generalData['Cell'][1:7]
     2272    Vol = generalData['Cell'][7:8][0]
    22712273    Amat,Bmat = G2lat.cell2AB(cell)         #Amat - crystal to cartesian, Bmat - inverse
    22722274    A4mat = np.concatenate((np.concatenate((Amat,[[0],[0],[0]]),axis=1),[[0,0,0,1],]),axis=0)
     
    27262728    def Draw():
    27272729        if 'Map' in generalData:
     2730            VP = np.array(drawingData['viewPoint'][0])-np.array([.5,.5,.5])
    27282731            mapData = generalData['Map']
    27292732            contLevel = drawingData['contourLevel']*mapData['rhoMax']
     
    27322735            else:
    27332736                rho = ma.array(mapData['rho'],mask=(mapData['rho']<contLevel))
     2737            steps = 1./np.array(rho.shape)
     2738            incre = np.where(VP>0,VP%steps,VP%steps-steps)
     2739            Vsteps = -np.array(VP/steps,dtype='i')
     2740            rho = np.roll(np.roll(np.roll(rho,Vsteps[0],axis=0),Vsteps[1],axis=1),Vsteps[2],axis=2)
    27342741            indx = np.array(ma.nonzero(rho)).T
    2735             steps = 1./np.array(rho.shape)
    2736             rhoXYZ = indx*steps
    2737             radius = drawingData['mapSize']**2
     2742            rhoXYZ = indx*steps+VP-incre
     2743            Nc = len(rhoXYZ)
     2744            rcube = 2000.*Vol/(ForthirdPI*Nc)
     2745            rmax = math.exp(math.log(rcube)/3.)**2
     2746            radius = min(drawingData['mapSize']**2,rmax)
    27382747            view = np.array(drawingData['viewPoint'][0])
    27392748            Rok = np.sum(np.inner(Amat,rhoXYZ-view).T**2,axis=1)>radius
Note: See TracChangeset for help on using the changeset viewer.