Commit b75eaed5 authored by Alessandro 's avatar Alessandro

adding summation window choice in fit_routine (juobs_tool)

parent e20407eb
...@@ -150,13 +150,13 @@ The method return an array upar with the best fit parameters with their errors. ...@@ -150,13 +150,13 @@ The method return an array upar with the best fit parameters with their errors.
@. model(x,p) = p[1] + p[2] * exp(-(p[3]-p[1])*x) @. model(x,p) = p[1] + p[2] * exp(-(p[3]-p[1])*x)
fit_routine(model, ydata, param=3) fit_routine(model, ydata, param=3)
""" """
function fit_routine(model::Function, ydata::Array{uwreal}, param::Int64=3) function fit_routine(model::Function, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing )
yval = value.(ydata) yval = value.(ydata)
yer = err.(ydata) yer = err.(ydata)
xdata = collect(1:length(ydata)) xdata = collect(1:length(ydata))
chisq = gen_chisq(model, xdata, yer) chisq = gen_chisq(model, xdata, yer)
fit = curve_fit(model, xdata, yval, 1.0 ./ yer.^2, fill(0.5, param)) fit = curve_fit(model, xdata, yval, 1.0 ./ yer.^2, fill(0.5, param))
upar, chi_exp = fit_error(chisq, coef(fit), ydata) isnothing(wpm) ? (upar, chi_exp) = fit_error(chisq, coef(fit), ydata) : (upar, chi_exp) = fit_error(chisq, coef(fit), ydata, wpm)
for i = 1:length(upar) for i = 1:length(upar)
uwerr(upar[i]) uwerr(upar[i])
print("\n Fit parameter: ", i, ": ") print("\n Fit parameter: ", i, ": ")
......
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