Writing ALPHAdobs records is usually done with the ALPHAdobs_write
method:
ALPHAio.ALPHAdobs_write
— Function function ALPHAdobs_write(fb, obs...; extra=nothing)
Write the observables obs
in the file fb
, together with a parameter record. If obs
are uwreal
, the record parameter is a scalar one. If obs
is Aray{uwreal}
the parameter record is an array record. If obs
are a Dict{String, uwreal}
or Dict{String, Array{uwreal}}
the parameter record is of type Dict. Note that all observables have to be of the same type and size.
Additional information in the parameter record can be added by passing an arbitrary Dict{String, Any}
that have to be parsable by TOML. All dictionary entries that do not have a specific TOML header are written under [extra]
. See the TOML.jl documentation for more information.
using ADerrors # hide
a = uwreal(1.0 .+ randn(1000), "Random ensemble")
b = uwreal([1.3, 0.6], "Simple var with error")
c = uwreal([3.2, 0.4], "Another var with error")
e = uwreal(2.0 .+ randn(1000), "Another ensemble")
# Write as observables
ALPHAdobs_write(fb, a, b, c, e)
# Write as a vector of observables
ALPHAdobs_write(fb, [a, b, c, e])
# Write as an array of observables
d = Dict{String, Any}("Exact" => [1.0, 1.3, 3.2, 2.0])
ALPHAdobs_write(fb, [a b
c, e], d)
# Write as a dictionary
d = Dict{String, Any}("Exact" => [1.0, 1.3, 3.2, 2.0],
"Source" => "Package documentation")
data = Dict{String, uwreal}("random noise" => a,
"Variable with error 1" => b,
"Variable with error 2" => c,
"more noise" => e)
ALPHAdobs_write(fb, data, d)
# Write as a dictionary with target vectors
d = Dict{String, Any}("Exact" => [1.0, 1.3, 3.2, 2.0],
"Source" => "Package documentation")
data = Dict{String, uwreal}("random noise" => [a,e],
"Variables with error" => [b,c])
ALPHAdobs_write(fb, data, d)
These other methods provide finer control.
ALPHAio.ALPHAdobs_scalar_parameters
— Function function ALPHAdobs_scalar_parameters(fb, nobs; extra=nothing)
Creates a new ALPHA dobs parameter record for nobs
scalar quantities.
ALPHAio.ALPHAdobs_vector_parameters
— Function function ALPHAdobs_vector_parameters(fb, nobs, nlen; extra=nothing)
Creates a new ALPHA dobs parameter record for nobs
vector quantities of length nlen
.
ALPHAio.ALPHAdobs_array_parameters
— Function function ALPHAdobs_array_parameters(fb, nobs, size; extra=nothing)
Creates a new ALPHA dobs parameter record for nobs
array quantities of size size.
ALPHAio.ALPHAdobs_add
— Functionfunctiona ALPHAdobs_add(fb, vob::Union{uwreal,Array{uwreal}})
Given a vector/scalar vob
of ADerrors uwreal
, this routine write the observable in the fb
handler.
ALPHAio.ALPHAdobs_close
— Functionfunction ALPHAdobs_close(fb, cmmt="# Computed with ADerrors.jl")
Close the handler fb
with (optional) comment cmmt
.