Changeset 7308
- Timestamp:
- Jul 12, 2009, 10:53:38 PM (15 years ago)
- Location:
- anuga_core/source/anuga
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/shallow_water/data_manager.py
r7276 r7308 3083 3083 else: 3084 3084 jmin = num.searchsorted(times, mint) 3085 3086 # numpy.int32 didn't work in slicing of amplitude below 3087 jmin = int(jmin) 3085 3088 3086 3089 if maxt is None: … … 3089 3092 else: 3090 3093 jmax = num.searchsorted(times, maxt) 3094 3095 # numpy.int32 didn't work in slicing of amplitude below 3096 jmax = int(jmax) 3091 3097 3092 3098 kmin, kmax, lmin, lmax = _get_min_max_indexes(latitudes[:], … … 3123 3129 # 'print hmmm' 3124 3130 3125 # Get missing values3131 # Get missing values 3126 3132 nan_ha = file_h.variables['HA'].missing_value[0] 3127 3133 nan_ua = file_u.variables['UA'].missing_value[0] … … 3132 3138 nan_e = None 3133 3139 3134 # Cleanup3140 # Cleanup 3135 3141 missing = (amplitudes == nan_ha) 3136 3142 if num.sometrue (missing): … … 3828 3834 if verbose: print 'Reading DEM from %s' % inname 3829 3835 3830 # Read metadata3831 ncols = in file.ncols[0]3832 nrows = in file.nrows[0]3836 # Read metadata (convert from numpy.int32 to int where appropriate) 3837 ncols = int(infile.ncols[0]) 3838 nrows = int(infile.nrows[0]) 3833 3839 xllcorner = infile.xllcorner[0] 3834 3840 yllcorner = infile.yllcorner[0] 3835 cellsize = in file.cellsize[0]3836 NODATA_value = in file.NODATA_value[0]3837 zone = in file.zone[0]3841 cellsize = int(infile.cellsize[0]) 3842 NODATA_value = int(infile.NODATA_value[0]) 3843 zone = int(infile.zone[0]) 3838 3844 false_easting = infile.false_easting[0] 3839 3845 false_northing = infile.false_northing[0] … … 3860 3866 nrows_new = 1 + (nrows - nrows_stencil) / cellsize_ratio 3861 3867 3868 #print type(ncols_new), ncols_new 3869 3862 3870 #Open netcdf file for output 3863 3871 outfile = NetCDFFile(outname, netcdf_mode_w) … … 3885 3893 3886 3894 # dimension definition 3895 #print nrows_new, ncols_new, nrows_new*ncols_new 3896 #print type(nrows_new), type(ncols_new), type(nrows_new*ncols_new) 3887 3897 outfile.createDimension('number_of_points', nrows_new*ncols_new) 3888 3898 … … 6102 6112 Maybe make this general, but the viewer assumes these quantities, 6103 6113 so maybe we don't want it general - unless the viewer is general 6104 6105 precon 6106 triangulation and 6107 header have been called. 6114 6115 The argument sww_precision allows for storing as either 6116 * single precision (default): num.float32 6117 * double precision: num.float64 or num.float 6118 6119 Precondition: 6120 triangulation and 6121 header have been called. 6108 6122 """ 6109 6123 … … 6112 6126 slice_index = len(file_time) 6113 6127 file_time[slice_index] = time 6128 else: 6129 slice_index = int(slice_index) # In case it was numpy.int 6114 6130 6115 6131 # Write the conserved quantities from Domain. … … 6124 6140 else: 6125 6141 q_values = quant[q] 6126 outfile.variables[q][slice_index] = \ 6127 q_values.astype(sww_precision) 6142 6143 x = q_values.astype(sww_precision) 6144 outfile.variables[q][slice_index] = x 6145 6128 6146 6129 6147 # This updates the _range values -
anuga_core/source/anuga/shallow_water/test_data_manager.py
r7276 r7308 5960 5960 tide = 1 5961 5961 base_name, files = self.create_mux() 5962 5962 5963 urs2sww(base_name, 5963 5964 mint=0.25, … … 5965 5966 mean_stage=tide, 5966 5967 remove_nc_files=True, 5967 verbose=self.verbose 5968 ) 5968 verbose=self.verbose) 5969 5969 sww_file = base_name + '.sww' 5970 5970 … … 11678 11678 11679 11679 if __name__ == "__main__": 11680 suite = unittest.makeSuite(Test_Data_Manager, 'test')11680 suite = unittest.makeSuite(Test_Data_Manager, 'test') 11681 11681 11682 11683 # FIXME(Ole): When Ross has implemented logging, we can 11684 # probably get rid of all this: 11682 11685 if len(sys.argv) > 1 and sys.argv[1][0].upper() == 'V': 11683 11686 Test_Data_Manager.verbose=True -
anuga_core/source/anuga/utilities/test_polygon.py
r7276 r7308 304 304 points = [[0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]] 305 305 res = inside_polygon( points, polygon, verbose=False ) 306 assert num.allclose( res, [0,1,2])306 assert num.allclose(res, [0,1,2]) 307 307 308 308 def test_outside_polygon(self): … … 585 585 points = [(1., 0.25),(1., 0.75)] 586 586 inside, outside = in_and_outside_polygon(points, polygon, closed=True) 587 assert (inside,[0,1])587 assert num.alltrue(inside == [0,1]) 588 588 assert len(outside) == 0 589 589 590 590 inside, outside = in_and_outside_polygon(points, polygon, closed=False) 591 591 assert len(inside) == 0 592 assert (outside,[0,1])592 assert num.alltrue(outside == [0,1]) 593 593 594 594 points = [(100., 0.25), (0.5, 0.5) ] 595 595 inside, outside = in_and_outside_polygon(points, polygon) 596 assert (inside,[1])596 assert num.alltrue(inside == [1]) 597 597 assert outside[0] == 0 598 598 599 599 points = [(100., 0.25),(0.5, 0.5), (39,20), (0.6,0.7),(56,43),(67,90)] 600 600 inside, outside = in_and_outside_polygon(points, polygon) 601 assert (inside,[1, 3])602 assert (outside,[0, 2, 4, 5])601 assert num.alltrue(inside == [1, 3]) 602 assert num.alltrue(outside == [0, 2, 4, 5]) 603 603 604 604 def test_intersection1(self): -
anuga_core/source/anuga/utilities/treenode.py
r3566 r7308 24 24 self.parent = None 25 25 26 # subclasses can implement these attributes as functions, called26 # Subclasses can implement these attributes as functions, called 27 27 # when a node (either leaf or internal) is deleted 28 if not hasattr(self,'ClearLeafNode'): 29 self.ClearLeafNode = None 30 if not hasattr(self,'ClearInternalNode'): 31 self.ClearInternalNode = None 28 29 # FIXME (Ole): The hasattr statements below were commented out on 12 July 2009 by Ole Nielsen due to 30 # errors appearing when using Python2.6. Tests pass, so I think this was just superfluous anyway. 31 # 32 # Excerpt from What's New in Python 2.6 33 # 34 #The hasattr() function was catching and ignoring all errors, 35 #under the assumption that they meant a __getattr__() method 36 #was failing somehow and the return value of hasattr() would 37 #therefore be False. This logic shouldn't be applied to 38 #KeyboardInterrupt and SystemExit, however; Python 2.6 will no 39 #longer discard such exceptions when hasattr() encounters 40 #them. (Fixed by Benjamin Peterson; issue 2196.) 41 42 #if not hasattr(self,'ClearLeafNode'): 43 # self.ClearLeafNode = None 44 #if not hasattr(self,'ClearInternalNode'): 45 # self.ClearInternalNode = None 46 47 # # When not already set by derived class, set unique instance name 48 #if not hasattr(self,'name'): 49 # if name: 50 # self.name = name 51 # else: 52 # self.name = id(self) 32 53 33 # when not already set by derived class, set unique instance name34 if n ot hasattr(self,"name"):35 if name:36 self.name = name37 else:38 self.name = id(self)54 # When not already set by derived class, set unique instance name 55 if name: 56 self.name = name 57 else: 58 self.name = id(self) 59 39 60 40 61 41 #Make treenode elements appear as sequences such thta on 42 #can iterate over them 62 63 # Make treenode elements appear as sequences such that one 64 # can iterate over them 43 65 def __iter__(self): 44 66 self.index = -1 # incremented on first call to next()
Note: See TracChangeset
for help on using the changeset viewer.