ADjson.jl provides ADerrors.jl with input and output routines for the json.gz
file format used within pyerrors.
The specifications of the json.gz
format can be found in the documentation of pyerrors.
The package depends on ADerrors.jl which depends on bdio.jl. All three packages are not registered in the official Julia registry. They can be installed by running the following commands:
julia -e 'using Pkg; Pkg.add(url="https://gitlab.ift.uam-csic.es/alberto/bdio.jl")'
julia -e 'using Pkg; Pkg.add(url="https://gitlab.ift.uam-csic.es/alberto/ADerrors.jl")'
julia -e 'using Pkg; Pkg.add(url="https://github.com/fjosw/ADjson.jl")'
At the moment ADjson.jl supports only a subset of the full json.gz
-pyerrors specification.
Obs |
List |
Array |
Corr |
|
---|---|---|---|---|
read | ✔️ | ✔️ | ✔️ | ✔️ |
write | ✔️ | ✔️ | ✖️ | ✖️ |
- ADerrors.jl always assumes that replica are labeled as
r0
,r1
, etc. Custom replica names injson.gz
files get lost in the conversion. - Per replicum means, labelled
$\bar{a}_{\alpha}^{r}$ in hep-lat/0306017, get lost in the conversion as they are not stored within ADerrors.jl data types. - ADerrors.jl does not support array valued constants with cross correlations. If such a constant is found in a
json.gz
file ADjson.jl throws an error. - Reading files with multiple replica and gaps in the Monte Carlo history is not yet supported as not all cases supported by pyerrors can be correctly initialized in ADerrors.jl. For now ADjson.jl throws an error in case such an observable is encountered.
- Writing files with gaps in the Monte Carlo history is not supported as ADerrors.jl rescales gapped data and this rescaling can be ambiguous.
A single observable can be written to a file as described in the following example
using ADerrors
using ADjson
# Create a test observable
test_obs = uwreal(rand(100), "Test ensemble")
# Write the observable to a file with a description
dump_to_json(test_obs, "test_file", "This file contains a test observable.")
# Read the observable from disk
check = load_json("test_file")
# Check that the observable was corretly reconstructed
iamzero = test - check
uwerr(iamzero)
println(iamzero)
>>> 0.0 +/- 0.0
ADjson.jl can also directly write a vector of uwreal
objects to disc
test_obs = uwreal(rand(100), "Test ensemble") + uwreal(rand(20), "Second shorter test ensemble")
test_obs *= uwreal([1.02, 0.01], "Renormalization")
dump_to_json([test_obs, test_obs, test_obs],
"vector_file",
"File contains three times a test observable which is defined on two ensembles and a constant.")