Commit 7257bcfa authored by Alberto Ramos's avatar Alberto Ramos

Added trajectory ID to I/O format

parent 8ca2d6ad
...@@ -200,7 +200,7 @@ All observables are stored in a single `BDIO` record of type `BDIO_BIN_GENERIC`. ...@@ -200,7 +200,7 @@ All observables are stored in a single `BDIO` record of type `BDIO_BIN_GENERIC`.
- neid (`Int32`): The number of ensembles contributing to the observable. - neid (`Int32`): The number of ensembles contributing to the observable.
- ndata (`Vector{Int32}(neid)`): The length of each ensemble. - ndata (`Vector{Int32}(neid)`): The length of each ensemble.
- nrep (`Vector{Int32}(neid)`): The number of replica of each enemble. - nrep (`Vector{Int32}(neid)`): The number of replica of each enemble.
- vrep (`Vector{Int32}`): The replica vector for each ensemble. - vrep (`Vector{Int32}`): A vector with length the number of replica that contains the number of measurements in each replica.
- ids (`Vector{Int32}(neid)`): The ensemble numeric `ID`'s. - ids (`Vector{Int32}(neid)`): The ensemble numeric `ID`'s.
- nt (`Vector{Int32}(neid)`): Half the largest replica of each ensemble. - nt (`Vector{Int32}(neid)`): Half the largest replica of each ensemble.
- zero (`Vector{Float64}(neid)`): just `neid` zeros. - zero (`Vector{Float64}(neid)`): just `neid` zeros.
...@@ -208,9 +208,10 @@ All observables are stored in a single `BDIO` record of type `BDIO_BIN_GENERIC`. ...@@ -208,9 +208,10 @@ All observables are stored in a single `BDIO` record of type `BDIO_BIN_GENERIC`.
- delta (`Vector{Float64}`): The fluctuations for each ensemble. - delta (`Vector{Float64}`): The fluctuations for each ensemble.
- name (NULL terminated `String`): A description of the observable. - name (NULL terminated `String`): A description of the observable.
- `ID` tags: A list of `neid` tuples `(Int32, String)` that maps each numeric `ID` to an ensemble tag. All strings are NULL terminated. - `ID` tags: A list of `neid` tuples `(Int32, String)` that maps each numeric `ID` to an ensemble tag. All strings are NULL terminated.
- Replica names: A list of `neid` tuples `(Int32, Vector{String})` - Replica details: `neid` times the following information:
that maps each numeric `ID` to a vector of replica names. All - First an `Int32` wiht the numeric `ID` tag of the ensemble.
strings are NULL terminated. - Then a `Vector{String}` that contains the replica names.
- Finally a `Vector{Int32}` that contains the the configuration index where each measurement has been performed.
!!! alert !!! alert
Obviously this weird format is what it is for some legacy reasons, but it is strongly encouraged that new implementations respect this standard with all its weirdness. Obviously this weird format is what it is for some legacy reasons, but it is strongly encouraged that new implementations respect this standard with all its weirdness.
......
...@@ -34,7 +34,7 @@ include("ADerrorsUtils.jl") ...@@ -34,7 +34,7 @@ include("ADerrorsUtils.jl")
export err, value, derror, taui, dtaui, window, rho, drho, details, ensembles, mchist export err, value, derror, taui, dtaui, window, rho, drho, details, ensembles, mchist
export uwreal, uwerr, change_id export uwreal, uwerr, change_id
export cov, trcov, trcorr, neid export cov, trcov, trcorr, neid, derivative
export read_uwreal, write_uwreal export read_uwreal, write_uwreal
export addobs, cobs export addobs, cobs
export root_error, chiexp, fit_error, int_error export root_error, chiexp, fit_error, int_error
......
...@@ -90,21 +90,28 @@ function get_name_from_id(id::Int64, ws::wspace) ...@@ -90,21 +90,28 @@ function get_name_from_id(id::Int64, ws::wspace)
return str return str
end end
function add_repnames(id::Int64, ws::wspace, rname::Vector{String}) function add_repnames(id::Int64, ws::wspace, rname::Vector{String},
ridc::Vector{Int64})
if haskey(ws.repnam, id) if haskey(ws.repnam, id)
for i in 1:length(rname) for i in 1:length(rname)
if rname[i] != ws.repnam[id][i] if rname[i] != ws.repnam[id][i]
error("Mistmatch in replica names for ensemble: "*get_name_from_id(id,ws)) error("Mistmatch in replica names for ensemble: "*get_name_from_id(id,ws))
end end
if ridc[i] != ws.repidc[id][i]
error("Mistmatch in replica configuration index for ensemble: "
*get_name_from_id(id,ws)*" replicum: "*rname[i])
end
end end
else else
ws.repnam[id] = rname ws.repnam[id] = rname
ws.repidc[id] = ridc
end end
end end
get_repnames_from_id(id::Int64, ws::wspace) = ws.repnam[id] get_repnames_from_id(id::Int64, ws::wspace) = ws.repnam[id]
get_repidc_from_id(id::Int64, ws::wspace) = ws.repidc[id]
function add_maps(id::Int64, ws::wspace, iv::Vector{Int64}) function add_maps(id::Int64, ws::wspace, iv::Vector{Int64})
...@@ -699,7 +706,8 @@ wsg = ADerrors.wspace(similar(Vector{ADerrors.fbd}, 0), ...@@ -699,7 +706,8 @@ wsg = ADerrors.wspace(similar(Vector{ADerrors.fbd}, 0),
similar(Vector{Int64}, 0), similar(Vector{Int64}, 0),
Dict{Int64, Int64}(), Dict{Int64, Int64}(),
Dict{Int64, String}(), Dict{String, Int64}(), Dict{Int64, String}(), Dict{String, Int64}(),
Dict{Int64, Vector{String}}(), Dict{Int64, Vector{String}}(),
Dict{Int64, Vector{Int64}}(),
-12345) -12345)
get_id_from_name(str::String) = get_id_from_name(str, wsg) get_id_from_name(str::String) = get_id_from_name(str, wsg)
...@@ -839,35 +847,30 @@ uwreal(x::Float64) = ADerrors.uwreal(x, 0.0, 0.0, ...@@ -839,35 +847,30 @@ uwreal(x::Float64) = ADerrors.uwreal(x, 0.0, 0.0,
Vector{Int64}(), Vector{cfdata}()) Vector{Int64}(), Vector{cfdata}())
uwreal(data::Vector{Float64}, uwreal(data::Vector{Float64},
id::Int64) = ADerrors.uwcls(data, id::Int64) = uwreal(data,
id, string(id))
wsg,
[length(data)])
uwreal(data::Vector{Float64}, uwreal(data::Vector{Float64},
id::Int64, id::Int64,
iv::Vector{Int64}) = ADerrors.uwcls(data, iv::Vector{Int64}) = uwreal(data,
id, string(id),
wsg, iv)
iv)
uwreal(data::Vector{Float64}, uwreal(data::Vector{Float64},
id::Int64, id::Int64,
idm::Vector{Int64}, idm::Vector{Int64},
nms::Int64) = ADerrors.uwcls_gaps(data, nms::Int64) = uwreal(data,
id, string(id),
wsg, [nms],
[nms], idm,
idm, nms)
nms)
uwreal(data::Vector{Float64}, uwreal(data::Vector{Float64},
id::Int64, id::Int64,
iv::Vector{Int64}, iv::Vector{Int64},
idm::Vector{Int64}, idm::Vector{Int64},
nms::Int64) = ADerrors.uwcls_gaps(data, nms::Int64) = uwreal(data,
id, string(id),
wsg, iv,
iv, idm,
idm, nms)
nms)
function uwreal(data::Vector{Float64}, str::String) function uwreal(data::Vector{Float64}, str::String)
uw = ADerrors.uwcls(data, uw = ADerrors.uwcls(data,
...@@ -875,7 +878,8 @@ function uwreal(data::Vector{Float64}, str::String) ...@@ -875,7 +878,8 @@ function uwreal(data::Vector{Float64}, str::String)
wsg, wsg,
[length(data)]) [length(data)])
v = [str*"_r0"] v = [str*"_r0"]
add_repnames(get_id_from_name(str, wsg), wsg, v) idc = collect(1:length(data))
add_repnames(get_id_from_name(str, wsg), wsg, v, idc)
return uw return uw
end end
...@@ -886,10 +890,17 @@ function uwreal(data::Vector{Float64}, ...@@ -886,10 +890,17 @@ function uwreal(data::Vector{Float64},
uw = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv) uw = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv)
v = Vector{String}(undef, length(iv)) v = Vector{String}(undef, length(iv))
idc = Vector{Int64}(undef, length(data))
iof = 0
for i in 1:length(v) for i in 1:length(v)
v[i] = str*"r"*string(i-1) v[i] = str*"r"*string(i-1)
for k in 1:iv[i]
idc[k+iof] = k
end
iof = iof + iv[i]
end end
add_repnames(get_id_from_name(str, wsg), wsg, v)
add_repnames(get_id_from_name(str, wsg), wsg, v, idc)
return uw return uw
end end
...@@ -905,7 +916,8 @@ function uwreal(data::Vector{Float64}, ...@@ -905,7 +916,8 @@ function uwreal(data::Vector{Float64},
idm, idm,
nms) nms)
v = [str*"_r0"] v = [str*"_r0"]
add_repnames(get_id_from_name(str, wsg), wsg, v) idc = collect(1:nms)
add_repnames(get_id_from_name(str, wsg), wsg, v, idc)
return uw return uw
end end
...@@ -921,10 +933,16 @@ function uwreal(data::Vector{Float64}, ...@@ -921,10 +933,16 @@ function uwreal(data::Vector{Float64},
idm, idm,
nms) nms)
v = Vector{String}(undef, length(iv)) v = Vector{String}(undef, length(iv))
idc = Vector{Int64}(undef, length(data))
iof = 0
for i in 1:length(v) for i in 1:length(v)
v[i] = str*"r"*string(i-1) v[i] = str*"r"*string(i-1)
for k in 1:iv[i]
idc[k+iof] = k
end
iof = iof + iv[i]
end end
add_repnames(get_id_from_name(str, wsg), wsg, v) add_repnames(get_id_from_name(str, wsg), wsg, v, idc)
return uw return uw
end end
...@@ -935,7 +953,8 @@ function uwreal(data::Vector{Float64}, str::String, rname::Vector{String}) ...@@ -935,7 +953,8 @@ function uwreal(data::Vector{Float64}, str::String, rname::Vector{String})
get_id_from_name(str, wsg), get_id_from_name(str, wsg),
wsg, wsg,
[length(data)]) [length(data)])
add_repnames(get_id_from_name(str, wsg), wsg, rname) idc = collect(1:length(data))
add_repnames(get_id_from_name(str, wsg), wsg, rname, idc)
return uw return uw
end end
...@@ -945,7 +964,16 @@ function uwreal(data::Vector{Float64}, ...@@ -945,7 +964,16 @@ function uwreal(data::Vector{Float64},
iv::Vector{Int64}) iv::Vector{Int64})
uw = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv) uw = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv)
add_repnames(get_id_from_name(str, wsg), wsg, rname)
idc = Vector{Int64}(undef, length(data))
iof = 0
for i in 1:length(iv)
for k in 1:iv[i]
idc[k+iof] = k
end
iof = iof + iv[i]
end
add_repnames(get_id_from_name(str, wsg), wsg, rname, idc)
return uw return uw
end end
...@@ -960,7 +988,9 @@ function uwreal(data::Vector{Float64}, ...@@ -960,7 +988,9 @@ function uwreal(data::Vector{Float64},
[nms], [nms],
idm, idm,
nms) nms)
add_repnames(get_id_from_name(str, wsg), wsg, rname)
idc = collect(1:nms)
add_repnames(get_id_from_name(str, wsg), wsg, rname, idc)
return uw return uw
end end
...@@ -975,7 +1005,15 @@ function uwreal(data::Vector{Float64}, ...@@ -975,7 +1005,15 @@ function uwreal(data::Vector{Float64},
iv, iv,
idm, idm,
nms) nms)
add_repnames(get_id_from_name(str, wsg), wsg, rname)
iof = 0
for i in 1:length(iv)
for k in 1:iv[i]
idc[k+iof] = k
end
iof = iof + iv[i]
end
add_repnames(get_id_from_name(str, wsg), wsg, rname, iv)
return uw return uw
end end
......
...@@ -357,27 +357,35 @@ function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64}) ...@@ -357,27 +357,35 @@ function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64})
# Here not to use ids[i] # Here not to use ids[i]
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
v = Vector{String}(undef, nrep[i]) v = Vector{String}(undef, nrep[i])
idc = Vector{Int32}(undef, nds[i])
BDIO.BDIO_read(fb, ifoo) BDIO.BDIO_read(fb, ifoo)
str = get_name_from_id(ids[i], ws) str = get_name_from_id(ids[i], ws)
for j in 1:nrep[i] for j in 1:nrep[i]
v[j] = str*"_r"*string(j) v[j] = str*"_r"*string(j)
for k in is:ie
idc[k] = convert(Int32, k-is+1)
end
end end
add_repnames(convert(Int64, ids_obs[i]), ws, v) add_repnames(convert(Int64, ids_obs[i]), ws, v, idc)
is = ie + 1
end end
else else
for i in 1:nid for i in 1:nid
v = Vector{String}(undef, nrep[i]) v = Vector{String}(undef, nrep[i])
idc = Vector{Int32}(undef, nds[i])
BDIO.BDIO_read(fb, ifoo) BDIO.BDIO_read(fb, ifoo)
for j in 1:nrep[i] for j in 1:nrep[i]
v[j] = BDIO.BDIO_read_str(fb) v[j] = BDIO.BDIO_read_str(fb)
end end
add_repnames(convert(Int64, ids_obs[i]), ws, v) BDIO.BDIO_read(fb, idc)
add_repnames(convert(Int64, ids_obs[i]), ws, v, convert(Vector{Int64}, idc))
end end
end end
return uwreal(dfoo[1], p, d) return uwreal(dfoo[1], p, d)
end end
...@@ -436,6 +444,7 @@ function write_bdio(p::uwreal, fb, iu::Int, ws::wspace; name="NO NAME") ...@@ -436,6 +444,7 @@ function write_bdio(p::uwreal, fb, iu::Int, ws::wspace; name="NO NAME")
for j in 1:length(v) for j in 1:length(v)
BDIO.BDIO_write!(fb, v[j]*"\0") BDIO.BDIO_write!(fb, v[j]*"\0")
end end
BDIO.BDIO_write!(fb, convert(Vector{Int32}, get_repidc_from_id(p.ids[i], ws)))
end end
BDIO.BDIO_write_hash!(fb) BDIO.BDIO_write_hash!(fb)
......
...@@ -104,7 +104,6 @@ function cobs(avgs::Vector{Float64}, cov::Array{Float64, 2}, ids::Vector{Int64}) ...@@ -104,7 +104,6 @@ function cobs(avgs::Vector{Float64}, cov::Array{Float64, 2}, ids::Vector{Int64})
p[j] = p[j] + uwreal([0.0, A[j,i]], ids[i]) p[j] = p[j] + uwreal([0.0, A[j,i]], ids[i])
end end
end end
end end
return p return p
......
...@@ -78,6 +78,7 @@ mutable struct wspace ...@@ -78,6 +78,7 @@ mutable struct wspace
id2str::Dict{Int64, String} # Ensemble id for each String id2str::Dict{Int64, String} # Ensemble id for each String
str2id::Dict{String, Int64} # Ensemble String for each id str2id::Dict{String, Int64} # Ensemble String for each id
repnam::Dict{Int64, Vector{String}} # Vector of replica names for each id repnam::Dict{Int64, Vector{String}} # Vector of replica names for each id
repidc::Dict{Int64, Vector{Int64}} # Configuration number for each replicum
newid::Int64 newid::Int64
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