- Timestamp:
- Nov 1, 2006, 10:58:50 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r3846 r3900 1124 1124 else: 1125 1125 raise 'Should raise exception' 1126 1127 1128 1129 def test_interpolation_interface_with_time_thinning(self): 1130 # Test spatio-temporal interpolation 1131 # Test that spatio temporal function performs the correct 1132 # interpolations in both time and space 1133 1134 #Three timesteps 1135 time = [1.0, 2.0, 4.0, 5.0, 7.0, 8.0, 9.0, 10.0] 1136 1137 #Setup mesh used to represent fitted function 1138 a = [0.0, 0.0] 1139 b = [0.0, 2.0] 1140 c = [2.0, 0.0] 1141 d = [0.0, 4.0] 1142 e = [2.0, 2.0] 1143 f = [4.0, 0.0] 1144 1145 points = [a, b, c, d, e, f] 1146 #bac, bce, ecf, dbe 1147 triangles = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]] 1148 1149 1150 #New datapoints where interpolated values are sought 1151 interpolation_points = [[ 0.0, 0.0], 1152 [ 0.5, 0.5], 1153 [ 0.7, 0.7], 1154 [ 1.0, 0.5], 1155 [ 2.0, 0.4], 1156 [ 2.8, 1.2]] 1157 1158 #One quantity 1159 Q = zeros( (8,6), Float ) 1160 1161 #Linear in time and space 1162 for i, t in enumerate(time): 1163 Q[i, :] = t*linear_function(points) 1164 1165 # Check interpolation of one quantity using interpolaton points) using default 1166 # time_thinning of 1 1167 I = Interpolation_function(time, Q, 1168 vertex_coordinates=points, 1169 triangles=triangles, 1170 interpolation_points=interpolation_points, 1171 verbose=False) 1172 1173 answer = linear_function(interpolation_points) 1174 1175 1176 t = time[0] 1177 for j in range(50): #t in [1, 6] 1178 for id in range(len(interpolation_points)): 1179 assert allclose(I(t, id), t*answer[id]) 1180 t += 0.1 1181 1182 1183 # Now check time_thinning 1184 I = Interpolation_function(time, Q, 1185 vertex_coordinates=points, 1186 triangles=triangles, 1187 interpolation_points=interpolation_points, 1188 time_thinning=2, 1189 verbose=False) 1190 1191 1192 assert len(I.time) == 4 1193 assert( allclose(I.time, [1.0, 4.0, 7.0, 9.0] )) 1194 1195 answer = linear_function(interpolation_points) 1196 1197 t = time[0] 1198 for j in range(50): #t in [1, 6] 1199 for id in range(len(interpolation_points)): 1200 assert allclose(I(t, id), t*answer[id]) 1201 t += 0.1 1202 1203 1126 1204 1127 1205
Note: See TracChangeset
for help on using the changeset viewer.