Changeset 1639


Ignore:
Timestamp:
Feb 9, 2015 3:11:16 PM (7 years ago)
Author:
vondreele
Message:

remove a couple of error messages from G2math.
implement use of multiple reflection sets for Fourier maps & charge flipping; both 3 & 4D cases - needed for neutron TOF single crystal data.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIImath.py

    r1635 r1639  
    16041604    '''
    16051605    generalData = data['General']
    1606     if not generalData['4DmapData']['RefList']:
    1607         print '**** ERROR - 4D Fourier map data not defined'
    1608         return
    16091606    mapData = generalData['4DmapData']
    16101607    dmin = mapData['Resolution']
     
    16601657    '''
    16611658    generalData = data['General']
    1662     if not generalData['Map']['MapType']:
    1663         print '**** ERROR - Fourier map not defined'
    1664         return
    16651659    mapData = generalData['Map']
    16661660    dmin = mapData['Resolution']
  • trunk/GSASIIphsGUI.py

    r1635 r1639  
    9393
    9494    '''
     95   
     96    def GetReflData(G2frame,phaseName,reflNames):
     97        ReflData = {'RefList':[],'Type':''}
     98        for reflName in reflNames:
     99            if 'PWDR' in reflName:
     100                PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
     101                reflSets = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
     102                reflData = reflSets[phaseName]
     103                if 'list' in str(type(reflData)):       #patch for old reflection data
     104                    RefData = {'RefList':[],'FF':[]}
     105                    for ref in reflDict:
     106                        RefData['RefList'].append(ref[:11]+[ref[13],])
     107                        RefData['FF'].append(ref[14])
     108                    RefData['RefList'] = np.array(RefData['RefList'])
     109                    reflData = RefData
     110            elif 'HKLF' in reflName:
     111                PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
     112                reflData = G2frame.PatternTree.GetItemPyData(PatternId)[1]
     113                if 'Type' not in reflData:
     114                    reflData['Type'] = 'SXC'
     115            if ReflData['Type'] and reflData['Type'] != ReflData['Type']:
     116                G2frame.ErrorDialog('Data type conflict',
     117                    reflName+' conflicts with previous '+ReflData['Type'])
     118                return None
     119            ReflData['RefList'] += list(reflData['RefList'])
     120            ReflData['Type'] = reflData['Type']
     121        return ReflData
    95122
    96123    # UpdatePhaseData execution continues below
     
    680707               
    681708            def OnRefList(event):
    682                 Map['RefList'] = refList.GetValue()
     709                dlg = G2gd.G2MultiChoiceDialog(G2frame, 'Select reflection sets to use',
     710                    'Use data',refsList,filterBox=False)
     711                try:
     712                    if dlg.ShowModal() == wx.ID_OK:
     713                        Map['RefList'] = [refsList[i] for i in dlg.GetSelections()]
     714                    else:
     715                        return
     716                finally:
     717                    dlg.Destroy()
     718                wx.CallAfter(UpdateGeneral)               
    683719               
    684720            def OnResVal(event):
     
    704740                Map['cutOff'] = 100.0
    705741            mapTypes = ['Fobs','Fcalc','delt-F','2*Fo-Fc','Omit','2Fo-Fc Omit','Patterson']
    706             refList = data['Histograms'].keys()
     742            refsList = data['Histograms'].keys()
    707743            if not generalData['AtomTypes']:
    708744                 mapTypes = ['Patterson',]
     
    711747            lineSizer = wx.BoxSizer(wx.HORIZONTAL)
    712748            lineSizer.Add(wx.StaticText(General,label=' Fourier map controls: Map type: '),0,WACV)
    713             mapType = wx.ComboBox(General,-1,value=Map['MapType'],choices=mapTypes,
     749            mapType = wx.ComboBox(General,value=Map['MapType'],choices=mapTypes,
    714750                style=wx.CB_READONLY|wx.CB_DROPDOWN)
    715751            mapType.Bind(wx.EVT_COMBOBOX,OnMapType)
    716752            lineSizer.Add(mapType,0,WACV)
    717             lineSizer.Add(wx.StaticText(General,label=' Reflection set from: '),0,WACV)
    718             refList = wx.ComboBox(General,-1,value=Map['RefList'],choices=refList,
    719                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    720             refList.Bind(wx.EVT_COMBOBOX,OnRefList)
     753            lineSizer.Add(wx.StaticText(General,label=' Reflection sets: '),0,WACV)
     754            if 'list' not in str(type(Map['RefList'])):     #patch
     755                Map['RefList'] = [Map['RefList'],]
     756            lineSizer.Add(wx.ComboBox(General,value=Map['RefList'][0],choices=Map['RefList'],
     757                style=wx.CB_DROPDOWN),0,WACV)
     758            refList = wx.Button(General,label='Select reflection sets')
     759            refList.Bind(wx.EVT_BUTTON,OnRefList)
    721760            lineSizer.Add(refList,0,WACV)
    722761            mapSizer.Add(lineSizer,0,WACV)
     
    739778           
    740779            def OnRefList(event):
    741                 Flip['RefList'] = refList.GetValue()
     780                dlg = G2gd.G2MultiChoiceDialog(G2frame, 'Select reflection sets to use',
     781                    'Use data',refsList,filterBox=False)
     782                try:
     783                    if dlg.ShowModal() == wx.ID_OK:
     784                        Flip['RefList'] = [refsList[i] for i in dlg.GetSelections()]
     785                    else:
     786                        return
     787                finally:
     788                    dlg.Destroy()
     789                wx.CallAfter(UpdateGeneral)               
    742790               
    743791            def OnNormElem(event):
     
    775823                kMax.SetValue("%.1f"%(Flip['k-Max']))          #reset in case of error
    776824
    777             refList = data['Histograms'].keys()
     825            refsList = data['Histograms'].keys()
    778826            flipSizer = wx.BoxSizer(wx.VERTICAL)
    779827            lineSizer = wx.BoxSizer(wx.HORIZONTAL)
    780             lineSizer.Add(wx.StaticText(General,label=' Charge flip controls: Reflection set from: '),0,WACV)
    781             refList = wx.ComboBox(General,-1,value=Flip['RefList'],choices=refList,
    782                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    783             refList.Bind(wx.EVT_COMBOBOX,OnRefList)
     828            lineSizer.Add(wx.StaticText(General,label=' Charge flip controls: Reflection sets: '),0,WACV)
     829            if 'list' not in str(type(Flip['RefList'])):     #patch
     830                Flip['RefList'] = [Flip['RefList'],]
     831            lineSizer.Add(wx.ComboBox(General,value=Flip['RefList'][0],choices=Flip['RefList'],
     832                style=wx.CB_DROPDOWN),0,WACV)
     833            refList = wx.Button(General,label='Select reflection sets')
     834            refList.Bind(wx.EVT_BUTTON,OnRefList)
    784835            lineSizer.Add(refList,0,WACV)
    785836            lineSizer.Add(wx.StaticText(General,label=' Normalizing element: '),0,WACV)
     
    21402191
    21412192            def OnRefList(event):
    2142                 Map['RefList'] = refList.GetValue()
     2193                dlg = G2gd.G2MultiChoiceDialog(G2frame, 'Select reflection sets to use',
     2194                    'Use data',refsList,filterBox=False)
     2195                try:
     2196                    if dlg.ShowModal() == wx.ID_OK:
     2197                        Map['RefList'] = [refsList[i] for i in dlg.GetSelections()]
     2198                    else:
     2199                        return
     2200                finally:
     2201                    dlg.Destroy()
     2202                UpdateWavesData()
    21432203               
    21442204            def OnMapType(event):
     
    21462206               
    21472207            Map['Resolution'] = 0.25
    2148             refList = data['Histograms'].keys()
     2208            refsList = data['Histograms'].keys()
    21492209            mapSizer = wx.BoxSizer(wx.HORIZONTAL)
     2210           
    21502211            mapSizer.Add(wx.StaticText(waveData,label=' 4D map data: Reflection set from: '),0,WACV)
    2151             refList = wx.ComboBox(waveData,-1,value=Map['RefList'],choices=refList,
    2152                 style=wx.CB_READONLY|wx.CB_DROPDOWN)
    2153             refList.Bind(wx.EVT_COMBOBOX,OnRefList)
     2212            if 'list' not in str(type(Map['RefList'])):     #patch
     2213                Map['RefList'] = [Map['RefList'],]
     2214            mapSizer.Add(wx.ComboBox(waveData,value=Map['RefList'][0],choices=Map['RefList'],
     2215                style=wx.CB_DROPDOWN),0,WACV)
     2216            refList = wx.Button(waveData,label='Select reflection sets')
     2217            refList.Bind(wx.EVT_BUTTON,OnRefList)
    21542218            mapSizer.Add(refList,0,WACV)
     2219           
    21552220            mapTypes = ['Fobs','delt-F']
    21562221            mapSizer.Add(wx.StaticText(waveData,label=' Map type: '),0,WACV)
     
    22022267        generalData = data['General']
    22032268        mapData = generalData['4DmapData']
    2204         reflName = mapData['RefList']
     2269        reflNames = mapData['RefList']
    22052270        generalData['Map']['Flip'] = False
    2206         if not reflName:
    2207             G2frame.ErrorDialog('Fourier map','No reflections defined for Fourier map')
     2271        if not len(reflNames):
     2272            G2frame.ErrorDialog('Fourier map error','No reflections defined for Fourier map')
    22082273            return
    22092274        phaseName = generalData['Name']
    2210         if 'PWDR' in reflName:
    2211             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    2212             reflSets = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    2213             reflData = reflSets[phaseName]
    2214         elif 'HKLF' in reflName:
    2215             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    2216             reflData = G2frame.PatternTree.GetItemPyData(PatternId)[1]
    2217         mapData.update(G2mth.Fourier4DMap(data,reflData))
     2275        ReflData = GetReflData(G2frame,phaseName,reflNames)
     2276        if ReflData == None: return
     2277        mapData.update(G2mth.Fourier4DMap(data,ReflData))
    22182278        mapSig = np.std(mapData['rho'])
    22192279        print mapData['MapType']+' computed: rhomax = %.3f rhomin = %.3f sigma = %.3f'%(np.max(mapData['rho']),np.min(mapData['rho']),mapSig)
     
    55155575        generalData = data['General']
    55165576        mapData = generalData['Map']
    5517         reflName = mapData['RefList']
    5518         if not reflName:
    5519             G2frame.ErrorDialog('Fourier map','No reflections defined for Fourier map')
     5577        reflNames = mapData['RefList']
     5578        if not generalData['Map']['MapType']:
     5579            G2frame.ErrorDialog('Fourier map error','Fourier map type not defined')
     5580            return
     5581        if not len(reflNames):
     5582            G2frame.ErrorDialog('Fourier map error','No reflections defined for Fourier map')
    55205583            return
    55215584        phaseName = generalData['Name']
    5522         if 'PWDR' in reflName:
    5523             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    5524             reflSets = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    5525             reflData = reflSets[phaseName]
    5526             if 'list' in str(type(reflData)):       #patch for old reflection data
    5527             #if isinstance(reflData,list):       #patch for old reflection data
    5528                 RefData = {'RefList':[],'FF':[]}
    5529                 for ref in reflData:
    5530                     RefData['RefList'].append(ref[:11]+[ref[13],])
    5531                     RefData['FF'].append(ref[14])
    5532                 RefData['RefList'] = np.array(RefData['RefList'])
    5533                 reflData = RefData
    5534         elif 'HKLF' in reflName:
    5535             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    5536             reflData = G2frame.PatternTree.GetItemPyData(PatternId)[1]
     5585        ReflData = GetReflData(G2frame,phaseName,reflNames)
     5586        if ReflData == None: return
    55375587        if 'Omit' in mapData['MapType']:
    55385588            pgbar = wx.ProgressDialog('Omit map','Blocks done',65,
    55395589            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE)
    5540             mapData.update(G2mth.OmitMap(data,reflData,pgbar))
     5590            mapData.update(G2mth.OmitMap(data,ReflData,pgbar))
    55415591            pgbar.Destroy()
    55425592        else:
    5543             mapData.update(G2mth.FourierMap(data,reflData))
     5593            mapData.update(G2mth.FourierMap(data,ReflData))
    55445594        mapData['Flip'] = False
    55455595        mapSig = np.std(mapData['rho'])
     
    56165666        map4DData = generalData['4DmapData']
    56175667        flipData = generalData['Flip']
    5618         reflName = flipData['RefList']
     5668        reflNames = flipData['RefList']
     5669        if not len(reflNames):
     5670            G2frame.ErrorDialog('Charge flip error','No reflections defined for charge flipping')
     5671            return
    56195672        phaseName = generalData['Name']
    5620         if 'PWDR' in reflName:
    5621             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    5622             reflSets = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    5623             reflDict = reflSets[phaseName]
    5624         elif 'HKLF' in reflName:
    5625             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    5626             reflDict = G2frame.PatternTree.GetItemPyData(PatternId)[1]
    5627         else:
    5628             print '**** ERROR - No data defined for charge flipping'
    5629             return
     5673        ReflData = GetReflData(G2frame,phaseName,reflNames)
     5674        if ReflData == None: return
    56305675        pgbar = wx.ProgressDialog('Charge flipping','Residual Rcf =',101.0,
    56315676            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT)
     
    56365681            pgbar.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    56375682        try:
    5638             newMap,new4Dmap = G2mth.SSChargeFlip(data,reflDict,pgbar)
     5683            newMap,new4Dmap = G2mth.SSChargeFlip(data,ReflData,pgbar)
    56395684        finally:
    56405685            pgbar.Destroy()
     
    56575702        mapData = generalData['Map']
    56585703        flipData = generalData['Flip']
    5659         reflName = flipData['RefList']
     5704        reflNames = flipData['RefList']
     5705        if not len(reflNames):
     5706            G2frame.ErrorDialog('Charge flip error','No reflections defined for charge flipping')
     5707            return
    56605708        phaseName = generalData['Name']
    5661         if 'PWDR' in reflName:
    5662             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    5663             reflSets = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(G2frame,PatternId,'Reflection Lists'))
    5664             reflDict = reflSets[phaseName]
    5665             if 'list' in str(type(reflDict)):       #patch for old reflection data
    5666                 RefData = {'RefList':[],'FF':[]}
    5667                 for ref in reflDict:
    5668                     RefData['RefList'].append(ref[:11]+[ref[13],])
    5669                     RefData['FF'].append(ref[14])
    5670                 RefData['RefList'] = np.array(RefData['RefList'])
    5671                 reflDict = RefData
    5672         elif 'HKLF' in reflName:
    5673             PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root, reflName)
    5674             reflDict = G2frame.PatternTree.GetItemPyData(PatternId)[1]
    5675         else:
    5676             print '**** ERROR - No data defined for charge flipping'
    5677             return
     5709        ReflData = GetReflData(G2frame,phaseName,reflNames)
     5710        if ReflData == None: return
    56785711        pgbar = wx.ProgressDialog('Charge flipping','Residual Rcf =',101.0,
    56795712            style = wx.PD_ELAPSED_TIME|wx.PD_AUTO_HIDE|wx.PD_CAN_ABORT)
     
    56845717            pgbar.SetPosition(wx.Point(screenSize[2]-Size[0]-305,screenSize[1]+5))
    56855718        try:
    5686             mapData.update(G2mth.ChargeFlip(data,reflDict,pgbar))
     5719            mapData.update(G2mth.ChargeFlip(data,ReflData,pgbar))
    56875720        finally:
    56885721            pgbar.Destroy()
Note: See TracChangeset for help on using the changeset viewer.