Changeset 9384
- Timestamp:
- Dec 17, 2014, 12:57:26 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file/sww.py
r9383 r9384 1372 1372 shape = quantity.shape 1373 1373 1374 def my_num_add_at(a,indices,b): 1375 """ 1376 Use the numpy add.at opperation if it is available, (numpy version >1.8) 1377 otherwise just use a quick and dirty implementation via a python loop 1378 """ 1379 1380 try: 1381 num.add.at(a, indices, b) 1382 except: 1383 n_ids = len(indices) 1384 b_array = num.zeros_like(indices,dtype=num.float) 1385 b_array[:] = b 1386 1387 for n in xrange(n_ids): 1388 a[indices[n]] = a[indices[n]] + b_array[n] 1389 1390 1391 1374 1392 if len(shape) == 2: 1375 1393 # time array … … 1384 1402 1385 1403 count_uv = num.zeros(len(mesh.nodes)) 1386 num.add.at(count_uv, mesh_ids, 1)1404 my_num_add_at(count_uv, mesh_ids, 1) 1387 1405 1388 1406 for i in range(n_time): 1389 num.add.at(temp_uv[i,:], mesh_ids, quantity[i,:] )1407 my_num_add_at(temp_uv[i,:], mesh_ids, quantity[i,:] ) 1390 1408 temp_uv[i,:] = temp_uv[i,:]/count_uv 1391 1409 … … 1399 1417 1400 1418 count_uv = num.zeros(len(mesh.nodes)) 1401 num.add.at(count_uv, mesh_ids, 1)1402 num.add.at(temp_uv, mesh_ids, quantity )1419 my_num_add_at(count_uv, mesh_ids, 1) 1420 my_num_add_at(temp_uv, mesh_ids, quantity ) 1403 1421 1404 1422 else:
Note: See TracChangeset
for help on using the changeset viewer.