Commit 06f0325c authored by Antonino D'Anna's avatar Antonino D'Anna

Added new versions of plat_av. now the function accept a optional vector or a...

Added new versions of plat_av. now the function accept a optional vector or a matrix of weight. wpm is still an optional paramter for backward compatibily.
parent 1bad48f9
......@@ -650,6 +650,19 @@ function md_val(a::uwreal, obs::Corr, derm::Vector{Corr}; new_version::Bool=fals
end
end
"""
plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, [W::VecOrMat{Float64},] wpm::Union{Dict{Int64},Vector{Float{64}},Dict{String,Vector{Float{64}},Nothing}=nothing} )
It computes plateau average of `obs` in the range `plat`. Effectively this perform a fit to a constant.
The field `W` is optional. When absent, `W` is a `Vector{Float64}` constructed from the error of `obs`.
When `W` is a `Vector{Float64}` it performs an uncorrelated fit, when `W` is a `Matrix{Float64}`, it perfom a correlated fit
# Potential side effects
When `W` is absent, the function acts with `ADerror.uwerr` on `obs` in order to compute the errors.
This is the reason why a `wpm` may be given as input.
"""
function plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing)
isnothing(wpm) ? uwerr.(obs) : [uwerr(obs_aux, wpm) for obs_aux in obs]
w = 1 ./ err.(obs)[plat[1]:plat[2]].^2
......@@ -657,6 +670,8 @@ function plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, wpm::Union{Dict{Int64
return av
end
plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, W::Vector{Float64},wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing) = sum(W .* obs[plat[1]:plat[2]]) / sum(W)
plat_av(obs::Vector{uwreal}, plat::Vector{Int64}, W::Matrix{Float64},wpm::Union{Dict{Int64,Vector{Float64}},Dict{String,Vector{Float64}}, Nothing}=nothing) = sum(W[i,j]*obs[j] for i in axes(W,1) for j in axes(W,2))/sum(W)
function model_av(fun::Function, y::Vector{uwreal}, guess::Float64;
tm::Vector{Int64}, tM::Vector{Int64}, k::Int64,
......
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