Commit 7b83ed08 authored by Alessandro 's avatar Alessandro Committed by Javier

adding summation window choice in fit_routine (juobs_tool)

parent 45a38e54
......@@ -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)
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)
yer = err.(ydata)
xdata = collect(1:length(ydata))
chisq = gen_chisq(model, xdata, yer)
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)
uwerr(upar[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