- Timestamp:
- Apr 22, 2013, 2:59:58 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/anuga_core/source/anuga/file_conversion/sww2array.py
r8780 r8847 27 27 28 28 # Default block size for sww2dem() 29 DEFAULT_BLOCK_SIZE = 10000 29 DEFAULT_BLOCK_SIZE = 100000 30 30 31 31 def sww2array(name_in, … … 197 197 198 198 # Get slices of all required variables 199 q_dict = {} 200 for name in var_list: 201 # check if variable has time axis 202 if len(fid.variables[name].shape) == 2: 203 q_dict[name] = fid.variables[name][:,start_slice:end_slice] 204 else: # no time axis 205 q_dict[name] = fid.variables[name][start_slice:end_slice] 206 207 # Evaluate expression with quantities found in SWW file 208 res = apply_expression_to_dictionary(quantity, q_dict) 209 210 if len(res.shape) == 2: 211 new_res = num.zeros(res.shape[1], num.float) 212 for k in xrange(res.shape[1]): 213 if type(reduction) is not types.BuiltinFunctionType: 214 new_res[k] = res[reduction,k] 215 else: 216 new_res[k] = reduction(res[:,k]) 217 res = new_res 199 if type(reduction) is not types.BuiltinFunctionType: 200 q_dict = {} 201 for name in var_list: 202 # check if variable has time axis 203 if len(fid.variables[name].shape) == 2: 204 print 'avoiding large array' 205 q_dict[name] = fid.variables[name][reduction,start_slice:end_slice] 206 else: # no time axis 207 q_dict[name] = fid.variables[name][start_slice:end_slice] 208 209 # Evaluate expression with quantities found in SWW file 210 res = apply_expression_to_dictionary(quantity, q_dict) 211 212 # if len(res.shape) == 2: 213 # new_res = num.zeros(res.shape[1], num.float) 214 # for k in xrange(res.shape[1]): 215 # if type(reduction) is not types.BuiltinFunctionType: 216 # new_res[k] = res[k] 217 # else: 218 # new_res[k] = reduction(res[:,k]) 219 # res = new_res 220 else: 221 q_dict = {} 222 for name in var_list: 223 # check if variable has time axis 224 if len(fid.variables[name].shape) == 2: 225 q_dict[name] = fid.variables[name][:,start_slice:end_slice] 226 else: # no time axis 227 q_dict[name] = fid.variables[name][start_slice:end_slice] 228 229 # Evaluate expression with quantities found in SWW file 230 res = apply_expression_to_dictionary(quantity, q_dict) 231 232 if len(res.shape) == 2: 233 new_res = num.zeros(res.shape[1], num.float) 234 for k in xrange(res.shape[1]): 235 if type(reduction) is not types.BuiltinFunctionType: 236 new_res[k] = res[reduction,k] 237 else: 238 new_res[k] = reduction(res[:,k]) 239 res = new_res 218 240 219 241 result[start_slice:end_slice] = res … … 282 304 283 305 284 306 fid.close() 307 285 308 #print outside_indices 286 309
Note: See TracChangeset
for help on using the changeset viewer.