Changeset 1210


Ignore:
Timestamp:
Jan 31, 2014 12:18:59 PM (8 years ago)
Author:
vondreele
Message:

constrast changed to substance
add absorption results to substances
begin models stuff

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASII.py

    r1208 r1210  
    15621562                rd.Sample)
    15631563            self.PatternTree.SetItemPyData(
    1564                 self.PatternTree.AppendItem(Id,text='Contrast'),
    1565                     {'Substances':{'vacuum':{'Elements':{},'Volume':1.0,'Density':0.0,'Scatt density':0.0}},
    1566                     'Contrast':0.0})
     1564                self.PatternTree.AppendItem(Id,text='Substances'),G2pdG.SetDefaultSubstances())
    15671565            self.PatternTree.SetItemPyData(
    1568                 self.PatternTree.AppendItem(Id,text='Models'),
    1569                 {})     #Fill in defaults here
     1566                self.PatternTree.AppendItem(Id,text='Models'),G2pdG.SetDefaultSASDModel())
    15701567            self.PatternTree.Expand(Id)
    15711568            self.PatternTree.SelectItem(Id)
  • trunk/GSASIIIO.py

    r1208 r1210  
    887887                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Reflection Lists'),{})
    888888            elif 'SASD' in name:             
    889                 G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Contrast'),
    890                     {'Substances':{'vacuum':{'Elements':{},'Volume':1.0,'Density':0.0,'Scatt density':0.0}},
    891                     'Contrast':0.0})
    892                 G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Models'),{})
     889                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Substances'),G2pdG.SetDefaultSubstances())
     890                G2frame.PatternTree.SetItemPyData(G2gd.GetPatternTreeItemId(G2frame,Id,'Models'),G2pdG.SetDefaultSASDModel())
    893891        else:
    894892            Id = G2frame.PatternTree.AppendItem(parent=G2frame.root,text=name+" Azm= %.2f"%(Azms[i]))
     
    909907                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Reflection Lists'),{})
    910908            elif 'SASD' in name:             
    911                 G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Contrast'),
    912                     {'Substances':{'vacuum':{'Elements':{},'Volume':1.0,'Density':0.0,'Scatt density':0.0}},
    913                     'Contrast':0.0})
    914                 G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Models'),{})
     909                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Substances'),G2pdG.SetDefaultSubstances())
     910                G2frame.PatternTree.SetItemPyData(G2frame.PatternTree.AppendItem(Id,text='Models'),G2pdG.SetDefaultSASDModel())
    915911            valuesdict = {
    916912                'wtFactor':1.0,
  • trunk/GSASIIgrid.py

    r1209 r1210  
    134134] = [wx.NewId() for item in range(1)]
    135135
    136 [ wxID_MODELCOPY,wxID_MODELFIT,wxID_CONTRASTADD,wxID_CONTRASTDELETE,wxID_ADDSUBSTANCE,
    137     wxID_LOADSUBSTANCE,
    138 ] = [wx.NewId() for item in range(6)]
     136[ wxID_MODELCOPY,wxID_MODELFIT,wxID_ELEMENTADD,wxID_ELEMENTDELETE,wxID_ADDSUBSTANCE,
     137    wxID_LOADSUBSTANCE,wxID_DELETESUBSTANCE,
     138] = [wx.NewId() for item in range(7)]
    139139
    140140[ wxID_SELECTPHASE,
     
    25282528        self.PostfillDataMenu()
    25292529       
    2530         #SASD/ Contrast calculator
    2531         self.ContrastMenu = wx.MenuBar()
    2532         self.PrefillDataMenu(self.ContrastMenu,helpType='Contrast')
    2533         self.ContrastEdit = wx.Menu(title='')
    2534         self.ContrastMenu.Append(menu=self.ContrastEdit, title='Edit')
    2535         self.ContrastEdit.Append(id=wxID_ADDSUBSTANCE, kind=wx.ITEM_NORMAL,text='Add substance',
    2536             help='Add new substance')
    2537         self.ContrastEdit.Append(id=wxID_LOADSUBSTANCE, kind=wx.ITEM_NORMAL,text='Load substance',
     2530        #SASD & REFL/ Substance editor
     2531        self.SubstanceMenu = wx.MenuBar()
     2532        self.PrefillDataMenu(self.SubstanceMenu,helpType='Substances')
     2533        self.SubstanceEdit = wx.Menu(title='')
     2534        self.SubstanceMenu.Append(menu=self.SubstanceEdit, title='Edit')
     2535        self.SubstanceEdit.Append(id=wxID_LOADSUBSTANCE, kind=wx.ITEM_NORMAL,text='Load substance',
    25382536            help='Load substance from file')
    2539         self.ContrastEdit.Append(id=wxID_CONTRASTADD, kind=wx.ITEM_NORMAL,text='Add elements',
     2537        self.SubstanceEdit.Append(id=wxID_ADDSUBSTANCE, kind=wx.ITEM_NORMAL,text='Add substance',
     2538            help='Add new substance to list')
     2539        self.SubstanceEdit.Append(id=wxID_DELETESUBSTANCE, kind=wx.ITEM_NORMAL,text='Delete substance',
     2540            help='Delete substance from list')           
     2541        self.SubstanceEdit.Append(id=wxID_ELEMENTADD, kind=wx.ITEM_NORMAL,text='Add elements',
    25402542            help='Add elements to substance')
    2541         self.ContrastEdit.Append(id=wxID_CONTRASTDELETE, kind=wx.ITEM_NORMAL,text='Delete elements',
     2543        self.SubstanceEdit.Append(id=wxID_ELEMENTDELETE, kind=wx.ITEM_NORMAL,text='Delete elements',
    25422544            help='Delete elements from substance')
    25432545        self.PostfillDataMenu()
     
    40044006        data = G2frame.PatternTree.GetItemPyData(item)
    40054007        G2pdG.UpdateModelsGrid(G2frame,data)
    4006     elif G2frame.PatternTree.GetItemText(item) == 'Contrast':
     4008    elif G2frame.PatternTree.GetItemText(item) == 'Substances':
    40074009        G2frame.PatternId = G2frame.PatternTree.GetItemParent(item)
    40084010        G2frame.PickId = item
    40094011        data = G2frame.PatternTree.GetItemPyData(item)
    4010         G2pdG.UpdateContrastGrid(G2frame,data)
     4012        G2pdG.UpdateSubstanceGrid(G2frame,data)
    40114013    elif G2frame.PatternTree.GetItemText(item) == 'Sample Parameters':
    40124014        G2frame.PatternId = G2frame.PatternTree.GetItemParent(item)
  • trunk/GSASIImath.py

    r1208 r1210  
    654654    :returns: float rho: scattering density in 10^10cm^-2;
    655655        if wave > 0 the includes f' contribution
     656    :returns: float mu: if wave>0 absorption coeff in cm^-1 ; otherwise 0
    656657   
    657658    '''
    658659    rho = 0
     660    mu = 0
    659661    if wave:
    660662        Xanom = XAnomAbs(Elements,wave)
     
    663665        if wave:
    664666            f0 += Xanom[El][0]
     667            mu += Xanom[El][2]*Elements[El]['Num']
    665668        rho += Elements[El]['Num']*f0
    666     return 28.179*rho/vol
     669    return 28.179*rho/vol,0.1*mu/vol
    667670   
    668671def wavekE(wavekE):
  • trunk/GSASIIpwdGUI.py

    r1208 r1210  
    6363
    6464def SetDefaultSample():
    65     'Needs a doc string'
     65    'Fills in default items for the Sample dictionary'
    6666    return {
    6767        'InstrName':'',
     
    7474        'Omega':0.0,'Chi':0.0,'Phi':0.0
    7575        }
     76       
     77def SetDefaultSASDModel():
     78    'Fills in default items for the SASD Models dictionary'   
     79    return {'Back':[0.0,False],'Size':{'MinMaxDiam':[50.,10000.],'Nbins':100,
     80        'Contrast':['vacuum','vacuum'],'Method':'MaxEnt','Distribution':[],
     81        'Shape':['Spheroid',1.0],'MaxEnt':{'Niter':100,'Precision':0.01,'Sky':1e-6},
     82        'IPG':{'Niter':100,'Approach':0.8},'Reg':{},},           
     83        'Unified':{'Levels':[],},           
     84        'Particle':{'Levels':[],},
     85        }
     86       
     87def SetDefaultSubstances():
     88    'Fills in default items for the SASD Substances dictionary'
     89    return {'Substances':{'vacuum':{'Elements':{},'Volume':1.0,'Density':0.0,'Scatt density':0.0}},
     90                    'Contrast':0.0}
    7691                         
    7792################################################################################
     
    20642079   
    20652080################################################################################
    2066 #####  SASD Contrast
     2081#####  SASD Substances
    20672082################################################################################
    20682083           
    2069 def UpdateContrastGrid(G2frame,data):
    2070     '''respond to selection of SASD Contrast data tree item.
     2084def UpdateSubstanceGrid(G2frame,data):
     2085    '''respond to selection of SASD Substance data tree item.
    20712086    '''
    20722087    import Substances as substFile
     
    20832098            dlg.Destroy()
    20842099        data['Substances'][name] = {'Elements':{},'Volume':1.0,'Density':1.0,
    2085             'Scatt density':0.0,'XAnom density':0.0}
     2100            'Scatt density':0.0,'XAnom density':0.0,'XAbsorption':0.0}
    20862101        subst = substFile.Substances[name]
    20872102        ElList = subst['Elements'].keys()
     
    21032118                    G2mth.Vol2Den(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])
    21042119            data['Substances'][name]['Scatt density'] = \
    2105                 G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])         
    2106             data['Substances'][name]['XAnom density'] = \
    2107                 G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
    2108         UpdateContrastGrid(G2frame,data)
     2120                G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])[0]
     2121            contrst,absorb = G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
     2122            data['Substances'][name]['XAnom density'] = contrst
     2123            data['Substances'][name]['XAbsorption'] = absorb
     2124                         
     2125        UpdateSubstanceGrid(G2frame,data)
    21092126   
    21102127    def OnAddSubstance(event):
     
    21142131            Name = dlg.GetValue()
    21152132            data['Substances'][Name] = {'Elements':{},'Volume':1.0,'Density':1.0,
    2116                 'Scatt density':0.0,'XAnom density':0.}
     2133                'Scatt density':0.0,'XAnom density':0.,'XAbsorption':0.}
    21172134        dlg.Destroy()
    2118         UpdateContrastGrid(G2frame,data)
     2135        AddElement(Name)
     2136        UpdateSubstanceGrid(G2frame,data)
     2137       
     2138    def OnDeleteSubstance(event):
     2139        TextList = []
     2140        for name in data['Substances']:
     2141            if name != 'vacuum':
     2142                TextList += [name,]
     2143        if not TextList:
     2144            return
     2145        dlg = wx.SingleChoiceDialog(G2frame, 'Which substance?', 'Select substance to delete', TextList, wx.CHOICEDLG_STYLE)
     2146        try:
     2147            if dlg.ShowModal() == wx.ID_OK:
     2148                name = TextList[dlg.GetSelection()]
     2149            else:
     2150                return
     2151        finally:
     2152            dlg.Destroy()
     2153        del(data['Substances'][name])
     2154        UpdateSubstanceGrid(G2frame,data)       
    21192155               
    21202156    def OnAddElement(event):       
     
    21332169        finally:
    21342170            dlg.Destroy()
     2171        AddElement(name)
     2172        UpdateSubstanceGrid(G2frame,data)
     2173       
     2174    def AddElement(name):
    21352175        ElList = data['Substances'][name]['Elements'].keys()
    21362176        dlg = G2elemGUI.PickElements(G2frame,ElList)
     
    21452185                    G2mth.Vol2Den(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])
    21462186                data['Substances'][name]['Scatt density'] = \
    2147                     G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])         
    2148                 data['Substances'][name]['XAnom density'] = \
    2149                     G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
     2187                    G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])[0]
     2188                contrst,absorb = G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
     2189                data['Substances'][name]['XAnom density'] = contrst
     2190                data['Substances'][name]['XAbsorption'] = absorb
    21502191        dlg.Destroy()
    2151         UpdateContrastGrid(G2frame,data)
     2192       
    21522193       
    21532194    def OnDeleteElement(event):
     
    21762217                    G2mth.Vol2Den(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])
    21772218                data['Substances'][name]['Scatt density'] = \
    2178                     G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])         
    2179                 data['Substances'][name]['XAnom density'] = \
    2180                     G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
    2181         UpdateContrastGrid(G2frame,data)
     2219                    G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])[0]
     2220                contrst,absorb = G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
     2221                data['Substances'][name]['XAnom density'] = contrst
     2222                data['Substances'][name]['XAbsorption'] = absorb
     2223        UpdateSubstanceGrid(G2frame,data)
    21822224               
    21832225    def SubstSizer():
     
    22102252                        G2mth.Den2Vol(data['Substances'][name]['Elements'],value)
    22112253            data['Substances'][name]['Scatt density'] = \
    2212                 G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])         
    2213             data['Substances'][name]['XAnom density'] = \
    2214                 G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
    2215             UpdateContrastGrid(G2frame,data)
     2254                G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'])[0]
     2255            contrst,absorb = G2mth.XScattDen(data['Substances'][name]['Elements'],data['Substances'][name]['Volume'],wave)         
     2256            data['Substances'][name]['XAnom density'] = contrst
     2257            data['Substances'][name]['XAbsorption'] = absorb
     2258            UpdateSubstanceGrid(G2frame,data)
    22162259       
    22172260        Indx = {}
    22182261        Pwr10 = unichr(0x0b9)+unichr(0x0b0)
    22192262        Pwrm2 = unichr(0x207b)+unichr(0x0b2)
     2263        Pwrm1 = unichr(0x207b)+unichr(0x0b9)
    22202264        substSizer = wx.BoxSizer(wx.VERTICAL)
    2221         substSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Substance list:'),
     2265        substSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Substance list: wavelength: %.5fA'%(wave)),
    22222266            0,wx.ALIGN_CENTER_VERTICAL)
    22232267        for name in data['Substances']:
     2268            G2gd.HorizontalLine(substSizer,G2frame.dataDisplay)   
    22242269            substSizer.Add(wx.StaticText(parent=G2frame.dataDisplay,label=' Data for '+name+':'),
    22252270                0,wx.ALIGN_CENTER_VERTICAL)
     
    22622307                    label=' Anomalous density : %.2f *10%scm%s'%(Substance['XAnom density'],Pwr10,Pwrm2)),
    22632308                    0,wx.ALIGN_CENTER_VERTICAL)               
    2264                
     2309                substSizer.Add(wx.StaticText(G2frame.dataDisplay,
     2310                    label=' X-ray absorption   : %.2f cm%s'%(Substance['XAbsorption'],Pwrm1)),
     2311                    0,wx.ALIGN_CENTER_VERTICAL)               
    22652312        return substSizer
    22662313           
     
    22692316    if G2frame.dataDisplay:
    22702317        G2frame.dataFrame.DestroyChildren()
    2271     G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.ContrastMenu)
     2318    G2gd.SetDataMenuBar(G2frame,G2frame.dataFrame.SubstanceMenu)
    22722319    if not G2frame.dataFrame.GetStatusBar():
    22732320        Status = G2frame.dataFrame.CreateStatusBar()
    22742321    G2frame.dataDisplay = wxscroll.ScrolledPanel(G2frame.dataFrame)
    2275     G2frame.dataFrame.SetLabel('Contrast calculator')
     2322    G2frame.dataFrame.SetLabel('Substances')
    22762323    G2frame.dataFrame.Bind(wx.EVT_MENU, OnLoadSubstance, id=G2gd.wxID_LOADSUBSTANCE)   
    22772324    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddSubstance, id=G2gd.wxID_ADDSUBSTANCE)   
    2278     G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddElement, id=G2gd.wxID_CONTRASTADD)
    2279     G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteElement, id=G2gd.wxID_CONTRASTDELETE)
     2325    G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteSubstance, id=G2gd.wxID_DELETESUBSTANCE)   
     2326    G2frame.dataFrame.Bind(wx.EVT_MENU, OnAddElement, id=G2gd.wxID_ELEMENTADD)
     2327    G2frame.dataFrame.Bind(wx.EVT_MENU, OnDeleteElement, id=G2gd.wxID_ELEMENTDELETE)
    22802328    mainSizer = wx.BoxSizer(wx.VERTICAL)
    22812329    mainSizer.Add(SubstSizer(),0)
     
    22892337    G2frame.dataDisplay.SetSize(Size)
    22902338    G2frame.dataFrame.setSizePosLeft(Size)   
    2291            
    22922339       
    22932340################################################################################
     
    22992346    '''
    23002347   
    2301     def FillDefaultModel():
    2302         data['Model'] = 'Size distribution'
    2303    
    23042348    def OnCopyModel(event):
    23052349        print 'copy model'
     
    23122356    if not G2frame.dataFrame.GetStatusBar():
    23132357        Status = G2frame.dataFrame.CreateStatusBar()
    2314     if not len(data):
    2315         FillDefaultModel()   
    23162358    G2frame.dataFrame.SetLabel('Modelling')
    23172359    G2frame.dataDisplay = wxscroll.ScrolledPanel(G2frame.dataFrame)
    23182360    G2frame.dataFrame.Bind(wx.EVT_MENU, OnCopyModel, id=G2gd.wxID_MODELCOPY)
    23192361    G2frame.dataFrame.Bind(wx.EVT_MENU, OnFitModel, id=G2gd.wxID_MODELFIT)
     2362    mainSizer = wx.BoxSizer(wx.VERTICAL)
    23202363
    23212364    mainSizer.Layout()   
Note: See TracChangeset for help on using the changeset viewer.