Changeset 2170


Ignore:
Timestamp:
Mar 14, 2016 9:13:28 AM (7 years ago)
Author:
vondreele
Message:

fix isotope problem for atyoms with no "Nat. Abund."
add scale & background to stacking simulation - still under development

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIphsGUI.py

    r2167 r2170  
    291291                generalData['vdWRadii'].append(Info['Vdrad'])
    292292                if atom[ct] in generalData['Isotope']:
     293                    if generalData['Isotope'][atom[ct]] not in generalData['Isotopes'][atom[ct]]:
     294                        isotope = generalData['Isotopes'][atom[ct]].keys()[-1]
     295                        generalData['Isotope'][atom[ct]] = isotope
    293296                    generalData['AtomMass'].append(Info['Isotopes'][generalData['Isotope'][atom[ct]]]['Mass'])
    294297                else:
    295298                    generalData['Isotope'][atom[ct]] = 'Nat. Abund.'
     299                    if 'Nat. Abund.' not in generalData['Isotopes'][atom[ct]]:
     300                        isotope = generalData['Isotopes'][atom[ct]].keys()[-1]
     301                        generalData['Isotope'][atom[ct]] = isotope
    296302                    generalData['AtomMass'].append(Info['Mass'])
    297303                generalData['NoAtoms'][atom[ct]] = atom[cs-1]*float(atom[cs+1])
     
    624630                item = Indx[Obj.GetId()]
    625631                isotope = Obj.GetValue()
    626                 generalData['Isotope'][item] = isotope
     632                data['General']['Isotope'][item] = isotope
    627633                indx = generalData['AtomTypes'].index(item)
    628634                data['General']['AtomMass'][indx] = generalData['Isotopes'][item][isotope]['Mass']
     
    677683                colorTxt.SetBackgroundColour(wx.Colour(R,G,B))
    678684                elemSizer.Add(colorTxt,0,WACV)
     685           
    679686            return elemSizer
    680687       
     
    28852892        PWDR = data['Histograms'][HistName]
    28862893        G2frame.PatternId = G2gd.GetPatternTreeItemId(G2frame,G2frame.root,HistName)
    2887        
     2894        sample = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
     2895            G2frame,G2frame.PatternId, 'Sample Parameters'))
     2896        scale = sample['Scale'][0]
     2897        background = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
     2898            G2frame,G2frame.PatternId, 'Background'))       
    28882899        limits = G2frame.PatternTree.GetItemPyData(G2gd.GetPatternTreeItemId(
    28892900            G2frame,G2frame.PatternId, 'Limits'))[1]
     
    28932904            wx.MessageBox("Can't simulate neutron TOF patterns yet",caption='Data error',style=wx.ICON_EXCLAMATION)
    28942905            return           
    2895         profile = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)[1]
    2896            
    2897         G2pwd.StackSim(data['Layers'],HistName,limits,inst,profile)
     2906        profile = G2frame.PatternTree.GetItemPyData(G2frame.PatternId)[1]           
     2907        G2pwd.StackSim(data['Layers'],HistName,scale,background,limits,inst,profile)
    28982908        G2plt.PlotPatterns(G2frame,plotType='PWDR')
    28992909       
  • trunk/GSASIIpwd.py

    r2167 r2170  
    17371737################################################################################
    17381738
    1739 def StackSim(Layers,HistName,limits,inst,profile):
     1739def StackSim(Layers,HistName,scale,background,limits,inst,profile):
    17401740    '''Simulate powder pattern from stacking faults using DIFFaX
    17411741   
     
    17441744                        'Layers':[],'Stacking':[],'Transitions':[]}
    17451745    param: HistName str: histogram name to simulate 'PWDR...'
     1746    param: scale float: scale factor
     1747    param: background dict: background parameters
    17461748    param: limits list: min/max 2-theta to be calculated
    17471749    param: inst dict: instrumnet parameters dictionary
     
    17791781    iBeg = np.searchsorted(x0,limits[0])
    17801782    iFin = np.searchsorted(x0,limits[1])
     1783    if iFin-iBeg > 20000:
     1784        iFin = iBeg+19999
    17811785    x = x0[iBeg:iFin]
    17821786    dx = x0[iBeg+1]-x0[iBeg]
     
    18511855    print 'DIFFaX time = %.2fs'%(time.time()-time0)
    18521856    X = np.loadtxt('GSASII-DIFFaX.spc')
    1853     profile[3][:len(X.T[1])] = X.T[1]
     1857    bakType,backDict,backVary = SetBackgroundParms(background)
     1858    backDict['Lam1'] = G2mth.getWave(inst)
     1859#    GSASIIpath.IPyBreak()
     1860    iB = np.searchsorted(profile[0],X.T[0])[0]
     1861    iF = np.searchsorted(profile[0],X.T[-1])[0]
     1862    if not iF:
     1863        iF = -1
     1864    profile[4][iB:iF] = getBackground('',backDict,bakType,inst['Type'][0],X.T[0])[0]   
     1865    profile[3][iB:iF] = X.T[1]*scale+profile[4][iB:iF]
     1866    if not np.any(profile[1]):                   #fill dummy data x,y,w,yc,yb,yd
     1867        rv = st.poisson(profile[3][iB:iF])
     1868        profile[1][iB:iF] = rv.rvs()
     1869        Z = np.ones_like(profile[3][iB:iF])
     1870        Z[1::2] *= -1
     1871        profile[1][iB:iF] = profile[3][iB:iF]+np.abs(profile[1][iB:iF]-profile[3][iB:iF])*Z
     1872        profile[2][iB:iF] = np.where(profile[1][iB:iF]>0.,1./profile[1][iB:iF],1.0)
     1873    profile[5][iB:iF] = profile[1][iB:iF]-profile[3][iB:iF]
     1874
     1875
    18541876    #cleanup files..
    18551877    os.remove('data.sfc')
Note: See TracChangeset for help on using the changeset viewer.