Пример #1
0
    
    #Kill alles was kleiner als 0.050 bar ist
    dat_Num1 = dat_Num1[dat_Num1>0.1]
    
    #Nur bis zum maximalen Druck anzeigen
    dat_Num1 = dat_Num1[1:dat_Num1.argmax()]
    dat_Num1 = dat_Num1[dat_Num1<dat_Num1.max()*0.98]
    return dat_Num1

dat_Num=daten_lesen('Caro-Ringstaub 250g__Kanal1_230712.txt')
zeit_achse = N.arange(N.size(dat_Num))*0.002
max_value = dat_Num.max()

dat_Num2=dat_Num
mat = N.column_stack((zeit_achse[:,N.newaxis],dat_Num2[:,N.newaxis]))
res = minuit_wrapper(fitfunc_logist, mat)


#plt.subplot(211)
#plt.plot(mat[:,0],mat[:,1])
plt.plot(mat[:,0],(fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G'])),'+')
plt.plot(mat[:,0],(fitfunc_logist(mat[:,0],res.values['k']+2,res.values['c'],res.values['G'])),'-')
plt.ylabel(r"Druck [bar]", fontsize = 12)

text_fr= 'Parameters \n G : %3.3f\n k : %3.3f\n c : %3.3f\n'%(res.values['G'],res.values['k'],res.values['c'])
plt.text(0.005,max_value*0.5,text_fr)


#ableitung = res.values['k']*fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G'])*(res.values['G']-fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G']))
#ableitung_1 = (res.values['k']-res.errors['k'])*fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G'])*(res.values['G']-fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G']))
#ableitung_2 = (res.values['k']+res.errors['k'])*fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G'])*(res.values['G']-fitfunc_logist(mat[:,0],res.values['k'],res.values['c'],res.values['G']))
Пример #2
0
# Daten aus der kinetik.datei auslesen
data_x,data_y=loadtxt('kinetik.txt',delimiter=',',usecols=(0, 1),unpack=True)

# Polynomfit erzeugen
z   = N.polyfit(data_x, data_y, 7)
p40 = N.poly1d(z)

# Diagramm erzeugen
lindat = column_stack([data_x,data_y])

def fitfunc(x, a,b,c,d,e,f,g,h):
    """The fit function: e-func."""
    return a*x**8+b*x**7+c*x**6+d*x**5+e*x**4+f*x**3+g*x**2+h*x

res = minuit_wrapper(fitfunc, lindat)
print('Result: ', res.values)
print('Uncertainties: ', res.errors)
print('polyfit:',z)
#p.plot(data_x,data_y,data_x,p40(data_x))
p.plot(data_x,data_y,data_x,fitfunc(data_x, **res.values))

xvals, yvals, xvals_band, yvals_band, chi2pdof = errorband(res, fitfunc, len(lindat), 1.7, 3.16, 0.025)
p.fill(xvals_band, yvals_band, '#aaaaaa')
p.plot(lindat.transpose()[0], lindat.transpose()[1], 'r+')
p.plot(xvals, yvals)
p.show()
print('chi^2/dof = ', chi2pdof)


# Schätzwert Temperatur
Пример #3
0
plot_kin_datx('stahl60.asc',1)
#plot_kin_datx('stahl90.asc',1)
#plot_kin_dat('stahl2.asc',1)

#plot_kin_datx('holz80_2.asc',1)
#plot_kin_datx('holz_c1.asc',1)

#p.subplot(132)
p.xlabel(u"Temperatur [°C]", fontsize = 12)
p.ylabel(u"Zeitdauer [hr á 5 °C] ", fontsize = 12)

N.sort(dataxy,1)
mat = N.array(dataxy)
p.plot(mat[:,0],mat[:,1],'o')

res = minuit_wrapper(fitfunc_lin, mat)
#p.plot(mat[:,0],(fitfunc_lin(mat[:,0],res.values['m'],res.values['b'])),'+')
xvals, yvals, xvals_band, yvals_band, chi2pdof = errorband(res, fitfunc_lin, len(mat), 40, 130, 5)
p.fill(xvals_band, yvals_band, '#aaaaaa')
#p.plot(mat.transpose()[0], mat.transpose()[1], 'r+')
p.plot(xvals, yvals)

print('Best fit parameters: ', res.values)
print('Best fit uncertainties: ', res.errors)

time_sum=res.values['b']
for e in range(80):
    time_sum = time_sum + res.values['m']*(e*5)+res.values['b']
    print (e*delta_t),time_sum/24,res.values['m']*(e*5)+res.values['b']
   
p.show() # für linares Model
Пример #4
0
import minuit
from fithelpers import minuit_wrapper, errorband


# ============================================================================
#  Executable program section
# ============================================================================

# Step 1: Reproduce the previous work (using fithelper this time).

lindat = np.array([0.9,0.2, 2.1,0.3, 3.0,0.5, 4.1,0.5]).reshape(4,2)
def fitfunc(x, a, b):
    """The fit function: A straight line."""
    return b + x*a

res = minuit_wrapper(fitfunc, lindat)
print('Result: ', res.values)
print('Uncertainties: ', res.errors)

xvals, yvals, xvals_band, yvals_band, chi2pdof = errorband(res, fitfunc, len(lindat), 0., 5., 0.1)
plt.fill(xvals_band, yvals_band, '#aaaaaa')
plt.plot(lindat.transpose()[0], lindat.transpose()[1], 'r+')
plt.plot(xvals, yvals)
plt.show()
print('chi^2/dof = ', chi2pdof)
raw_input('Press return ...')


# Step 2: Read in the form factor data and plot it.

fh = open('realdata_2.dat', 'r') ; content=fh.readlines() ; fh.close()