diff --git a/src/MagneticFieldCoefficients.jl b/src/MagneticFieldCoefficients.jl index aaa03fc..ae490b3 100644 --- a/src/MagneticFieldCoefficients.jl +++ b/src/MagneticFieldCoefficients.jl @@ -132,10 +132,9 @@ end # TODO: This should be merged with and moved to MPIFiles function calcTDesignCoefficients(filename::String) # load the measurement data - field, radius, N, t, center, correction = loadMagneticFieldMeasurementData(filename) + field, tDes, correction = loadMagneticFieldMeasurementData(filename) # calculate the coefficients - tDes = MPIFiles.loadTDesign(Int(t), N, radius * u"m", center .* u"m") coeffs = magneticField(tDes, field) # apply the correction of the sensors @@ -143,7 +142,7 @@ function calcTDesignCoefficients(filename::String) coeffs[j, c] = SphericalHarmonicExpansions.translation(coeffs[j, c], correction[:, j]) end - coeffs_MF = MagneticFieldCoefficients(coeffs, radius, zeros(size(coeffs))) + coeffs_MF = MagneticFieldCoefficients(coeffs, ustrip(tDes.radius), zeros(size(coeffs))) return coeffs_MF end diff --git a/src/utils.jl b/src/utils.jl index 3a9bd14..9f47dc3 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -26,6 +26,14 @@ function loadMagneticFieldMeasurementData(filename::String) t = tDes["t"] center = tDes["center"] + # load spherical t-design + tDes = MPIFiles.loadTDesign(Int(t), N, radius * u"m", center .* u"m") + # if measurementData contains positions, use them as t-design positions + if haskey(measurementData["positions"]["tDesign"], "positions") + tDes.positions = measurementData["positions"]["tDesign"]["positions"] + end + + # get optional data if haskey(measurementData, "sensor") correction = measurementData["sensor"]["correctionTranslation"] else @@ -33,7 +41,7 @@ function loadMagneticFieldMeasurementData(filename::String) @warn "No correction of the sensor translations found." end - return field, radius, N, t, center, correction + return field, tDes, correction end """ @@ -57,6 +65,9 @@ function loadMagneticFieldMeasurementDataV2(filename::String) tDes["N"] = read(file, "/positions/tDesign/N") # number of points of the t-design tDes["t"] = Int(read(file, "/positions/tDesign/t")) # t of the t-design tDes["center"] = read(file, "/positions/tDesign/center") # center of the measured ball + if haskey(file,"positions/tDesign/positions") # optional data + tDes["positions"] = read(file, "/positions/tDesign/positions") # measured positions (shifted and scaled t-design) + end # sensor measurementData["sensor"] = Dict{String, Any}() diff --git a/test/testWriteLoad.jl b/test/testWriteLoad.jl index ca614fb..6edfae0 100644 --- a/test/testWriteLoad.jl +++ b/test/testWriteLoad.jl @@ -8,6 +8,7 @@ # write data (v2) h5open(filename, "w") do file write(file,"/fields", fieldValues) # measured field (size: 3 x #points x #patches) + write(file,"/positions/tDesign/positions", tDes.positions) # measured positions (on the unit-sphere) write(file,"/positions/tDesign/radius", ustrip(u"m", tDes.radius)) # radius of the measured ball write(file,"/positions/tDesign/N", size(tDes.positions,2)) # number of points of the t-design write(file,"/positions/tDesign/t", tDes.T) # t of the t-design