Commit 7939eaf6 authored by Alberto Ramos's avatar Alberto Ramos

Improved check on MC length consistency

parent 13cfc4a1
......@@ -90,12 +90,25 @@ function get_name_from_id(id::Int64, ws::wspace)
return str
end
function add_maps(id::Int64, ws::wspace)
function add_maps(id::Int64, ws::wspace, iv::Vector{Int64})
ws.nob += 1
push!(ws.map_nob, id)
if (!haskey(ws.map_ids, id))
ws.map_ids[id] = ws.nob
else
if (sum(iv) != ws.fluc[ws.map_ids[id]].nd)
println(stderr, "ID: ", ws.id2str[id])
println(stderr, "DB length: ", ws.fluc[ws.map_ids[id]].nd)
println(stderr, "obs length: ", sum(iv))
error("Mistmatch in data length for the same ensemble ID")
end
if (iv != ws.fluc[ws.map_ids[id]].ivrep)
println(stderr, "ID: ", ws.id2str[id])
println(stderr, "DB replica: ", ws.fluc[ws.map_ids[id]].ivrep)
println(stderr, "obs replica: ", iv)
error("Mistmatch in replica vector for the same ensemble ID")
end
end
return nothing
......@@ -115,21 +128,6 @@ function add_DB(delta::Vector{Float64}, id::Int64, iv::Vector{Int64}, ws::wspace
ArgumentError("Sum of replica length does not match number of measurements")
end
if (haskey(ws.map_ids, id))
if (length(delta) != ws.fluc[ws.map_ids[id]].nd)
println(stderr, "ID: ", id)
println(stderr, "DB length: ", ws.fluc[ws.map_ids[id]].nd)
println(stderr, "obs length: ", length(delta))
error("Mistmatch in data length for the same ensemble ID")
end
if (iv != ws.fluc[ws.map_ids[id]].ivrep)
println(stderr, "ID: ", id)
println(stderr, "DB replica: ", ws.fluc[ws.map_ids[id]].ivrep)
println(stderr, "obs replica: ", iv)
error("Mistmatch in replica vector for the same ensemble ID")
end
end
fseries = Dict{Int64,Vector{Complex{Float64}}}()
nbin = get_nbin_vec(iv)
is = 1
......@@ -150,7 +148,7 @@ function add_DB(delta::Vector{Float64}, id::Int64, iv::Vector{Int64}, ws::wspace
end
if do_maps
add_maps(id, ws)
add_maps(id, ws, iv)
end
return nothing
......
......@@ -284,20 +284,28 @@ function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64})
end
if BDIO.BDIO_eor(fb)
is = 1
for i in 1:nid
ie = is + nrep[i] - 1
id = convert(Int64, ids[i])
add_maps(id, ws)
add_maps(id, ws, convert(Vector{Int64}, ivrep[is:ie]))
get_name_from_id(id, ws)
is = ie + 1
end
else
name = BDIO.BDIO_read_str(fb)
is = 1
for i in 1:nid
ie = is + nrep[i] - 1
BDIO.BDIO_read(fb, ifoo)
str = BDIO.BDIO_read_str(fb)
id = get_id_from_name(str, ws)
add_maps(id, ws)
add_maps(id, ws, convert(Vector{Int64}, ivrep[is:ie]))
is = ie + 1
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