Changeset 7822
- Timestamp:
- Jun 11, 2010, 11:56:36 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/utilities/sww_merge.py
r7820 r7822 18 18 May be useful for parallel runs. Note that some advanced information 19 19 and custom quantities may not be exported. 20 21 The sww files to be merged must have exactly the same timesteps. 22 23 swwfiles is a list of .sww files to merge. 24 output is the output filename, including .sww extension. 25 verbose True to log output information 20 26 """ 21 27 … … 43 49 out_s_quantities[quantity] = [] 44 50 51 # Quantities are stored as a 2D array of timesteps x data. 45 52 for quantity in dynamic_quantities: 46 53 out_d_quantities[quantity] = [ [] for _ in range(len(times))] … … 50 57 else: 51 58 for tri in tris: 59 # Advance new tri indices to point at newly appended points. 52 60 verts = [vertex+tri_offset for vertex in tri] 53 61 out_tris.append(verts) … … 62 70 y.extend(list(fid.variables['y'][:])) 63 71 72 # Grow the list of static quantities associated with the x,y points 64 73 for quantity in static_quantities: 65 74 out_s_quantities[quantity].extend(fid.variables[quantity][:]) 66 75 76 #Collate all dynamic quantities according to their timestep 67 77 for quantity in dynamic_quantities: 68 78 time_chunks = fid.variables[quantity][:] 69 79 for i, time_chunk in enumerate(time_chunks): 70 80 out_d_quantities[quantity][i].extend(time_chunk) 71 81 82 # Mash all points into a single big list 72 83 points = [[xx, yy] for xx, yy in zip(x, y)] 73 84 fid.close() 74 85 75 # NetCDF file definition86 # Write out the SWW file 76 87 fido = NetCDFFile(output, netcdf_mode_w) 77 88 sww = Write_sww(static_quantities, dynamic_quantities) … … 87 98 sww.store_static_quantities(fido, verbose=verbose, **out_s_quantities) 88 99 100 # Write out all the dynamic quantities for each timestep 89 101 for q in dynamic_quantities: 90 102 q_values = out_d_quantities[q]
Note: See TracChangeset
for help on using the changeset viewer.