@@ -55,28 +55,31 @@ MagneticFieldCoefficients(coeffs::Array{SphericalHarmonicCoefficients,2}, tDesig
55
55
56
56
# read coefficients from an HDF5-file
57
57
function MagneticFieldCoefficients (path:: String )
58
- file = h5open (path," r" )
59
58
60
59
# load spherical harmonic coefficients
61
60
shcoeffs = SphericalHarmonicCoefficients (path)
62
-
63
- if haskey (HDF5. root (file), " /radius" )
64
- # file contains all relevant information
65
- radius = read (file, " /radius" )
66
- center = read (file, " /center" )
67
- if haskey (HDF5. root (file), " /ffp" )
68
- ffp = read (file, " /ffp" )
69
- return MagneticFieldCoefficients (shcoeffs, radius, center, ffp)
61
+
62
+ coeffsMF = h5open (path," r" ) do file
63
+ if haskey (HDF5. root (file), " /radius" )
64
+ # file contains all relevant information
65
+ radius = read (file, " /radius" )
66
+ center = read (file, " /center" )
67
+ if haskey (HDF5. root (file), " /ffp" )
68
+ ffp = read (file, " /ffp" )
69
+ return MagneticFieldCoefficients (shcoeffs, radius, center, ffp)
70
+ else
71
+ # field has not FFP -> ffp = nothing
72
+ return MagneticFieldCoefficients (shcoeffs, radius, center)
73
+ end
70
74
else
71
- # field has not FFP -> ffp = nothing
72
- return MagneticFieldCoefficients (shcoeffs, radius, center)
75
+ # convert file of SphericalHarmonicCoefficients into MagneticFieldCoefficients
76
+ # -> set all additional informations to 0 or nothing
77
+ # use radius = 0.01 as default value
78
+ return MagneticFieldCoefficients (shcoeffs, 0.01 )
73
79
end
74
- else
75
- # convert file of SphericalHarmonicCoefficients into MagneticFieldCoefficients
76
- # -> set all additional informations to 0 or nothing
77
- # use radius = 0.01 as default value
78
- return MagneticFieldCoefficients (shcoeffs, 0.01 )
79
80
end
81
+
82
+ return coeffsMF
80
83
end
81
84
82
85
"""
@@ -200,15 +203,17 @@ end
200
203
201
204
function SphericalHarmonicsDefinedField (filename:: String )
202
205
203
- file = h5open (filename," r" )
206
+ func = h5open (filename," r" ) do file
207
+ if haskey (file," coeffs" )
208
+ # load coefficients
209
+ coeffs_MF = MagneticFieldCoefficients (filename)
210
+ func = fastfunc .(coeffs_MF. coeffs)
211
+ else
212
+ # load measured field
213
+ coeffs_MF, expansion, func = loadTDesignCoefficients (filename)
214
+ end
204
215
205
- if haskey (file," coeffs" )
206
- # load coefficients
207
- coeffs_MF = MagneticFieldCoefficients (filename)
208
- func = fastfunc .(coeffs_MF. coeffs)
209
- else
210
- # load measured field
211
- coeffs_MF, expansion, func = loadTDesignCoefficients (filename)
216
+ return func
212
217
end
213
218
214
219
return SphericalHarmonicsDefinedField (func= func)
0 commit comments