Commit e979d31d authored by Alberto Ramos's avatar Alberto Ramos

Adding replica names to i/o

parent 209eb3cf
...@@ -17,6 +17,12 @@ git-tree-sha1 = "dedbbb2ddb876f899585c4ec4433265e3017215a" ...@@ -17,6 +17,12 @@ git-tree-sha1 = "dedbbb2ddb876f899585c4ec4433265e3017215a"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197" uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
version = "2.1.0" version = "2.1.0"
[[Artifacts]]
deps = ["Pkg"]
git-tree-sha1 = "c30985d8821e0cd73870b17b0ed0ce6dc44cb744"
uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
version = "1.3.0"
[[BDIO]] [[BDIO]]
deps = ["Documenter", "Nettle"] deps = ["Documenter", "Nettle"]
git-tree-sha1 = "31aa5298af4936ad33dd39f43ef0c3f7c45fb197" git-tree-sha1 = "31aa5298af4936ad33dd39f43ef0c3f7c45fb197"
...@@ -41,10 +47,10 @@ uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232" ...@@ -41,10 +47,10 @@ uuid = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
version = "0.5.10" version = "0.5.10"
[[Bzip2_jll]] [[Bzip2_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "03a44490020826950c68005cafb336e5ba08b7e8" git-tree-sha1 = "c3598e525718abcc440f69cc6d5f60dda0a1b61e"
uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0" uuid = "6e34b625-4abd-537c-b88f-471c36dfa7a0"
version = "1.0.6+4" version = "1.0.6+5"
[[ColorSchemes]] [[ColorSchemes]]
deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"] deps = ["ColorTypes", "Colors", "FixedPointNumbers", "Random", "StaticArrays"]
...@@ -153,10 +159,10 @@ uuid = "c87230d0-a227-11e9-1b43-d7ebe4e7570a" ...@@ -153,10 +159,10 @@ uuid = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
version = "0.3.0" version = "0.3.0"
[[FFMPEG_jll]] [[FFMPEG_jll]]
deps = ["Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "LAME_jll", "LibVPX_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "Pkg", "Zlib_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"] deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "LAME_jll", "LibVPX_jll", "Libdl", "Ogg_jll", "OpenSSL_jll", "Opus_jll", "Pkg", "Zlib_jll", "libass_jll", "libfdk_aac_jll", "libvorbis_jll", "x264_jll", "x265_jll"]
git-tree-sha1 = "13a934b9e74a8722bf1786c989de346a9602e695" git-tree-sha1 = "3cc57ad0a213808473eafef4845a74766242e05f"
uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5" uuid = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
version = "4.3.1+2" version = "4.3.1+4"
[[FFTW]] [[FFTW]]
deps = ["AbstractFFTs", "FFTW_jll", "IntelOpenMP_jll", "Libdl", "LinearAlgebra", "MKL_jll", "Reexport"] deps = ["AbstractFFTs", "FFTW_jll", "IntelOpenMP_jll", "Libdl", "LinearAlgebra", "MKL_jll", "Reexport"]
...@@ -165,10 +171,10 @@ uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341" ...@@ -165,10 +171,10 @@ uuid = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
version = "1.2.2" version = "1.2.2"
[[FFTW_jll]] [[FFTW_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "6c975cd606128d45d1df432fb812d6eb10fee00b" git-tree-sha1 = "5a0d4b6a22a34d17d53543bd124f4b08ed78e8b0"
uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a" uuid = "f5851436-0d7a-5f13-b9de-f02708fd171a"
version = "3.3.9+5" version = "3.3.9+7"
[[FastGaussQuadrature]] [[FastGaussQuadrature]]
deps = ["LinearAlgebra", "SpecialFunctions"] deps = ["LinearAlgebra", "SpecialFunctions"]
...@@ -189,16 +195,16 @@ uuid = "f6369f11-7733-5829-9624-2563aa707210" ...@@ -189,16 +195,16 @@ uuid = "f6369f11-7733-5829-9624-2563aa707210"
version = "0.10.10" version = "0.10.10"
[[FreeType2_jll]] [[FreeType2_jll]]
deps = ["Bzip2_jll", "Libdl", "Pkg", "Zlib_jll"] deps = ["Artifacts", "Bzip2_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "720eee04e3b496c15e5e2269669c2532fb5005c0" git-tree-sha1 = "cbd58c9deb1d304f5a245a0b7eb841a2560cfec6"
uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7" uuid = "d7e528f0-a631-5988-bf34-fe36492bcfd7"
version = "2.10.1+4" version = "2.10.1+5"
[[FriBidi_jll]] [[FriBidi_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "cfc3485a0a968263c789e314fca5d66daf75ed6c" git-tree-sha1 = "0d20aed5b14dd4c9a2453c1b601d08e1149679cc"
uuid = "559328eb-81f9-559d-9380-de523a88c83c" uuid = "559328eb-81f9-559d-9380-de523a88c83c"
version = "1.0.5+5" version = "1.0.5+6"
[[GR]] [[GR]]
deps = ["Base64", "DelimitedFiles", "HTTP", "JSON", "LinearAlgebra", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"] deps = ["Base64", "DelimitedFiles", "HTTP", "JSON", "LinearAlgebra", "Printf", "Random", "Serialization", "Sockets", "Test", "UUIDs"]
...@@ -250,6 +256,11 @@ git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" ...@@ -250,6 +256,11 @@ git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856"
uuid = "82899510-4779-5014-852e-03e436cf321d" uuid = "82899510-4779-5014-852e-03e436cf321d"
version = "1.0.0" version = "1.0.0"
[[JLLWrappers]]
git-tree-sha1 = "a431f5f2ca3f4feef3bd7a5e94b8b8d4f2f647a0"
uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
version = "1.2.0"
[[JSON]] [[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"] deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4" git-tree-sha1 = "81690084b6198a2e1da36fcfda16eeca9f9f24e4"
...@@ -257,10 +268,10 @@ uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" ...@@ -257,10 +268,10 @@ uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.1" version = "0.21.1"
[[LAME_jll]] [[LAME_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "a7999edc634307964d5651265ebf7c2e14b4ef91" git-tree-sha1 = "df381151e871f41ee86cee4f5f6fd598b8a68826"
uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d" uuid = "c1c5ebd0-6772-5130-a774-d5fcae4a789d"
version = "3.100.0+2" version = "3.100.0+3"
[[LaTeXStrings]] [[LaTeXStrings]]
git-tree-sha1 = "de44b395389b84fd681394d4e8d39ef14e3a2ea8" git-tree-sha1 = "de44b395389b84fd681394d4e8d39ef14e3a2ea8"
...@@ -272,10 +283,10 @@ deps = ["Printf"] ...@@ -272,10 +283,10 @@ deps = ["Printf"]
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
[[LibVPX_jll]] [[LibVPX_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e02378f5707d0f94af22b99e4aba798e20368f6e" git-tree-sha1 = "85fcc80c3052be96619affa2fe2e6d2da3908e11"
uuid = "dd192d2f-8180-539f-9fb4-cc70b1dcf69a" uuid = "dd192d2f-8180-539f-9fb4-cc70b1dcf69a"
version = "1.9.0+0" version = "1.9.0+1"
[[Libdl]] [[Libdl]]
uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
...@@ -310,10 +321,10 @@ uuid = "739be429-bea8-5141-9913-cc70e7f3736d" ...@@ -310,10 +321,10 @@ uuid = "739be429-bea8-5141-9913-cc70e7f3736d"
version = "1.0.2" version = "1.0.2"
[[MbedTLS_jll]] [[MbedTLS_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "c0b1286883cac4e2b617539de41111e0776d02e8" git-tree-sha1 = "0eef589dd1c26a3ac9d753fe1a8bcad63f956fa6"
uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1"
version = "2.16.8+0" version = "2.16.8+1"
[[Measures]] [[Measures]]
git-tree-sha1 = "e498ddeee6f9fdb4551ce855a46f54dbd900245f" git-tree-sha1 = "e498ddeee6f9fdb4551ce855a46f54dbd900245f"
...@@ -341,28 +352,28 @@ uuid = "49dea1ee-f6fa-5aa6-9a11-8816cee7d4b9" ...@@ -341,28 +352,28 @@ uuid = "49dea1ee-f6fa-5aa6-9a11-8816cee7d4b9"
version = "0.4.0" version = "0.4.0"
[[Ogg_jll]] [[Ogg_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4c3275cda1ba99d1244d0b82a9d0ca871c3cf66b" git-tree-sha1 = "a42c0f138b9ebe8b58eba2271c5053773bde52d0"
uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051" uuid = "e7412a2a-1a6e-54c0-be00-318e2571c051"
version = "1.3.4+1" version = "1.3.4+2"
[[OpenSSL_jll]] [[OpenSSL_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "997359379418d233767f926ea0c43f0e731735c0" git-tree-sha1 = "71bbbc616a1d710879f5a1021bcba65ffba6ce58"
uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95"
version = "1.1.1+5" version = "1.1.1+6"
[[OpenSpecFun_jll]] [[OpenSpecFun_jll]]
deps = ["CompilerSupportLibraries_jll", "Libdl", "Pkg"] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "d51c416559217d974a1113522d5919235ae67a87" git-tree-sha1 = "9db77584158d0ab52307f8c04f8e7c08ca76b5b3"
uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e" uuid = "efe28fd5-8261-553b-a9e1-b2916fc3738e"
version = "0.5.3+3" version = "0.5.3+4"
[[Opus_jll]] [[Opus_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "cc90a125aa70dbb069adbda2b913b02cf2c5f6fe" git-tree-sha1 = "f9d57f4126c39565e05a2b0264df99f497fc6f37"
uuid = "91d4177d-7536-5919-b921-800302f37372" uuid = "91d4177d-7536-5919-b921-800302f37372"
version = "1.3.1+2" version = "1.3.1+3"
[[OrderedCollections]] [[OrderedCollections]]
git-tree-sha1 = "16c08bf5dba06609fe45e30860092d6fa41fde7b" git-tree-sha1 = "16c08bf5dba06609fe45e30860092d6fa41fde7b"
...@@ -554,37 +565,37 @@ uuid = "b8865327-cd53-5732-bb35-84acbb429228" ...@@ -554,37 +565,37 @@ uuid = "b8865327-cd53-5732-bb35-84acbb429228"
version = "1.1.0" version = "1.1.0"
[[Zlib_jll]] [[Zlib_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "fdd89e5ab270ea0f2a0174bd9093e557d06d4bfa" git-tree-sha1 = "320228915c8debb12cb434c59057290f0834dbf6"
uuid = "83775a58-1f1d-513f-b197-d71354ab007a" uuid = "83775a58-1f1d-513f-b197-d71354ab007a"
version = "1.2.11+16" version = "1.2.11+18"
[[libass_jll]] [[libass_jll]]
deps = ["Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "Libdl", "Pkg", "Zlib_jll"] deps = ["Artifacts", "Bzip2_jll", "FreeType2_jll", "FriBidi_jll", "JLLWrappers", "Libdl", "Pkg", "Zlib_jll"]
git-tree-sha1 = "f02d0db58888592e98c5f4953cef620ce9274eee" git-tree-sha1 = "acc685bcf777b2202a904cdcb49ad34c2fa1880c"
uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0" uuid = "0ac62f75-1d6f-5e53-bd7c-93b484bb37c0"
version = "0.14.0+3" version = "0.14.0+4"
[[libfdk_aac_jll]] [[libfdk_aac_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e17b4513993b4413d31cffd1b36a63625ebbc3d3" git-tree-sha1 = "7a5780a0d9c6864184b3a2eeeb833a0c871f00ab"
uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280" uuid = "f638f0a6-7fb0-5443-88ba-1cc74229b280"
version = "0.1.6+3" version = "0.1.6+4"
[[libvorbis_jll]] [[libvorbis_jll]]
deps = ["Libdl", "Ogg_jll", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Ogg_jll", "Pkg"]
git-tree-sha1 = "8014e1c1033009edcfe820ec25877a9f1862ba4c" git-tree-sha1 = "fa14ac25af7a4b8a7f61b287a124df7aab601bcd"
uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a" uuid = "f27f6e37-5d2b-51aa-960f-b287f2bc3b7a"
version = "1.3.6+5" version = "1.3.6+6"
[[x264_jll]] [[x264_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "e496625b900df1b02ab0e02fad316b77446616ef" git-tree-sha1 = "d713c1ce4deac133e3334ee12f4adff07f81778f"
uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a" uuid = "1270edf5-f2f9-52d2-97e9-ab00b5d0237a"
version = "2020.7.14+1" version = "2020.7.14+2"
[[x265_jll]] [[x265_jll]]
deps = ["Libdl", "Pkg"] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "ac7d44fa1639a780d0ae79ca1a5a7f4181131825" git-tree-sha1 = "487da2f8f2f0c8ee0e83f39d13037d6bbf0a45ab"
uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76" uuid = "dfaa095f-4041-5dcd-9319-2fabd8486b76"
version = "3.0.0+2" version = "3.0.0+3"
...@@ -11,6 +11,7 @@ cobs ...@@ -11,6 +11,7 @@ cobs
```@docs ```@docs
change_id change_id
ensembles
``` ```
## I/O ## I/O
...@@ -40,6 +41,7 @@ taui ...@@ -40,6 +41,7 @@ taui
dtaui dtaui
rho rho
drho drho
mchist
window window
details details
neid neid
......
...@@ -208,6 +208,9 @@ All observables are stored in a single `BDIO` record of type `BDIO_BIN_GENERIC`. ...@@ -208,6 +208,9 @@ 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})`
that maps each numeric `ID` to a vector of replica names. All
strings are NULL terminated.
!!! 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.
......
...@@ -32,7 +32,7 @@ include("ADerrorsTools.jl") ...@@ -32,7 +32,7 @@ include("ADerrorsTools.jl")
# Root, fit, integral error propagation # Root, fit, integral error propagation
include("ADerrorsUtils.jl") include("ADerrorsUtils.jl")
export err, value, derror, taui, dtaui, window, rho, drho, details 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
export read_uwreal, write_uwreal export read_uwreal, write_uwreal
......
...@@ -89,7 +89,23 @@ function get_name_from_id(id::Int64, ws::wspace) ...@@ -89,7 +89,23 @@ 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})
if haskey(ws.repnam, id)
for i in 1:length(rname)
if rname[i] != ws.repnam[id][i]
error("Mistmatch in replica names for ensemble: "*get_name_from_id(id,ws))
end
end
else
ws.repnam[id] = rname
end
end
get_repnames_from_id(id::Int64, ws::wspace) = ws.repnam[id]
function add_maps(id::Int64, ws::wspace, iv::Vector{Int64}) function add_maps(id::Int64, ws::wspace, iv::Vector{Int64})
ws.nob += 1 ws.nob += 1
...@@ -683,6 +699,7 @@ wsg = ADerrors.wspace(similar(Vector{ADerrors.fbd}, 0), ...@@ -683,6 +699,7 @@ 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}}(),
-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)
...@@ -691,6 +708,7 @@ dtaui(a::uwreal, str::String) = dtaui(a, get_id_from_name(str)) ...@@ -691,6 +708,7 @@ dtaui(a::uwreal, str::String) = dtaui(a, get_id_from_name(str))
window(a::uwreal, str::String) = window(a, get_id_from_name(str)) window(a::uwreal, str::String) = window(a, get_id_from_name(str))
rho(a::uwreal, str::String) = rho(a, get_id_from_name(str)) rho(a::uwreal, str::String) = rho(a, get_id_from_name(str))
drho(a::uwreal, str::String) = drho(a, get_id_from_name(str)) drho(a::uwreal, str::String) = drho(a, get_id_from_name(str))
mchist(a::uwreal, str::String) = mchist(a, get_id_from_name(str))
empt = Dict{Int64,Vector{Float64}}() empt = Dict{Int64,Vector{Float64}}()
...@@ -851,30 +869,116 @@ uwreal(data::Vector{Float64}, ...@@ -851,30 +869,116 @@ uwreal(data::Vector{Float64},
idm, idm,
nms) nms)
uwreal(data::Vector{Float64}, str::String) = ADerrors.uwcls(data, function uwreal(data::Vector{Float64}, str::String)
get_id_from_name(str, wsg), uw = ADerrors.uwcls(data,
wsg, get_id_from_name(str, wsg),
[length(data)]) wsg,
uwreal(data::Vector{Float64}, [length(data)])
str::String, v = [str*"_r0"]
iv::Vector{Int64}) = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv) add_repnames(get_id_from_name(str, wsg), wsg, v)
uwreal(data::Vector{Float64},
str::String, return uw
idm::Vector{Int64}, end
nms::Int64) = ADerrors.uwcls_gaps(data,
function uwreal(data::Vector{Float64},
str::String,
iv::Vector{Int64})
uw = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv)
v = Vector{String}(undef, length(iv))
for i in 1:length(v)
v[i] = str*"r"*string(i-1)
end
add_repnames(get_id_from_name(str, wsg), wsg, v)
return uw
end
function uwreal(data::Vector{Float64},
str::String,
idm::Vector{Int64},
nms::Int64)
uw = ADerrors.uwcls_gaps(data,
get_id_from_name(str, wsg), wsg, get_id_from_name(str, wsg), wsg,
[nms], [nms],
idm, idm,
nms) nms)
uwreal(data::Vector{Float64}, v = [str*"_r0"]
str::String, add_repnames(get_id_from_name(str, wsg), wsg, v)
iv::Vector{Int64},
idm::Vector{Int64}, return uw
nms::Int64) = ADerrors.uwcls_gaps(data, end
get_id_from_name(str, wsg),
iv, function uwreal(data::Vector{Float64},
idm, str::String,
nms) iv::Vector{Int64},
idm::Vector{Int64},
nms::Int64)
uw = ADerrors.uwcls_gaps(data,
get_id_from_name(str, wsg),
iv,
idm,
nms)
v = Vector{String}(undef, length(iv))
for i in 1:length(v)
v[i] = str*"r"*string(i-1)
end
add_repnames(get_id_from_name(str, wsg), wsg, v)
return uw
end
function uwreal(data::Vector{Float64}, str::String, rname::Vector{String})
uw = ADerrors.uwcls(data,
get_id_from_name(str, wsg),
wsg,
[length(data)])
add_repnames(get_id_from_name(str, wsg), wsg, rname)
return uw
end
function uwreal(data::Vector{Float64},
str::String, rname::Vector{String},
iv::Vector{Int64})
uw = ADerrors.uwcls(data, get_id_from_name(str, wsg), wsg, iv)
add_repnames(get_id_from_name(str, wsg), wsg, rname)
return uw
end
function uwreal(data::Vector{Float64},
str::String, rname::Vector{String},
idm::Vector{Int64},
nms::Int64)
uw = ADerrors.uwcls_gaps(data,
get_id_from_name(str, wsg), wsg,
[nms],
idm,
nms)
add_repnames(get_id_from_name(str, wsg), wsg, rname)
return uw
end
function uwreal(data::Vector{Float64},
str::String, rname::Vector{String},
iv::Vector{Int64},
idm::Vector{Int64},
nms::Int64)
uw = ADerrors.uwcls_gaps(data,
get_id_from_name(str, wsg),
iv,
idm,
nms)
add_repnames(get_id_from_name(str, wsg), wsg, rname)
return uw
end
@doc raw""" @doc raw"""
......
...@@ -237,6 +237,51 @@ function drho(a::uwreal, mcid::Int64) ...@@ -237,6 +237,51 @@ function drho(a::uwreal, mcid::Int64)
end end
end end
"""
mchist(a::uwreal, mcid)
Returns the fluctuations of the `uwreal` variable `a` on ensemble `mcid`. It is assumed that `uwerr` has been run on the variable and that `mcid` contributes to the observable `a`. Otherwise an error message is printed.
```@example
using ADerrors # hide
# Generate some correlated data
eta = randn(1000)
x = Vector{Float64}(undef, 1000)
x[1] = 0.0
for i in 2:1000
x[i] = x[i-1] + eta[i]
if abs(x[i]) > 1.0
x[i] = x[i-1]
end
end
a = uwreal(x.^2, "Some simple ensemble")
uwerr(a)
v = mchist(a, "Some simple ensemble")
for i in 1:length(v)
println(i, " ", v[i])
end
```
"""
function mchist(a::uwreal, mcid::Int64, ws::wspace)
idx = find_mcid(a, mcid)
if (idx == nothing)
error("No error available... maybe run uwerr")
else
nd = ws.fluc[ws.map_ids[a.ids[idx]]].nd
dt = zeros(Float64, nd)
for j in 1:length(a.prop)
if (a.prop[j] && (ws.map_nob[j] == a.ids[idx]))
dt .= dt .+ a.der[j] .* ws.fluc[j].delta
end
end
return dt
end
end
mchist(a::uwreal, mcid::Int64) = mchist(a, mcid, wsg)
function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64}) function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64})
dfoo = zeros(Float64, 1) dfoo = zeros(Float64, 1)
...@@ -308,6 +353,28 @@ function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64}) ...@@ -308,6 +353,28 @@ function read_bdio(fb, ws::wspace, mapids::Dict{Int64, Int64})
is = ie + 1 is = ie + 1
end end
end end
if BDIO.BDIO_eor(fb)
for i in 1:nid
v = Vector{String}(undef, nrep[i])
BDIO.BDIO_read(fb, ifoo)
str = get_name_from_id(ids[i], ws)
for j in 1:nrep[i]
v[j] = str*"_r"*string(j)
end
add_repnames(convert(Int64, ids[i]), ws, v)
end
else
for i in 1:nid
v = Vector{String}(undef, nrep[i])
BDIO.BDIO_read(fb, ifoo)
for j in 1:nrep[i]
v[j] = BDIO.BDIO_read_str(fb)
end
add_repnames(convert(Int64, ids[i]), ws, v)
end
end
return uwreal(dfoo[1], p, d) return uwreal(dfoo[1], p, d)
end end
...@@ -360,31 +427,73 @@ function write_bdio(p::uwreal, fb, iu::Int, ws::wspace; name="NO NAME") ...@@ -360,31 +427,73 @@ function write_bdio(p::uwreal, fb, iu::Int, ws::wspace; name="NO NAME")
BDIO.BDIO_write!(fb, [convert(Int32, p.ids[i])]) BDIO.BDIO_write!(fb, [convert(Int32, p.ids[i])])
BDIO.BDIO_write!(fb, get_name_from_id(p.ids[i], ws)*"\0") BDIO.BDIO_write!(fb, get_name_from_id(p.ids[i], ws)*"\0")
end end
for i in 1:nid
BDIO.BDIO_write!(fb, [convert(Int32, p.ids[i])])
v = get_repnames_from_id(p.ids[i], ws)
for j in 1:length(v)
BDIO.BDIO_write!(fb, v[j]*"\0")
end
end
BDIO.BDIO_write_hash!(fb) BDIO.BDIO_write_hash!(fb)
return true return true
end end
"""
ensembles(a::uwreal)
Returns the list of ensembles in lexicographic order contributing to the error of `a` as a `Vector{String}`.
```@example
using ADerrors # hide
using BDIO
a = uwreal(rand(2000), "Ensemble A")
b = uwreal(rand(2034), "Ensemble B")
c = sin(a+b)
for i in ensembles(c)
println("Ensemble "*str*" contributing")
end
```
"""
function ensembles(a::uwreal, ws::wspace)
nids = length(a.ids)
enlst = Vector{String}(undef, nids)
for i in 1:nids
enlst[i] = get_name_from_id(a.ids[i], ws)
end
ip = sort!(enlst, rev=true)
return enlst
end
ensembles(a::uwreal) = ensembles(a, wsg)
""" """
details(a::uwreal; io::IO=stdout, names::Dict{Int64, String} = Dict{Int64, String}()) details(a::uwreal; io::IO=stdout, names::Dict{Int64, String} = Dict{Int64, String}())
details(a::uwreal, ensemble::String, ws::wspace, io::IO=stdout)
Write out a detailed information on the error of `a`. Write out a detailed information on the error of `a`.
## Arguments ## Arguments
Optionally one can pass as a keyword argument (`io`) the `IO` stream to write to. If a the ergument `ensemble` is present, this routine writes information of the fluctuations of the observable in this ensemble. Optionally one can pass as a keyword argument (`io`) the `IO` stream to write to.
## Example ## Example
```@example ```@example
using ADerrors # hide using ADerrors # hide
a = uwreal(rand(2000), "Ensemble A12") a = uwreal(rand(2000), "Ensemble A12", ["A12 REP 0", "A12 REP 1", "A12 REP 2"], [1000, 500, 500])
b = uwreal([1.2, 0.023], "Ensemble XYZ") b = uwreal([1.2, 0.023], "Ensemble XYZ")
c = uwreal([5.2, 0.03], "Ensemble RRR") c = uwreal([5.2, 0.03], "Ensemble RRR")
d = a + b - c d = a + b - c
uwerr(d) uwerr(d)
details(d) details(d)
for en in ensembles(d)
details(d, en)
end
``` ```
""" """
function details(a::uwreal, ws::wspace, io::IO=stdout) function details(a::uwreal, ws::wspace, io::IO=stdout)
...@@ -435,6 +544,50 @@ end ...@@ -435,6 +544,50 @@ end
details(a::uwreal; io::IO=stdout) = details(a, wsg, io) details(a::uwreal; io::IO=stdout) = details(a, wsg, io)
function details(a::uwreal, str::String, ws::wspace, io::IO=stdout)
if (length(a.prop) == 0)
print(a.mean)
return
end
if (length(a.cfd) > 0)
println(io, a.mean, " +/- ", a.err)
nids = length(a.ids)
for i in 1:nids
idx = ws.map_ids[a.ids[i]]
if get_name_from_id(a.ids[i], ws) == str
nd = ws.fluc[ws.map_ids[a.ids[i]]].nd
dt = zeros(Float64, nd)
for j in 1:length(a.prop)
if (a.prop[j] && (ws.map_nob[j] == a.ids[i]))
dt .= dt .+ a.der[j] .* ws.fluc[j].delta
end
end
Printf.@printf(io, " ## Contribution of ensemble %s to error: %6.2f%s\n",
str, 100.0 .* a.cfd[i].var ./ a.err^2, "%")
println(io, " ## Ensemble details: ")
nc = 1
is = 1
for k in get_repnames_from_id(a.ids[i], ws)
ie = is + ws.fluc[idx].ivrep[nc] - 1
Printf.@printf(io, " # Replica: %s (length: %8d): %f +/- %f\n", k, ws.fluc[idx].ivrep[nc],
a.mean + sum(@view dt[is:ie])/ws.fluc[idx].ivrep[nc],
sqrt(a.cfd[i].var*sum(ws.fluc[idx].ivrep)/ws.fluc[idx].ivrep[nc]))
nc = nc + 1
is = ie + 1
end
end
end
end
return
end
details(a::uwreal, str::String; io::IO=stdout) = details(a, str, wsg, io)
""" """
read_uwreal(fb[, map_ids::Dict{Int64, Int64}]) read_uwreal(fb[, map_ids::Dict{Int64, Int64}])
......
...@@ -65,6 +65,7 @@ mutable struct fbd ...@@ -65,6 +65,7 @@ mutable struct fbd
delta::Array{Float64, 1} delta::Array{Float64, 1}
ivrep::Array{Int64, 1} ivrep::Array{Int64, 1}
fourier::Dict{Int64,Vector{Complex{Float64}}} fourier::Dict{Int64,Vector{Complex{Float64}}}
# repname::Vector{String}
end end
mutable struct wspace mutable struct wspace
...@@ -76,7 +77,8 @@ mutable struct wspace ...@@ -76,7 +77,8 @@ 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
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