@@ -90,19 +90,14 @@ using Aqua
90
90
@test_throws DimensionMismatch MagneticFieldCoefficients (coeffs, tDes, zeros (3 ,2 ))
91
91
end
92
92
93
- @testset " Load data from file" begin
93
+ @testset " Load/write data from/to file" begin
94
94
ɛ = eps (Float64)
95
95
96
96
# # measurement data (without coefficients)
97
97
filename = " idealGradientField.h5"
98
98
field = SphericalHarmonicsDefinedField (filename)
99
99
@test isapprox (field[0.01 ,0.01 ,0.01 ], [- 0.01 ,- 0.01 ,0.02 ], atol= ε)
100
100
101
- # Test field types
102
- @test fieldType (field) isa OtherField
103
- @test definitionType (field) isa SphericalHarmonicsDataBasedFieldDefinition
104
- @test timeDependencyType (field) isa TimeConstant
105
-
106
101
# get coefficients
107
102
coeffsMF, = MPISphericalHarmonics. loadTDesignCoefficients (filename)
108
103
@test isapprox (coeffsMF. radius, 0.042 , atol= ε) # radius
@@ -115,6 +110,7 @@ using Aqua
115
110
filename2 = " Coeffs.h5"
116
111
filename3 = " Coeffs2.h5"
117
112
filename4 = " Coeffs3.h5"
113
+ filenameW = " CoeffsW.h5"
118
114
write (filename2, coeffsMF. coeffs)
119
115
# add radius and center
120
116
cp (filename2, filename3)
@@ -144,17 +140,30 @@ using Aqua
144
140
field = SphericalHarmonicsDefinedField (filename4)
145
141
@test isapprox (field[- 0.02 ,0.02 ,- 0.03 ], [0.02 ,- 0.02 ,- 0.06 ], atol= ε)
146
142
143
+ # test write
144
+ MPISphericalHarmonics. write (filenameW, coeffsTest)
145
+ coeffsW = MagneticFieldCoefficients (filenameW)
146
+ @test isapprox (coeffsW. radius, 0.042 , atol= ε) # radius
147
+ @test isapprox (coeffsW. center, zeros (3 ), atol= ε) # center
148
+ @test coeffsW. ffp == zeros (3 ,1 ) # FFP
149
+
147
150
# remove test files
148
151
rm (filename2)
149
152
rm (filename3)
150
153
rm (filename4)
154
+ rm (filenameW)
151
155
end
152
156
153
- @testset " Multiple patches" begin
157
+ @testset " SphericalHarmonicsDefinedField (multiple patches) " begin
154
158
# # Multi-patch setting: Second field with offset
155
159
coeffsPatch = hcat (deepcopy (coeffs),deepcopy (coeffs)) # two patches
156
160
for j= 1 : 3 coeffsPatch[j,2 ][0 ,0 ] = 0.01 end # set offset
157
- field = SphericalHarmonicsDefinedField (func = fastfunc .(coeffsPatch))
161
+ field = SphericalHarmonicsDefinedField (coeffsPatch) # test constructor on coefficients
162
+
163
+ # Test field types
164
+ @test fieldType (field) isa OtherField
165
+ @test definitionType (field) isa SphericalHarmonicsDataBasedFieldDefinition
166
+ @test timeDependencyType (field) isa TimeConstant
158
167
159
168
# # Test FFPs (for both patches)
160
169
# First patch
0 commit comments