User Tools

Site Tools


ufit:help:tips

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ufit:help:tips [2017/10/23 10:12] pcermakufit:help:tips [2017/10/24 07:28] (current) – [Fit curve from the file] pcermak
Line 21: Line 21:
              aa.data.meta.title += ', stt=%0.2f' % aa.data.meta.gamma              aa.data.meta.title += ', stt=%0.2f' % aa.data.meta.gamma
  
-===== Fit background from the file =====+===== Fit curve from the file =====
  
 It is possible to have a spectrum/background stored as a xy points in ASCII datafile. This command will load that file, interpolate between the loaded values and then fit the scale of such model. Just add this line to the **Model definition**: It is possible to have a spectrum/background stored as a xy points in ASCII datafile. This command will load that file, interpolate between the loaded values and then fit the scale of such model. Just add this line to the **Model definition**:
            
-     Custom('MyBg', 'scale', "scipy.interpolate.interp1d(numpy.loadtxt('I:\Documents\Playground\sinus.txt').T[0], numpy.loadtxt('I:\Documents\Playground\sinus.txt').T[1], kind='cubic')(x) * scale")+     Custom('MyBg', 'scale', "(lambda data: scipy.interpolate.interp1d(data[0], data[1], kind='cubic')(x) * scale)(numpy.loadtxt('C:\bg.txt').T)") 
 + 
 +Replace **C:\bg.txt** with path to your ASCII file. **MyBg** can be also changed - this is just name of your model.
ufit/help/tips.1508753527.txt.gz · Last modified: 2017/10/23 10:12 by pcermak