Changeset 6170
 Timestamp:
 Jan 14, 2009, 4:34:19 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

anuga_core/source/anuga/fit_interpolate/test_interpolate.py
r6165 r6170 1328 1328 assert num.allclose(I(t, id), t*answer[id]) 1329 1329 t += 0.1 1330 1331 1332 1333 def test_interpolation_interface_with_time_limit(self):1334 """test_interpolation_interface_with_time_limit1335 1336 Test spatiotemporal interpolation1337 Test that spatio temporal function performs the correct1338 interpolations in both time and space1339 """1340 1341 #fixme: not done1342 1343 # Eight timesteps1344 time = [1.0, 2.0, 4.0, 5.0, 7.0, 8.0, 9.0, 10.0]1345 1346 # Setup mesh used to represent fitted function1347 a = [0.0, 0.0]1348 b = [0.0, 2.0]1349 c = [2.0, 0.0]1350 d = [0.0, 4.0]1351 e = [2.0, 2.0]1352 f = [4.0, 0.0]1353 1354 points = [a, b, c, d, e, f]1355 # bac, bce, ecf, dbe1356 triangles = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]]1357 1358 1359 # New datapoints where interpolated values are sought1360 interpolation_points = [[ 0.0, 0.0],1361 [ 0.5, 0.5],1362 [ 0.7, 0.7],1363 [ 1.0, 0.5],1364 [ 2.0, 0.4],1365 [ 2.8, 1.2]]1366 1367 # One quantity1368 Q = num.zeros((8,6), num.Float)1369 1370 # Linear in time and space1371 for i, t in enumerate(time):1372 Q[i, :] = t*linear_function(points)1373 1374 # Check interpolation of one quantity using interpolaton points) using default1375 # time_thinning of 11376 I = Interpolation_function(time, Q,1377 vertex_coordinates=points,1378 triangles=triangles,1379 interpolation_points=interpolation_points,1380 verbose=False)1381 1382 answer = linear_function(interpolation_points)1383 1384 1385 t = time[0]1386 for j in range(90): #t in [1, 10]1387 for id in range(len(interpolation_points)):1388 assert num.allclose(I(t, id), t*answer[id])1389 t += 0.11390 1391 1392 # Now check time_thinning1393 I = Interpolation_function(time, Q,1394 vertex_coordinates=points,1395 triangles=triangles,1396 interpolation_points=interpolation_points,1397 time_thinning=2,1398 verbose=False)1399 1400 1401 assert len(I.time) == 41402 assert num.allclose(I.time, [1.0, 4.0, 7.0, 9.0])1403 1404 answer = linear_function(interpolation_points)1405 1406 t = time[0]1407 for j in range(80): #t in [1, 9]1408 for id in range(len(interpolation_points)):1409 assert num.allclose(I(t, id), t*answer[id])1410 t += 0.11411 1412 1330 1413 1331
Note: See TracChangeset
for help on using the changeset viewer.