Changeset 7602
- Timestamp:
- Jan 6, 2010, 9:23:10 PM (15 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
r7574 r7602 702 702 fin = NetCDFFile(self.source, 'r') 703 703 704 for q in filter(lambda n:n != 'x' and n != 'y' and n != ' z' and n != 'time' and n != 'volumes' and \704 for q in filter(lambda n:n != 'x' and n != 'y' and n != 'time' and n != 'volumes' and \ 705 705 '_range' not in n, \ 706 706 fin.variables.keys()): … … 3413 3413 3414 3414 #FIXME use the Write_sww instance(sww) to write this info 3415 z = num.resize(z, outfile.variables[' z'][:].shape)3415 z = num.resize(z, outfile.variables['elevation'][:].shape) 3416 3416 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 3417 3417 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() 3418 outfile.variables['z'][:] = z #FIXME HACK for bacwards compat.3418 #outfile.variables['z'][:] = z #FIXME HACK for bacwards compat. 3419 3419 outfile.variables['elevation'][:] = z 3420 3420 outfile.variables['volumes'][:] = volumes.astype(num.int32) #For Opteron 64 … … 3707 3707 other_quantities.remove('x') 3708 3708 other_quantities.remove('y') 3709 other_quantities.remove('z')3709 #other_quantities.remove('z') 3710 3710 other_quantities.remove('volumes') 3711 3711 try: … … 4264 4264 4265 4265 #FIXME: Backwards compatibility 4266 outfile.createVariable('z', precision, ('number_of_points',))4266 #outfile.createVariable('z', precision, ('number_of_points',)) 4267 4267 ################################# 4268 4268 … … 4339 4339 log.critical('geo_ref: ', geo_ref) 4340 4340 4341 z = num.resize(bath_grid,outfile.variables[' z'][:].shape)4341 z = num.resize(bath_grid,outfile.variables['elevation'][:].shape) 4342 4342 outfile.variables['x'][:] = x - geo_ref.get_xllcorner() 4343 4343 outfile.variables['y'][:] = y - geo_ref.get_yllcorner() 4344 # FIXME (Ole): Remove once viewer has been recompiled and changed4345 # to use elevation instead of z4346 outfile.variables['z'][:] = z4344 # FIXME (Ole): Remove once viewer has been recompiled and changed 4345 # to use elevation instead of z 4346 #outfile.variables['z'][:] = z 4347 4347 outfile.variables['elevation'][:] = z 4348 4348 outfile.variables['volumes'][:] = volumes.astype(num.int32) # On Opteron 64 … … 6099 6099 outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max 6100 6100 6101 if 'elevation' in self.static_quantities:6102 # FIXME: Backwards compat - get rid of z once old view has retired6103 outfile.createVariable('z', sww_precision,6104 ('number_of_points',))6101 #if 'elevation' in self.static_quantities: 6102 # # FIXME: Backwards compat - get rid of z once old view has retired 6103 # outfile.createVariable('z', sww_precision, 6104 # ('number_of_points',)) 6105 6105 6106 6106 for q in self.dynamic_quantities: … … 6267 6267 6268 6268 # FIXME: Hack for backwards compatibility with old viewer 6269 if 'elevation' in self.static_quantities:6270 outfile.variables['z'][:] = outfile.variables['elevation'][:]6269 #if 'elevation' in self.static_quantities: 6270 # outfile.variables['z'][:] = outfile.variables['elevation'][:] 6271 6271 6272 6272 … … 6638 6638 geo_ref.write_NetCDF(outfile) 6639 6639 6640 x = 6641 y = 6642 z = outfile.variables[' z'][:]6640 x = points[:,0] 6641 y = points[:,1] 6642 z = outfile.variables['elevation'][:] 6643 6643 6644 6644 if verbose: … … 6655 6655 log.critical('------------------------------------------------') 6656 6656 6657 #z = resize(bath_grid,outfile.variables['z'][:].shape)6657 z = resize(bath_grid,outfile.variables['elevation'][:].shape) 6658 6658 outfile.variables['x'][:] = points[:,0] #- geo_ref.get_xllcorner() 6659 6659 outfile.variables['y'][:] = points[:,1] #- geo_ref.get_yllcorner() 6660 outfile.variables['z'][:] = elevation6660 #outfile.variables['z'][:] = elevation 6661 6661 outfile.variables['elevation'][:] = elevation #FIXME HACK4 6662 6662 -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r7520 r7602 182 182 sww.store_connectivity() 183 183 184 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append184 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append 185 185 186 186 # Get the variables … … 214 214 sww.store_connectivity() 215 215 216 # Check contents217 # Get NetCDF218 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append216 # Check contents 217 # Get NetCDF 218 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append 219 219 220 220 # Get the variables … … 383 383 sww.store_connectivity() 384 384 385 # Check contents386 # Get NetCDF387 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append385 # Check contents 386 # Get NetCDF 387 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append 388 388 389 389 # Get the variables … … 424 424 sww.store_timestep() 425 425 426 # Check contents427 # Get NetCDF428 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append426 # Check contents 427 # Get NetCDF 428 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append 429 429 430 430 … … 475 475 476 476 477 # Check contents478 # Get NetCDF479 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append477 # Check contents 478 # Get NetCDF 479 fid = NetCDFFile(sww.filename, netcdf_mode_r) # Open existing file for append 480 480 481 481 # Get the variables … … 2371 2371 2372 2372 2373 # Export to ascii/prj files2373 # Export to ascii/prj files 2374 2374 sww2dem(domain.get_name(), 2375 2375 quantity = 'elevation', … … 2386 2386 2387 2387 2388 # Check prj (meta data)2388 # Check prj (meta data) 2389 2389 prjid = open(prjfile) 2390 2390 lines = prjid.readlines() … … 4220 4220 (228+229+230+246+247+248+264+265+266) / 9.0] 4221 4221 4222 # generate a stencil for computing the decimated values4222 # generate a stencil for computing the decimated values 4223 4223 stencil = num.ones((3,3), num.float) / 9.0 4224 4224 4225 4225 decimate_dem(root, stencil=stencil, cellsize_new=100) 4226 4226 4227 # Open decimated NetCDF file4227 # Open decimated NetCDF file 4228 4228 fid = NetCDFFile(root + '_100.dem', netcdf_mode_r) 4229 4229 … … 4231 4231 elevation = fid.variables['elevation'] 4232 4232 4233 # Check values4233 # Check values 4234 4234 assert num.allclose(elevation, ref_elevation) 4235 4235 4236 # Cleanup4236 # Cleanup 4237 4237 fid.close() 4238 4238 … … 4247 4247 from Scientific.IO.NetCDF import NetCDFFile 4248 4248 4249 # Write test dem file4249 # Write test dem file 4250 4250 root = 'decdemtest' 4251 4251 … … 4281 4281 elevation = fid.variables['elevation'] 4282 4282 4283 # generate initial elevation values4283 # Generate initial elevation values 4284 4284 elevation_tmp = (num.arange(nrows*ncols)) 4285 #add some NODATA values 4285 4286 # Add some NODATA values 4286 4287 elevation_tmp[0] = NODATA_value 4287 4288 elevation_tmp[95] = NODATA_value … … 4296 4297 fid.close() 4297 4298 4298 # generate the elevation values expected in the decimated file4299 # Generate the elevation values expected in the decimated file 4299 4300 ref_elevation = [NODATA_value, 4300 4301 ( 4+ 5+ 6+ 22+ 23+ 24+ 40+ 41+ 42) / 9.0, … … 4314 4315 (228+229+230+246+247+248+264+265+266) / 9.0] 4315 4316 4316 # generate a stencil for computing the decimated values4317 # Generate a stencil for computing the decimated values 4317 4318 stencil = num.ones((3,3), num.float) / 9.0 4318 4319 4319 4320 decimate_dem(root, stencil=stencil, cellsize_new=100) 4320 4321 4321 # Open decimated NetCDF file4322 # Open decimated NetCDF file 4322 4323 fid = NetCDFFile(root + '_100.dem', netcdf_mode_r) 4323 4324 … … 4325 4326 elevation = fid.variables['elevation'] 4326 4327 4327 # Check values4328 # Check values 4328 4329 assert num.allclose(elevation, ref_elevation) 4329 4330 4330 # Cleanup4331 # Cleanup 4331 4332 fid.close() 4332 4333 … … 4501 4502 # check the sww file 4502 4503 4503 fid = NetCDFFile(sww_file, netcdf_mode_r) # Open existing file for read4504 fid = NetCDFFile(sww_file, netcdf_mode_r) # Open existing file for read 4504 4505 x = fid.variables['x'][:] 4505 4506 y = fid.variables['y'][:] 4506 z = fid.variables[' z'][:]4507 z = fid.variables['elevation'][:] 4507 4508 stage = fid.variables['stage'][:] 4508 4509 xmomentum = fid.variables['xmomentum'][:] … … 4811 4812 # check the sww file 4812 4813 4813 fid = NetCDFFile(sww_file, netcdf_mode_r) # Open existing file for read4814 fid = NetCDFFile(sww_file, netcdf_mode_r) # Open existing file for read 4814 4815 x = fid.variables['x'][:] 4815 4816 y = fid.variables['y'][:] 4816 z = fid.variables[' z'][:]4817 z = fid.variables['elevation'][:] 4817 4818 stage = fid.variables['stage'][:] 4818 4819 xmomentum = fid.variables['xmomentum'][:] … … 5005 5006 # check the sww file 5006 5007 5007 fid = NetCDFFile(sww_file, netcdf_mode_r) # Open existing file for read5008 fid = NetCDFFile(sww_file, netcdf_mode_r) # Open existing file for read 5008 5009 x = fid.variables['x'][:] 5009 5010 y = fid.variables['y'][:] 5010 z = fid.variables[' z'][:]5011 z = fid.variables['elevation'][:] 5011 5012 stage = fid.variables['stage'][:] 5012 5013 xmomentum = fid.variables['xmomentum'][:] … … 7757 7758 7758 7759 # read in sts file for combined source 7759 fid = NetCDFFile(sts_name_out+'.sts', netcdf_mode_r) # Open existing file for read7760 x = fid.variables['x'][:]+fid.xllcorner # x-coordinates of vertices7761 y = fid.variables['y'][:]+fid.yllcorner # y-coordinates of vertices7760 fid = NetCDFFile(sts_name_out+'.sts', netcdf_mode_r) # Open existing file for read 7761 x = fid.variables['x'][:]+fid.xllcorner # x-coordinates of vertices 7762 y = fid.variables['y'][:]+fid.yllcorner # y-coordinates of vertices 7762 7763 elevation = fid.variables['elevation'][:] 7763 7764 time=fid.variables['time'][:]+fid.starttime … … 7771 7772 assert num.allclose(stored_permutation, permutation), msg 7772 7773 7773 # get quantity data from sts file7774 # Get quantity data from sts file 7774 7775 quantity_names=['stage','xmomentum','ymomentum'] 7775 7776 quantities = {}
Note: See TracChangeset
for help on using the changeset viewer.