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