Changeset 4862
- Timestamp:
- Nov 28, 2007, 4:52:47 PM (17 years ago)
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r4850 r4862 70 70 from Numeric import concatenate, array, Float, Int, Int32, resize, sometrue, \ 71 71 searchsorted, zeros, allclose, around, reshape, transpose, sort, \ 72 NewAxis, ArrayType, compress, take, arange, argmax, alltrue,shape,Float 72 NewAxis, ArrayType, compress, take, arange, argmax, alltrue,shape,Float32 73 73 74 74 import string … … 337 337 description=description, 338 338 smoothing=domain.smooth, 339 order=domain.default_order) 339 order=domain.default_order, 340 sww_precision=self.precision) 340 341 341 342 # Extra optional information … … 542 543 self.writer.store_quantities(fid, 543 544 time=self.domain.time, 544 precision=self.precision,545 sww_precision=self.precision, 545 546 stage=stage, 546 547 xmomentum=xmomentum, … … 2898 2899 # Create new file 2899 2900 starttime = times[0] 2901 2900 2902 sww = Write_sww() 2901 2903 sww.store_header(outfile, times, number_of_volumes, 2902 2904 number_of_points, description=description, 2903 verbose=verbose )2905 verbose=verbose,sww_precision=Float) 2904 2906 2905 2907 # Store … … 2957 2959 #FIXME: z should be obtained from MOST and passed in here 2958 2960 2961 #FIXME use the Write_sww instance(sww) to write this info 2959 2962 from Numeric import resize 2960 2963 z = resize(z,outfile.variables['z'][:].shape) … … 4742 4745 sww = Write_sww() 4743 4746 sww.store_header(outfile, times, len(volumes), len(points_utm), 4744 verbose=verbose )4747 verbose=verbose,sww_precision=Float) 4745 4748 outfile.mean_stage = mean_stage 4746 4749 outfile.zscale = zscale … … 4764 4767 stage=stage, 4765 4768 xmomentum=xmomentum, 4766 ymomentum=ymomentum) 4769 ymomentum=ymomentum, 4770 sww_precision=Float) 4767 4771 j += 1 4768 4772 if verbose: sww.verbose_quantities(outfile) … … 4818 4822 description='Converted from XXX', 4819 4823 smoothing=True, 4820 order=1, verbose=False): 4824 order=1, 4825 sww_precision=Float32, 4826 verbose=False): 4821 4827 """ 4822 4828 outfile - the name of the file that will be written … … 4885 4891 4886 4892 # variable definitions 4887 outfile.createVariable('x', precision, ('number_of_points',))4888 outfile.createVariable('y', precision, ('number_of_points',))4889 outfile.createVariable('elevation', precision, ('number_of_points',))4893 outfile.createVariable('x', sww_precision, ('number_of_points',)) 4894 outfile.createVariable('y', sww_precision, ('number_of_points',)) 4895 outfile.createVariable('elevation', sww_precision, ('number_of_points',)) 4890 4896 q = 'elevation' 4891 outfile.createVariable(q+Write_sww.RANGE, precision,4897 outfile.createVariable(q+Write_sww.RANGE, sww_precision, 4892 4898 ('numbers_in_range',)) 4893 4899 … … 4895 4901 # Initialise ranges with small and large sentinels. 4896 4902 # If this was in pure Python we could have used None sensibly 4897 outfile.variables[q+Write_sww.RANGE][0] = max_float # Min 4903 outfile.variables[q+Write_sww.RANGE][0] = max_float # Min 4898 4904 outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max 4899 4905 4900 4906 # FIXME: Backwards compatibility 4901 outfile.createVariable('z', precision, ('number_of_points',))4907 outfile.createVariable('z', sww_precision, ('number_of_points',)) 4902 4908 ################################# 4903 4909 4904 4910 outfile.createVariable('volumes', Int, ('number_of_volumes', 4905 4911 'number_of_vertices')) 4906 4907 outfile.createVariable('time', precision,4912 # Doing sww_precision instead of Float gives cast errors. 4913 outfile.createVariable('time', Float, 4908 4914 ('number_of_timesteps',)) 4909 4915 4910 4916 for q in Write_sww.sww_quantities: 4911 outfile.createVariable(q, precision,4917 outfile.createVariable(q, sww_precision, 4912 4918 ('number_of_timesteps', 4913 4919 'number_of_points')) 4914 outfile.createVariable(q+Write_sww.RANGE, precision,4920 outfile.createVariable(q+Write_sww.RANGE, sww_precision, 4915 4921 ('numbers_in_range',)) 4916 4922 4917 4923 # Initialise ranges with small and large sentinels. 4918 4924 # If this was in pure Python we could have used None sensibly 4919 outfile.variables[q+Write_sww.RANGE][0] = max_float # Min 4925 outfile.variables[q+Write_sww.RANGE][0] = max_float # Min 4920 4926 outfile.variables[q+Write_sww.RANGE][1] = -max_float # Max 4921 4927 … … 5016 5022 5017 5023 #z = resize(bath_grid,outfile.variables['z'][:].shape) 5024 #print "points[:,0]", points[:,0] 5018 5025 outfile.variables['x'][:] = points[:,0] #- geo_ref.get_xllcorner() 5019 5026 outfile.variables['y'][:] = points[:,1] #- geo_ref.get_yllcorner() … … 5028 5035 5029 5036 5030 def store_quantities(self, outfile, precision=Float,5037 def store_quantities(self, outfile, sww_precision=Float32, 5031 5038 slice_index=None, time=None, 5032 5039 verbose=False, **quant): … … 5064 5071 else: 5065 5072 q_values = quant[q] 5066 outfile.variables[q][slice_index] = q_values.astype(precision) 5073 outfile.variables[q][slice_index] = \ 5074 q_values.astype(sww_precision) 5067 5075 5068 5076 # This updates the _range values … … 5713 5721 runup_index = argmax(wet_elevation) 5714 5722 runup = max(wet_elevation) 5715 assert wet_elevation[runup_index] == runup # Must always be True 5723 assert wet_elevation[runup_index] == runup # Must be True 5724 #print "runup", runup 5725 #print "maximal_runup", maximal_runup 5726 5716 5727 if runup > maximal_runup: 5717 5728 maximal_runup = runup # This works even if maximal_runups is None -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r4805 r4862 6770 6770 sww.store_header(outfile, times, number_of_volumes, 6771 6771 number_of_points, description='fully sick testing', 6772 verbose=self.verbose )6772 verbose=self.verbose,sww_precision=Float) 6773 6773 sww.store_triangulation(outfile, points_utm, volumes, 6774 6774 elevation, new_origin=new_origin, … … 6802 6802 sww.store_header(outfile, times, number_of_volumes, 6803 6803 number_of_points, description='fully sick testing', 6804 verbose=self.verbose )6804 verbose=self.verbose,sww_precision=Float) 6805 6805 sww.store_triangulation(outfile, points_utm, volumes, 6806 6806 elevation, new_origin=new_origin, 6807 verbose=self.verbose) 6807 verbose=self.verbose) 6808 6808 outfile.close() 6809 6809 fid = NetCDFFile(filename) … … 6838 6838 sww.store_header(outfile, times, number_of_volumes, 6839 6839 number_of_points, description='fully sick testing', 6840 verbose=self.verbose )6840 verbose=self.verbose,sww_precision=Float) 6841 6841 sww.store_triangulation(outfile, points_utm, volumes, 6842 6842 elevation, new_origin=new_origin, 6843 verbose=self.verbose) 6843 verbose=self.verbose) 6844 6844 outfile.close() 6845 6845 fid = NetCDFFile(filename) … … 6877 6877 sww.store_header(outfile, times, number_of_volumes, 6878 6878 number_of_points, description='fully sick testing', 6879 verbose=self.verbose )6879 verbose=self.verbose,sww_precision=Float) 6880 6880 sww.store_triangulation(outfile, points_utm, volumes, 6881 6881 elevation, new_origin=new_origin, … … 6913 6913 sww.store_header(outfile, times, number_of_volumes, 6914 6914 number_of_points, description='fully sick testing', 6915 verbose=self.verbose )6915 verbose=self.verbose,sww_precision=Float) 6916 6916 sww.store_triangulation(outfile, points_utm, volumes, 6917 6917 elevation, new_origin=new_origin, … … 7327 7327 #------------------------------------------------------------- 7328 7328 if __name__ == "__main__": 7329 #suite = unittest.makeSuite(Test_Data_Manager,'test_get_maximum_inundation')7330 7329 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_header') 7331 #suite = unittest.makeSuite(Test_Data_Manager,'test_export_grid_parallel')7332 7330 suite = unittest.makeSuite(Test_Data_Manager,'test') 7333 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_extrema') 7331 #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII') 7332 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww_range') 7334 7333 7335 7334 -
anuga_work/development/cairns_demo/runcairns.py
r4861 r4862 139 139 domain.set_quantity('elevation', 140 140 filename=dem_name + '.pts', 141 use_cache= True,141 use_cache=False, 142 142 verbose=True, 143 143 alpha=0.1)
Note: See TracChangeset
for help on using the changeset viewer.