Changeset 4201


Ignore:
Timestamp:
Dec 14, 2019 9:02:47 AM (22 months ago)
Author:
vondreele
Message:

add new chebyschev-1 background function; matches that from old gsas. It is default for new projects & is better behaved than chebyschev.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIIO.py

    r4198 r4201  
    907907        G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Limits'),copy.deepcopy([tuple(Xminmax),Xminmax]))
    908908        if 'PWDR' in Aname:
    909             G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Background'),[['chebyschev',1,3,1.0,0.0,0.0],
     909            G2frame.GPXtree.SetItemPyData(G2frame.GPXtree.AppendItem(Id,text='Background'),[['chebyschev-1',1,3,1.0,0.0,0.0],
    910910                {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    911911        inst = [dict(zip(names,zip(parms,parms,codes))),{}]
  • trunk/GSASIIctrlGUI.py

    r4155 r4201  
    58995899                    G2frame.GPXtree.AppendItem(Id,text='Background'),
    59005900                    rd.pwdparms.get('Background',
    5901                         [['chebyschev',True,3,1.0,0.0,0.0],{'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
     5901                        [['chebyschev-1',True,3,1.0,0.0,0.0],{'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    59025902                        )
    59035903                G2frame.GPXtree.SetItemPyData(
  • trunk/GSASIIdataGUI.py

    r4200 r4201  
    17471747                self.GPXtree.AppendItem(Id,text='Background'),
    17481748                rd.pwdparms.get('Background',
    1749                     [['chebyschev',True,3,1.0,0.0,0.0],{'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
     1749                    [['chebyschev-1',True,3,1.0,0.0,0.0],{'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    17501750                    )
    17511751            self.GPXtree.SetItemPyData(
     
    19431943        self.GPXtree.SetItemPyData(
    19441944            self.GPXtree.AppendItem(Id,text='Background'),
    1945             [['chebyschev',True,3,1.0,0.0,0.0],
     1945            [['chebyschev-1',True,3,1.0,0.0,0.0],
    19461946             {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    19471947        self.GPXtree.SetItemPyData(
     
    20772077        self.GPXtree.SetItemPyData(
    20782078            self.GPXtree.AppendItem(Id,text='Background'),
    2079             [['chebyschev',True,3,1.0,0.0,0.0],
     2079            [['chebyschev-1',True,3,1.0,0.0,0.0],
    20802080             {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    20812081        self.GPXtree.SetItemPyData(
     
    34923492                        self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='Comments'),Comments)                   
    34933493                        self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='Limits'),[tuple(Xminmax),Xminmax])
    3494                         self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='Background'),[['chebyschev',True,3,1.0,0.0,0.0],
     3494                        self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='Background'),[['chebyschev-1',True,3,1.0,0.0,0.0],
    34953495                            {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}])
    34963496                        self.GPXtree.SetItemPyData(self.GPXtree.AppendItem(Id,text='Instrument Parameters'),Inst)
  • trunk/GSASIIpwd.py

    r4200 r4201  
    855855            break
    856856#empirical functions
    857     if bakType in ['chebyschev','cosine']:
     857    if bakType in ['chebyschev','cosine','chebyschev-1']:
    858858        dt = xdata[-1]-xdata[0]   
    859859        for iBak in range(nBak):
     
    861861            if bakType == 'chebyschev':
    862862                ybi = parmDict[key]*(-1.+2.*(xdata-xdata[0])/dt)**iBak
     863            elif bakType == 'chebyschev-1':
     864                xpos = -1.+2.*(xdata-xdata[0])/dt
     865                ybi = parmDict[key]*np.cos(iBak*np.arccos(xpos))
    863866            elif bakType == 'cosine':
    864867                ybi = parmDict[key]*npcosd(180.*xdata*iBak/xdata[-1])
     
    989992    cw = np.append(cw,cw[-1])
    990993
    991     if bakType in ['chebyschev','cosine']:
     994    if bakType in ['chebyschev','cosine','chebyschev-1']:
    992995        dt = xdata[-1]-xdata[0]   
    993996        for iBak in range(nBak):   
    994997            if bakType == 'chebyschev':
    995998                dydb[iBak] = (-1.+2.*(xdata-xdata[0])/dt)**iBak
     999            elif bakType == 'chebyschev-1':
     1000                xpos = -1.+2.*(xdata-xdata[0])/dt
     1001                dydb[iBak] = np.cos(iBak*np.arccos(xpos))
    9961002            elif bakType == 'cosine':
    9971003                dydb[iBak] = npcosd(180.*xdata*iBak/xdata[-1])
  • trunk/GSASIIpwdGUI.py

    r4194 r4201  
    16681668    G2frame.Bind(wx.EVT_MENU,OnBkgClear,id=G2frame.dataWindow.wxID_BackPts['Clear'])   
    16691669    BackId = G2gd.GetGPXtreeItemId(G2frame,G2frame.PatternId, 'Background')
    1670     Choices = ['chebyschev','cosine','Q^2 power series','Q^-2 power series','lin interpolate','inv interpolate','log interpolate']
     1670    Choices = ['chebyschev','chebyschev-1','cosine','Q^2 power series','Q^-2 power series','lin interpolate','inv interpolate','log interpolate']
    16711671    G2frame.dataWindow.ClearData()
    16721672    mainSizer = G2frame.dataWindow.GetSizer()
  • trunk/GSASIIscriptable.py

    r4198 r4201  
    4343    gpx.histogram(0).add_back_peak(4.5,30000,5000,0)
    4444    pardict = {'set': {'Sample Parameters': ['Absorption', 'Contrast', 'DisplaceX'],
    45                        'Background': {'type': 'chebyschev', 'refine': True,
     45                       'Background': {'type': 'chebyschev-1', 'refine': True,
    4646                                      'peaks':[[0,True]]}}}
    4747    gpx.set_refinement(pardict)
     
    273273    pardict = {'set': { 'Limits': [0.8, 12.0],
    274274                       'Sample Parameters': ['Absorption', 'Contrast', 'DisplaceX'],
    275                        'Background': {'type': 'chebyschev', 'refine': True,
     275                       'Background': {'type': 'chebyschev-1', 'refine': True,
    276276                                      'peaks':[[0,True],[1,1,1]] }},
    277277              'clear': {'Instrument Parameters': ['U', 'V', 'W']}}
     
    294294    pardict = {'set': { 'Limits': [0.8, 12.0],
    295295                       'Sample Parameters': ['Absorption', 'Contrast', 'DisplaceX'],
    296                        'Background': {'type': 'chebyschev', 'refine': True}},
     296                       'Background': {'type': 'chebyschev-1', 'refine': True}},
    297297              'clear': {'Instrument Parameters': ['U', 'V', 'W']}}
    298298    my_project.do_refinements([pardict])
     
    484484                                            When value is a dict,
    485485                                            supply any of the following keys:
    486 \                     type                  The background model, e.g. 'chebyschev'
     486\                     type                  The background model, e.g. 'chebyschev-1'
    487487\                     refine                The value of the refine flag, boolean
    488488\                     'no. coeffs'          Number of coefficients to use, integer
     
    617617    params = { 'Limits': [0.8, 12.0],
    618618               'Sample Parameters': ['Absorption', 'Contrast', 'DisplaceX'],
    619                'Background': {'type': 'chebyschev', 'refine': True}}
     619               'Background': {'type': 'chebyschev-1', 'refine': True}}
    620620    some_histogram.set_refinements(params)
    621621
     
    694694                                    fmthint='GSAS powder')
    695695    hist.set_refinements({'Limits': [16.,24.],
    696           'Background': {"no. coeffs": 2,'type': 'chebyschev', 'refine': True}
     696          'Background': {"no. coeffs": 2,'type': 'chebyschev-1', 'refine': True}
    697697                         })
    698698    peak1 = hist.add_peak(1, ttheta=16.8)
     
    16531653    Tmax = np.max(reader.powderdata[0])
    16541654
    1655     default_background = [['chebyschev', False, 3, 1.0, 0.0, 0.0],
     1655    default_background = [['chebyschev-1', False, 3, 1.0, 0.0, 0.0],
    16561656                          {'nDebye': 0, 'debyeTerms': [], 'nPeaks': 0, 'peaksList': []}]
    16571657
     
    55495549                section = 'Background'
    55505550                histItems += [section]
    5551                 HistDict[section] = [['chebyschev',1,3,1.0,0.0,0.0],
     5551                HistDict[section] = [['chebyschev-1',1,3,1.0,0.0,0.0],
    55525552                    {'nDebye':0,'debyeTerms':[],'nPeaks':0,'peaksList':[]}]
    55535553            inst = [dict(zip(names,zip(parms,parms,codes))),{}]
Note: See TracChangeset for help on using the changeset viewer.