Skip to content

Commit 0ce99b4

Browse files
committed
load coefficients from file
1 parent f8c3367 commit 0ce99b4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/MPISphericalHarmonics.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,22 @@ Base.@kwdef mutable struct SphericalHarmonicsDefinedField <: AbstractMagneticFie
194194
end
195195

196196
function SphericalHarmonicsDefinedField(filename::String)
197-
coeffs_MF, expansion, func = loadTDesign(filename)
197+
198+
file = h5open(filename,"r")
199+
200+
if haskey(file,"coeffs")
201+
# load coefficients
202+
coeffs_MF = MagneticFieldCoefficients(filename)
203+
func = fastfunc.(coeffs_MF.coeffs)
204+
else
205+
# load measured field
206+
coeffs_MF, expansion, func = loadTDesign(filename)
207+
end
208+
198209
return SphericalHarmonicsDefinedField(func=func)
199210
end
200211

212+
201213
MPIMagneticFields.fieldType(::SphericalHarmonicsDefinedField) = OtherField()
202214
MPIMagneticFields.definitionType(::SphericalHarmonicsDefinedField) = SphericalHarmonicsDataBasedFieldDefinition()
203215
MPIMagneticFields.timeDependencyType(::SphericalHarmonicsDefinedField) = TimeConstant()

0 commit comments

Comments
 (0)