Changeset 7339
 Timestamp:
 Aug 7, 2009, 6:46:22 PM (14 years ago)
 Location:
 anuga_core/source/anuga/shallow_water
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

anuga_core/source/anuga/shallow_water/data_manager.py
r7317 r7339 350 350 from Scientific.IO.NetCDF import NetCDFFile 351 351 352 self.precision = netcdf_float32 # Use single precision for quantities352 self.precision = netcdf_float32 # Use single precision for quantities 353 353 self.recursion = recursion 354 354 self.mode = mode 355 355 if hasattr(domain, 'max_size'): 356 self.max_size = domain.max_size # file size max is 2Gig356 self.max_size = domain.max_size # File size max is 2Gig 357 357 else: 358 358 self.max_size = max_size … … 370 370 description = 'Output from anuga.abstract_2d_finite_volumes ' \ 371 371 'suitable for plotting' 372 self.writer = Write_sww( )372 self.writer = Write_sww(['elevation'], domain.conserved_quantities) 373 373 self.writer.store_header(fid, 374 374 domain.starttime, … … 3243 3243 starttime = times[0] 3244 3244 3245 sww = Write_sww( )3245 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 3246 3246 sww.store_header(outfile, times, number_of_volumes, 3247 3247 number_of_points, description=description, … … 5335 5335 # For a different way of doing this, check out tsh2sww 5336 5336 # work out sww_times and the index range this covers 5337 sww = Write_sww( )5337 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 5338 5338 sww.store_header(outfile, times, len(volumes), len(points_utm), 5339 5339 verbose=verbose, sww_precision=netcdf_float) … … 5850 5850 5851 5851 5852 ##5853 5852 # @brief A class to write an SWW file. 5854 5853 class Write_sww: 5855 5854 from anuga.shallow_water.shallow_water_domain import Domain 5856 5855 5857 # FIXME (Ole): Hardwiring the conserved quantities like5858 # this could be a problem. I would prefer taking them from5859 # the instantiation of Domain.5860 #5861 # (DSG) There is not always a Domain instance when Write_sww is used.5862 # Check to see if this is the same level of hardwiring as is in5863 # shallow water doamain.5864 5865 sww_quantities = Domain.conserved_quantities5866 5867 5856 RANGE = '_range' 5868 5857 EXTREMA = ':extrema' … … 5870 5859 ## 5871 5860 # brief Instantiate the SWW writer class. 5872 def __init__(self): 5873 pass 5861 def __init__(self, static_quantities, dynamic_quantities): 5862 """Initialise SWW writer with two list af quantity names: 5863 5864 static_quantities (e.g. elevation or friction): 5865 Stored once at the beginning of the simulation in a 1D array 5866 of length number_of_points 5867 dynamic_quantities (e.g stage): 5868 Stored every timestep in a 2D array with 5869 dimensions number_of_points X number_of_timesteps 5870 5871 """ 5872 self.static_quantities = static_quantities 5873 self.dynamic_quantities = dynamic_quantities 5874 5874 5875 5875 5876 ## … … 5960 5961 outfile.createVariable('x', sww_precision, ('number_of_points',)) 5961 5962 outfile.createVariable('y', sww_precision, ('number_of_points',)) 5962 outfile.createVariable('elevation', sww_precision,5963 ('number_of_points',))5964 q = 'elevation'5965 outfile.createVariable(q + Write_sww.RANGE, sww_precision,5966 ('numbers_in_range',))5967 5968 # Initialise ranges with small and large sentinels.5969 # If this was in pure Python we could have used None sensibly5970 outfile.variables[q+Write_sww.RANGE][0] = max_float # Min5971 outfile.variables[q+Write_sww.RANGE][1] = max_float # Max5972 5973 # FIXME: Backwards compatibility5974 outfile.createVariable('z', sww_precision, ('number_of_points',))5975 5963 5976 5964 outfile.createVariable('volumes', netcdf_int, ('number_of_volumes', … … 5981 5969 ('number_of_timesteps',)) 5982 5970 5983 for q in Write_sww.sww_quantities: 5971 5972 for q in self.static_quantities: 5973 5974 outfile.createVariable(q, sww_precision, 5975 ('number_of_points',)) 5976 5977 outfile.createVariable(q + Write_sww.RANGE, sww_precision, 5978 ('numbers_in_range',)) 5979 5980 # Initialise ranges with small and large sentinels. 5981 # If this was in pure Python we could have used None sensibly 5982 outfile.variables[q+Write_sww.RANGE][0] = max_float # Min 5983 outfile.variables[q+Write_sww.RANGE][1] = max_float # Max 5984 5985 # FIXME: Backwartds compat get rid of z once old view has retired 5986 5987 outfile.createVariable('z', sww_precision, 5988 ('number_of_points',)) 5989 5990 for q in self.dynamic_quantities: 5984 5991 outfile.createVariable(q, sww_precision, ('number_of_timesteps', 5985 5992 'number_of_points')) … … 6149 6156 # Also write the ranges: stage_range, 6150 6157 # xmomentum_range and ymomentum_range 6151 for q in Write_sww.sww_quantities:6158 for q in self.dynamic_quantities: 6152 6159 if not quant.has_key(q): 6153 6160 msg = 'SWW file can not write quantity %s' % q … … 6175 6182 log.critical('') 6176 6183 log.critical('More Statistics:') 6177 for q in Write_sww.sww_quantities:6184 for q in self.dynamic_quantities: 6178 6185 log.critical(' %s in [%f, %f]' 6179 6186 % (q, outfile.variables[q+Write_sww.RANGE][0], 
anuga_core/source/anuga/shallow_water/test_data_manager.py
r7308 r7339 10419 10419 number_of_volumes = len(volumes) 10420 10420 number_of_points = len(points_utm) 10421 sww = Write_sww( )10421 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 10422 10422 sww.store_header(outfile, times, number_of_volumes, 10423 10423 number_of_points, description='fully sick testing', … … 10451 10451 number_of_volumes = len(volumes) 10452 10452 number_of_points = len(points_utm) 10453 sww = Write_sww( )10453 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 10454 10454 sww.store_header(outfile, times, number_of_volumes, 10455 10455 number_of_points, description='fully sick testing', … … 10487 10487 number_of_volumes = len(volumes) 10488 10488 number_of_points = len(points_utm) 10489 sww = Write_sww( )10489 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 10490 10490 sww.store_header(outfile, times, number_of_volumes, 10491 10491 number_of_points, description='fully sick testing', … … 10526 10526 number_of_volumes = len(volumes) 10527 10527 number_of_points = len(points_utm) 10528 sww = Write_sww( )10528 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 10529 10529 sww.store_header(outfile, times, number_of_volumes, 10530 10530 number_of_points, description='fully sick testing', … … 10562 10562 number_of_volumes = len(volumes) 10563 10563 number_of_points = len(points_utm) 10564 sww = Write_sww( )10564 sww = Write_sww(['elevation'], ['stage', 'xmomentum', 'ymomentum']) 10565 10565 sww.store_header(outfile, times, number_of_volumes, 10566 10566 number_of_points, description='fully sick testing',
Note: See TracChangeset
for help on using the changeset viewer.