Commit f2252849 authored by ale's avatar ale

rwf clean try, change flag_s

parent 2015cdb7
......@@ -138,4 +138,11 @@ const db_c = Dict(
"E250" => ["ts001"],
"E300" => ["ts001_chunk2"],#, "ts001_chunk1"]
"D450" => ["ts001_1", "ts001_2"]
)
const flag_s = Dict(
"J303r003" => [324,325,326],
"H105r001" => [100,105,106],
"H105r002" => [1],
"H105r005" => [254, 255, 256, 257, 259, 260, 261, 264, 265, 266, 269, 280, 282, 283, 284, 285, 286, 287, 288, 289, 291, 299, 301, 313, 314, 315, 316, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342]
)
\ No newline at end of file
#TODO: apply_rw with gaps
function apply_rw(data::Array{Float64}, W::Matrix{Float64}, id::Union{String, Nothing}=nothing; vcfg::Union{Nothing, Vector{Int32}}=nothing)
nc = isnothing(vcfg) ? collect(1:size(data, 1)) : vcfg
W1 = W[1, nc]
W2 = W[2, nc]
if id == "J303" || id == "J303r003"
W_J303 = [1 for i in 1:length(data)]
W_J303[324] = W_J303[325] = W_J303[326] = -1
data_r = data .* W1 .* W2 .* W_J303
return (data_r, W1 .* W2 .* W_J303)
elseif id == "H105r005"
flagged_cfg = [254, 255, 256, 257, 259, 260, 261, 264, 265, 266, 269, 280, 282, 283, 284, 285, 286, 287, 288, 289, 291, 299, 301, 313, 314, 315, 316, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342]
W_H105r005 = [1 for i in 1:length(data)]
for i in flagged_cfg
W_H105r005[i] = -1
end
data_r = data .* W1 .* W2 .* W_H105r005
return (data_r, W1 .* W2 .* W_H105r005)
function apply_rw(data::Array{Float64}, W::Matrix{Float64}, vcfg::Union{Nothing, Vector{Int32}}=nothing, id::Union{String, Nothing}=nothing, fs::Bool=false)
nc = size(W,2)
if isnothing(vcfg)
vcfg = collect(1:nc)
end
rw1 = W[1, 1:nc]
rw2 = W[2, 1:nc]
if fs == false
rw = rw1 .* rw2
data_r = data .* rw[vcfg]
return (data_r, rw)
else
data_r = data .* W1 .* W2
return (data_r, W1 .* W2)
rw_s = [1.0 for i in 1:nc]
rw_s[flag_s[id]] .= -1.0
rw = rw1 .* rw2 .* rw_s
data_r = data .* rw[vcfg]
return (data_r, rw)
end
end
function apply_rw(data::Vector{<:Array{Float64}}, W::Vector{Matrix{Float64}}, id::Union{String, Nothing}=nothing)
if length(W) != length(data)
error("Lenghts must match")
function apply_rw(data::Vector{<:Array{Float64}}, W::Vector{Matrix{Float64}}, vcfg::Union{Nothing, Vector{Int32}}=nothing, id::Union{String, Nothing}=nothing, fs::Bool=false)
nc = size.(W, 2)
if isnothing(vcfg)
vcfg = [collect(1:nc[k]) for k=1:length(nc)]
end
nc = size.(data, 1)
if id == "J303" || id == "J303r003"
W_J303 = [1 for i in 1:nc[1]]
W_J303[324] = W_J303[325] = W_J303[326] = -1
rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)]
rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)]
rw3 = [W_J303]
rw = [rw1[k] .* rw2[k] .* rw3[k] for k=1:length(W)]
data_r = [data[k] .* rw[k] for k=1:length(data)]
rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)]
rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)]
if fs == false
rw = [rw1[k] .* rw2[k] for k =1:length(W)]
data_r = [data[k] .* rw[k][vcfg[k]] for k=1:length(data)]
return (data_r, rw)
elseif id == "H105r005"
flagged_cfg = [254, 255, 256, 257, 259, 260, 261, 264, 265, 266, 269, 280, 282, 283, 284, 285, 286, 287, 288, 289, 291, 299, 301, 313, 314, 315, 316, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342]
W_H105r005 = [1 for i in 1:nc[1]]
for i in flagged_cfg
W_H105r005[i] = -1
else
rw_s = [[1.0 for i in 1:nc[k]] for k=1:length(W)]
if id == "H105"
rw_s[1][flag_s["H105r001"]] .= -1.0
rw_s[2][flag_s["H105r002"]] .= -1.0
elseif id == "H105r005"
rw_s[1][flag_s["H105r005"]] .= -1.0
elseif id == "J303" || "J303r003"
rw_s[1][flag_s["J303r003"]] .= -1.0
end
rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)]
rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)]
rw3 = [W_H105r005]
rw = [rw1[k] .* rw2[k] .* rw3[k] for k=1:length(W)]
data_r = [data[k] .* rw[k] for k=1:length(data)]
rw = [rw1[k] .* rw2[k] .* rw_s[k] for k =1:length(W)]
data_r = [data[k] .* rw[k][vcfg[k]] for k=1:length(data)]
return (data_r, rw)
elseif id == "H105r001" || id == "H105"
W_H105r001 = [1 for i in 1:nc[1]]
W_H105r001[100] = W_H105r001[105] = W_H105r001[106] = -1
W_H105r002 = [1 for i in 1:nc[2]]
W_H105r002[1] = -1
rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)]
rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)]
rw3 = [W_H105r001, W_H105r002]
rw = [rw1[k] .* rw2[k] .* rw3[k] for k=1:length(W)]
data_r = [data[k] .* rw[k] for k=1:length(data)]
return (data_r, rw)
else
rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)]
rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)]
end
end
rw = [rw1[k] .* rw2[k] for k=1:length(W)]
data_r = [data[k] .* rw[k] for k=1:length(data)]
return (data_r, rw)
function apply_rw(data::Array{Float64}, W::Matrix{Float64}, vcfg::Union{Nothing, Vector{Int32}}=nothing, id::String="A653", fs::Bool=false)
nc = size(W,2)
if isnothing(vcfg)
vcfg = collect(1:nc)
end
rw1 = W[1, 1:nc]
rw = rw1
data_r = data .* rw[vcfg]
return (data_r, rw)
end
# rw with gaps
function apply_rw(data::Vector{<:Array{Float64}}, W::Vector{Matrix{Float64}}, vcfg::Vector{Vector{Int32}})
function apply_rw(data::Vector{<:Array{Float64}}, W::Vector{Matrix{Float64}}, vcfg::Union{Nothing, Vector{Int32}}=nothing, id::String="A653", fs::Bool=false)
nc = size.(W, 2)
if isnothing(vcfg)
vcfg = [collect(1:nc[k]) for k=1:length(nc)]
end
rw1 = [W[k][1, 1:nc[k]] for k=1:length(W)]
rw2 = [W[k][2, 1:nc[k]] for k=1:length(W)]
rw = [rw1[k] .* rw2[k] for k =1:length(W)]
rw = [rw1[k] for k =1:length(W)]
data_r = [data[k] .* rw[k][vcfg[k]] for k=1:length(data)]
return (data_r, rw)
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