Commit 560937f1 authored by Alejandro Saez's avatar Alejandro Saez

md_val for TSM

parent 7a934361
......@@ -432,7 +432,7 @@ m_md1, m_md2 = md_val(m, corr_pp[1], derm[1])
m_shifted = m + dm1 * m_md1 + dm2 * m_md2
```
"""
function md_val(a::uwreal, obs::Corr, derm::Vector{Corr}; new_version::Bool=false)
function md_val(a::uwreal, obs::Corr, derm::Vector{Corr}; new_version::Bool=false, TSM::Bool=false)
nid = neid(a)
if nid != 1
error("Error: neid > 1")
......@@ -471,27 +471,31 @@ function md_val(a::uwreal, obs::Corr, derm::Vector{Corr}; new_version::Bool=fals
=#
der = length(a.der) >= maximum(n_ow) ? a.der[n_ow] * w_mean : 0.0
elseif all(count.(prop) .== 3)
corr_der = getfield.(corr, :der)
n = findall.(t-> t==1, prop)
n = vcat(n'...)
if all(n[:, 1] .== n[1, 1]) # find ow and w
n_w = n[1, 1]
n_ow1 = n[:, 2]
n_ow2 = n[:, 3]
elseif all(n[:, 2] .== n[1, 2])
n_w = n[1, 2]
n_ow1 = n[:, 1]
n_ow2 = n[:, 3]
elseif all(n[:, 3] .== n[1, 3])
n_w = n[1, 3]
n_ow1 = n[:, 1]
n_ow2 = n[:, 2]
end
w_mean = 1 / getindex.(corr_der, n_ow1)[1]
if 1 / getindex.(corr_der, n_ow1)[1] != 1 / getindex.(corr_der, n_ow2)[1]
error("w_mean with n_ow1 and with n_ow2 different")
if TSM == false
return nothing
else
corr_der = getfield.(corr, :der)
n = findall.(t-> t==1, prop)
n = vcat(n'...)
if all(n[:, 1] .== n[1, 1]) # find ow and w
n_w = n[1, 1]
n_ow1 = n[:, 2]
n_ow2 = n[:, 3]
elseif all(n[:, 2] .== n[1, 2])
n_w = n[1, 2]
n_ow1 = n[:, 1]
n_ow2 = n[:, 3]
elseif all(n[:, 3] .== n[1, 3])
n_w = n[1, 3]
n_ow1 = n[:, 1]
n_ow2 = n[:, 2]
end
w_mean = 1 / getindex.(corr_der, n_ow1)[1]
if 1 / getindex.(corr_der, n_ow1)[1] != 1 / getindex.(corr_der, n_ow2)[1]
error("w_mean with n_ow1 and with n_ow2 different")
end
der = length(a.der) >= maximum(n_ow1) && length(a.der) >= maximum(n_ow2) ? a.der[n_ow1] * w_mean : 0.0
end
der = length(a.der) >= maximum(n_ow1) && length(a.der) >= maximum(n_ow2) ? a.der[n_ow1] * w_mean : 0.0
else
return nothing
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