Changeset 7858 for trunk/anuga_core/source/anuga/file/sts.py
 Timestamp:
 Jun 18, 2010, 4:43:10 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/anuga_core/source/anuga/file/sts.py
r7778 r7858 94 94 outfile.variables[q + Write_sts.RANGE][1] = max_float # Max 95 95 96 # Doing sts_precision instead of Float gives cast errors. 97 outfile.createVariable('time', netcdf_float, ('number_of_timesteps',)) 98 99 for q in Write_sts.sts_quantities: 100 outfile.createVariable(q, sts_precision, ('number_of_timesteps', 101 'number_of_points')) 102 outfile.createVariable(q + Write_sts.RANGE, sts_precision, 103 ('numbers_in_range',)) 104 # Initialise ranges with small and large sentinels. 105 # If this was in pure Python we could have used None sensibly 106 outfile.variables[q + Write_sts.RANGE][0] = max_float # Min 107 outfile.variables[q + Write_sts.RANGE][1] = max_float # Max 108 109 if isinstance(times, (list, num.ndarray)): 110 outfile.variables['time'][:] = times #Store time relative 111 112 if verbose: 113 log.critical('') 114 log.critical('Statistics:') 115 log.critical(' t in [%f, %f], len(t) == %d' 116 % (num.min(times), num.max(times), len(times.flat))) 96 self.write_dynamic_quantities(outfile, Write_sts.sts_quantities, times) 117 97 118 98 ## … … 265 245 266 246 247 def write_dynamic_quantities(self, outfile, quantities, 248 times, precis = netcdf_float32, verbose = False): 249 """ 250 Write out given quantities to file. 251 """ 252 for q in quantities: 253 outfile.createVariable(q, precis, ('number_of_timesteps', 254 'number_of_points')) 255 outfile.createVariable(q + Write_sts.RANGE, precis, 256 ('numbers_in_range',)) 257 258 # Initialise ranges with small and large sentinels. 259 # If this was in pure Python we could have used None sensibly 260 outfile.variables[q+Write_sts.RANGE][0] = max_float # Min 261 outfile.variables[q+Write_sts.RANGE][1] = max_float # Max 262 263 # Doing sts_precision instead of Float gives cast errors. 264 outfile.createVariable('time', netcdf_float, ('number_of_timesteps',)) 265 266 if isinstance(times, (list, num.ndarray)): 267 outfile.variables['time'][:] = times # Store time relative 268 269 if verbose: 270 log.critical('') 271 log.critical('Statistics:') 272 log.critical(' t in [%f, %f], len(t) == %d' 273 % (num.min(times), num.max(times), len(times.flat))) 274 267 275 268 276
Note: See TracChangeset
for help on using the changeset viewer.