Erste Seite Zurück Weiter Letzte Seite Übersicht Bilder

Daten-getriebene Anpassung

Die Methode kafe.file_tools.build_fit_from_file()

ermöglicht es, einfache Anpassungen

vollständig über eine Datei zu steuern:

import sys, matplotlib.pyplot as plt, kafe

from kafe.file_tools import buildFit_fromFile

# check for / read command line arguments

if len(sys.argv)==2:

fname=sys.argv[1]

else:

fname='data.fit'

print '*==* script ' + sys.argv[0]+ ' executing \n',\

' processing file ' + fname

# initialize fit object from file and run fit

theFit = buildFit_fromFile(fname)

theFit.do_fit()

thePlot = kafe.Plot(theFit)

thePlot.plot_all( show_info_for=None)

#thePlot.save(fname.split('.')[0]+'.pdf') #

#theFit.plot_correlations() # eventually contours

# show everything on screen

thePlot.show()

Skript kafe_fit-from-file.py

# example showing fit driven by input file

# ----------------------------------------

# this file is to be parsed with

# kafe.file_tools.buildFit_fromFile()

# Meta data for plotting

*BASENAME quadraticFitExample

*TITLE some test-data

*xLabel $x$

*xUnit

*yLabel $f(x)$

*yUnit

# the data

*xData

0.50 0.1

1.00 0.1

- - - -

9.50 0.1

10.00 0.1

*yData

0.45 0.1

0.82 0.1

- - - -

7.07 0.1

7.29 0.1

*FITLABEL quadratic function of x

*FitFunction

def fitf(x,a,b,c):

~~return a*x**2 + b*x +c

*InitialParameters # set initial values and range

0. 0.5

1. 0.5

0. 0.5

Datei data.fit