Commit e8bbe71c authored by Javier's avatar Javier

Array{<:Real} bug

parent 564b17af
...@@ -95,7 +95,7 @@ function plat_av(obs::Vector{uwreal}, plat::Vector{Int64}) ...@@ -95,7 +95,7 @@ function plat_av(obs::Vector{uwreal}, plat::Vector{Int64})
return av return av
end end
function lin_fit(x::Vector{Real}, v::Vector{Float64}, e::Vector{Float64}) function lin_fit(x::Vector{<:Real}, v::Vector{Float64}, e::Vector{Float64})
sig2 = e .* e sig2 = e .* e
S = sum(1 ./ sig2) S = sum(1 ./ sig2)
Sx = sum(x ./ sig2) Sx = sum(x ./ sig2)
...@@ -108,7 +108,7 @@ function lin_fit(x::Vector{Real}, v::Vector{Float64}, e::Vector{Float64}) ...@@ -108,7 +108,7 @@ function lin_fit(x::Vector{Real}, v::Vector{Float64}, e::Vector{Float64})
return par return par
end end
@doc raw""" @doc raw"""
lin_fit(x::Vector{Real}, y::Vector{uwreal}) lin_fit(x::Vector{<:Real}, y::Vector{uwreal})
Computes a linear fit of uwreal data points y. This method return uwreal fit parameters and chisqexpected. Computes a linear fit of uwreal data points y. This method return uwreal fit parameters and chisqexpected.
...@@ -117,7 +117,7 @@ fitp, csqexp = lin_fit(phi2, m2) ...@@ -117,7 +117,7 @@ fitp, csqexp = lin_fit(phi2, m2)
m2_phys = fitp[1] + fitp[2] * phi2_phys m2_phys = fitp[1] + fitp[2] * phi2_phys
``` ```
""" """
function lin_fit(x::Vector{Real}, y::Vector{uwreal}) function lin_fit(x::Vector{<:Real}, y::Vector{uwreal})
uwerr.(y) uwerr.(y)
par = lin_fit(x, value.(y), err.(y)) par = lin_fit(x, value.(y), err.(y))
...@@ -150,7 +150,7 @@ The method return an array upar with the best fit parameters with their errors. ...@@ -150,7 +150,7 @@ 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, xdata::Array{Real}, ydata::Array{uwreal}, param::Int64=3; wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing ) function fit_routine(model::Function, xdata::Array{<:Real}, 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)
chisq = gen_chisq(model, xdata, yer) chisq = gen_chisq(model, xdata, yer)
...@@ -164,7 +164,7 @@ function fit_routine(model::Function, xdata::Array{Real}, ydata::Array{uwreal}, ...@@ -164,7 +164,7 @@ function fit_routine(model::Function, xdata::Array{Real}, ydata::Array{uwreal},
println("Chisq / chiexp: ", chisq(coef(fit), ydata), " / ", chi_exp, " (dof: ", dof(fit),")") println("Chisq / chiexp: ", chisq(coef(fit), ydata), " / ", chi_exp, " (dof: ", dof(fit),")")
return upar return upar
end end
function gen_chisq(f::Function, x::Array{Real}, err::Vector{Float64}) function gen_chisq(f::Function, x::Array{<:Real}, err::Vector{Float64})
chisq(par, dat) = sum((dat .- f(x,par)).^2 ./err.^2) chisq(par, dat) = sum((dat .- f(x,par)).^2 ./err.^2)
return chisq return chisq
end end
......
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