Commit d1738aff authored by Carlson Moses Büth's avatar Carlson Moses Büth 🌝

added functions-class and class descriptions

parent 18f32be6
# Class for composing functions
import numpy as np #Liefert wichtige Rechenfunktionen und numpy-arrays; vergleichsweise schnelle Befehle
import uncertainties as uc #Rechnen mit Größen, die fehlerbehaftet sind.
from uncertainties import ufloat as uf
......
# Class for integrated Fit+Plot Functions
import numpy as np #Liefert wichtige Rechenfunktionen und numpy-arrays; vergleichsweise schnelle Befehle
import uncertainties as uc #Rechnen mit Größen, die fehlerbehaftet sind.
import matplotlib.pyplot as plt
from scipy.odr import *
import uncertainties.unumpy as unp
unv=unp.nominal_values
usd=unp.std_devs
def fitOdrXYun(func, x, y, sx = None, sy = None, startW = [1]):
data = RealData(x, y, sx, sy)
func_model = Model(func)
odr = ODR(data, func_model, beta0 = startW)
out = odr.run()
for index, item in enumerate(out.beta):
print(out.beta[index], '\t', out.sd_beta[index])
out.pprint() #zum Debuggen nutzlich (wenn Fit nicht konvergiert)
d = (max(x)-min(x))/20
x_fit = np.linspace(min(x)-d, max(x)+d, 200)
y_fit = func(out.beta, x_fit)
plt.errorbar(x, y, sy, sx, linestyle='None', fmt='.', capsize=5, linewidth=2, zorder = 5)
plt.plot(x_fit,y_fit, "--", alpha=1, zorder = 6)
return out.beta, out.sd_beta
\ No newline at end of file
# Functions used to fit
def getAllFunctions():
inspect.getmembers(self, predicate=inspect.ismethod)
def constFunc(p, x):
(c) = p
return 0*x +c
def linFunc(p, x):
(m, c) = p
return m*x + c
def quadFunc(p, x)
(m, x0, c)
return m*(x-x0)**2 + c
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment