Changeset 7617
- Timestamp:
- Feb 8, 2010, 1:58:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r7602 r7617 2016 2016 def export_grid(basename_in, extra_name_out=None, 2017 2017 quantities=None, # defaults to elevation 2018 timestep=None,2019 2018 reduction=None, 2020 2019 cellsize=10, … … 2067 2066 file_out = sww2dem(dir+sep+sww_file, dir+sep+basename_out, 2068 2067 quantity, 2069 timestep,2070 2068 reduction, 2071 2069 cellsize, … … 2197 2195 def sww2dem(basename_in, basename_out=None, 2198 2196 quantity=None, # defaults to elevation 2199 timestep=None,2200 2197 reduction=None, 2201 2198 cellsize=10, … … 2248 2245 if timestep (an index) is given, output quantity at that timestep 2249 2246 2250 if reduction is given use that to reduce quantity over all timesteps. 2247 if reduction is given and its an index, output quantity at that timestep. If reduction is given 2248 and is a built in function, use that to reduce quantity over all timesteps. 2251 2249 2252 2250 datum … … 2258 2256 2259 2257 import sys 2258 import types 2260 2259 2261 2260 from anuga.utilities.polygon import inside_polygon, outside_polygon, \ … … 2272 2271 if quantity is None: 2273 2272 quantity = 'elevation' 2274 2275 # FIXME (Ole): I reckon we need a check so that2276 # reduction and timestep cannot both be set.2277 # if reduction is not None and timestep is not None:2278 # msg = 'Either reduction or timestep must be set'2279 # msg += ' but not both.'2280 # raise Exception(msg)2281 2282 2273 2283 2274 if reduction is None: … … 2312 2303 y = fid.variables['y'][:] 2313 2304 volumes = fid.variables['volumes'][:] 2314 if t imestep is not None:2315 times = fid.variables['time'][ timestep]2305 if type(reduction) is not types.BuiltinFunctionType: 2306 times = fid.variables['time'][reduction] 2316 2307 else: 2317 2308 times = fid.variables['time'][:] … … 2345 2336 log.critical(' Reference:') 2346 2337 log.critical(' Lower left corner: [%f, %f]' % (xllcorner, yllcorner)) 2347 if t imestep is not None:2338 if type(reduction) is not types.BuiltinFunctionType: 2348 2339 log.critical(' Time: %f' % times) 2349 2340 else: … … 2354 2345 log.critical(' y [m] in [%f, %f], len(y) == %d' 2355 2346 % (num.min(y), num.max(y), len(y.flat))) 2356 if t imestep is not None:2347 if type(reduction) is not types.BuiltinFunctionType: 2357 2348 log.critical(' t [s] = %f, len(t) == %d' % (times, 1)) 2358 2349 else: … … 2364 2355 for name in ['stage', 'xmomentum', 'ymomentum']: 2365 2356 q = fid.variables[name][:].flatten() 2366 if t imestep is not None:2367 q = q[ timestep*len(x):(timestep+1)*len(x)]2357 if type(reduction) is not types.BuiltinFunctionType: 2358 q = q[reduction*len(x):(reduction+1)*len(x)] 2368 2359 if verbose: log.critical(' %s in [%f, %f]' 2369 2360 % (name, min(q), max(q))) … … 2411 2402 new_res = num.zeros(res.shape[1], num.float) 2412 2403 for k in xrange(res.shape[1]): 2413 if reduction is None:2414 new_res[k] = res[ timestep,k]2404 if type(reduction) is not types.BuiltinFunctionType: 2405 new_res[k] = res[reduction,k] 2415 2406 else: 2416 2407 new_res[k] = reduction(res[:,k]) … … 2612 2603 def sww2asc(basename_in, basename_out = None, 2613 2604 quantity = None, 2614 timestep = None,2615 2605 reduction = None, 2616 2606 cellsize = 10, … … 2622 2612 basename_out = basename_out, 2623 2613 quantity = quantity, 2624 timestep = timestep,2625 2614 reduction = reduction, 2626 2615 cellsize = cellsize, … … 2646 2635 def sww2ers(basename_in, basename_out=None, 2647 2636 quantity=None, 2648 timestep=None,2649 2637 reduction=None, 2650 2638 cellsize=10, … … 2656 2644 basename_out=basename_out, 2657 2645 quantity=quantity, 2658 timestep=timestep,2659 2646 reduction=reduction, 2660 2647 cellsize=cellsize,
Note: See TracChangeset
for help on using the changeset viewer.