[proFit-list] Batch Processing: Gauss-Fit

pro Fit Support profit at quansoft.com
Tue Feb 3 10:39:24 CST 2015


Dear Fabian

I prefer to do this kind of operations in Python. It provides better interaction with pro Fit, while still allowing e.g. to iterate through the files in a directory. Here is a script that iterates through all files in a directory, imports each file as data file, runs a fit, and gets the fit result. The code below only gets the value of ‘Am-1’, which is parameter 7 of the Gaussian function, but this merely serves as an example:



import os

# the directory to iterate through, adapt this to your needs:
dataDir = '/Users/kurt/Documents/datafiles'

# select the function to fit and set its default parameters
pf.SelectObject(pf.GetFunctionObject(function = "Peaks.Gauss-Peaks"))
pf.SetParameterProperties(parameter = 1, value = 1)

# set the options for importing data from text files. Adapt this to your needs.
pf.DataImportOptions(mode = pf.withoutTitles, headerLines = 0, headerDelimiter = "", copyInfo = False, withTitles = False, titleDelimiter = "", titleLength = 0, lineFormat = "", lineLength = 0, terminator = "", useDoublequotes = False, checkForDates = False, dateFormat = "", useGMT = False)

# recusrively iterate through the directory 
for root, dirs, files in os.walk(dataDir):
    for name in files:
    
        # open the file
        p = os.path.join(root, name)
        print 'processing', p
        pf.OpenFile(file = p, type = pf.dataType)
    
        # run the fit
        fitObj = pf.FitCreate(function = 'Peaks.Gauss-Peaks')
        pf.FitSetExperiment(fitObject = fitObj, xColumn = 1, yColumn = 2)  
        fitResultObj = pf.FitExecute(fitObject = fitObj)
        
        # close the window
        pf.CloseWindow(window = name, saveOption = pf.dontSave)
    
        # get the fit result. In the Gaussian function, parameter ‘Am-1’ has index 7
        print 'Am-1 =', pf.FitResult(fitResultObject = fitResultObj, result = pf.fittedParameter, index1 = 7)
    
print 'done'


I hope this gets you started.

Best regards 

Kurt Sutter
QuantumSoft


> On 29 Jan 2015, at 2:22, Wohlfender Fabian <fabian.wohlfender at stud.unibas.ch> wrote:
> 
> Hi there,
> 
> I have to fit a many histograms (data stored in a text file) using a single gauss peak. Therefore I would like to set up a batch processing using an Apple Script approach. The manual and the tech note batch processing did not help much, therefor I am asking for your help/ support. I am using Mac OS X 10.7.5 and pro Fit 6.2.16.
> 
> I would need the following parameters of the calculated fit: Am-1 (amplitude of the gaussian), x0-1 (location of the peak on the x-axis), s-1 (half width at half maximum) and their errors.
> 
> I am truly grateful for your help.
> 
> Best regards
> Fabian Wohlfender
> _______________________________________________
> proFit-list mailing list
> proFit-list at quantum-soft.com
> http://quantum-soft.com/mailman/listinfo/profit-list_quantum-soft.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://quantum-soft.com/pipermail/profit-list_quantum-soft.com/attachments/20150203/ec90fa5c/attachment.html>


More information about the proFit-list mailing list