Changeset 4648
- Timestamp:
- Jul 31, 2007, 2:46:30 PM (18 years ago)
- Location:
- anuga_core/source/anuga/fit_interpolate
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
r4596 r4648 20 20 import time 21 21 from random import seed, random 22 import tempfile 23 import profile , pstats 22 24 import tempfile 23 25 … … 71 73 segments_in_mesh=True, 72 74 save=False, 73 verbose=False): 75 verbose=False, 76 run_profile=False): 74 77 ''' 75 78 num_of_points 76 79 ''' 77 78 80 #print "num_of_points",num_of_points 79 81 #print "maxArea",maxArea … … 89 91 #m0 = None on windows 90 92 m0 = mem_usage() 91 93 94 profile_file = "P" + str(num_of_points) + \ 95 "T" + str(len(mesh_dict['triangles'])) + \ 96 "PPC" + str(max_points_per_cell) + \ 97 ".txt" 98 92 99 if use_least_squares is True: 93 100 from anuga.where.least_squares import Interpolation … … 108 115 else: 109 116 if is_fit is True: 117 from anuga.fit_interpolate.fit import Fit 110 118 interp = Fit(mesh_dict['vertices'], 111 119 mesh_dict['triangles'], … … 121 129 points_dict['point_attributes']) 122 130 G1.export_points_file(fileName, absolute=True) 123 calc = interp.fit(fileName, verbose=verbose) 131 132 if run_profile: 133 134 s = """interp.fit(fileName, verbose=verbose)""" 135 pobject = profile.Profile() 136 presult = pobject.runctx(s, 137 vars(sys.modules[__name__]), 138 vars()) 139 prof_file = tempfile.mktemp(".prof") 140 presult.dump_stats(prof_file) 141 # 142 # Let process these results 143 S = pstats.Stats(prof_file) 144 saveout = sys.stdout 145 pfile = open(profile_file, "w") 146 sys.stdout = pfile 147 s = S.sort_stats('cumulative').print_stats(30) 148 sys.stdout = saveout 149 pfile.close() 150 os.remove(prof_file) 151 else: 152 interp.fit(fileName, verbose=verbose) 124 153 os.remove(fileName) 125 154 … … 131 160 mesh_dict['triangles'], 132 161 max_vertices_per_cell = max_points_per_cell) 133 calc = interp.interpolate(mesh_dict['vertex_attributes']162 s = """calc = interp.interpolate(mesh_dict['vertex_attributes'] 134 163 ,points_dict['points'] 135 ,start_blocking_len=blocking_len) 136 164 ,start_blocking_len=blocking_len)""" 165 166 fileName = tempfile.mktemp(".prof") 167 profile.run(s, fileName) #profile_file) 168 169 S = pstats.Stats(fileName) 170 s = S.sort_stats('cumulative').print_stats(30) 171 print "***********" 172 print s 173 print "***********" 174 pfile = file.open(profile_file, "w") 175 pfile.write(s) 176 pfile.close() 137 177 time_taken_sec = (time.time()-t0) 138 178 m1 = mem_usage() -
anuga_core/source/anuga/fit_interpolate/fit.py
r4633 r4648 436 436 def fit_to_mesh(vertex_coordinates, 437 437 triangles, 438 point_coordinates, # this can also be a .csv/.txtfile name438 point_coordinates, # this can also be a points file name 439 439 point_attributes=None, 440 440 alpha=DEFAULT_ALPHA, -
anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py
r4614 r4648 91 91 92 92 if verbose: print 'FitInterpolate: Building quad tree' 93 # This stores indices of vertices 93 94 self.root = build_quadtree(self.mesh, 94 95 max_points_per_cell = max_vertices_per_cell) -
anuga_core/source/anuga/fit_interpolate/interpolate.py
r4614 r4648 241 241 #Convert point_coordinates to Numeric arrays, in case it was a list. 242 242 point_coordinates = ensure_numeric(point_coordinates, Float) 243 # for ticket 160 244 #boundary = self.mesh.get_boundary_polygon() 245 #geo = Geospatial_data(boundary) 246 #geo.export_points_file('serial-boundary.xya') 247 #geo.export_points_file('serial-boundary.txt') 243 248 244 if verbose: print 'Getting indices inside mesh boundary' 249 245 self.inside_poly_indices, self.outside_poly_indices = \ … … 251 247 self.mesh.get_boundary_polygon(), 252 248 closed = True, verbose = verbose) 253 #print "self.inside_poly_indices",self.inside_poly_indices 254 #print "self.outside_poly_indices",self.outside_poly_indices 249 255 250 #Build n x m interpolation matrix 256 251 if verbose and len(self.outside_poly_indices) > 0: -
anuga_core/source/anuga/fit_interpolate/test_search_functions.py
r4593 r4648 161 161 assert found is True 162 162 else: 163 assert found is False 164 165 166 167 168 169 170 171 172 163 assert found is False 173 164 #------------------------------------------------------------- 174 165 if __name__ == "__main__": -
anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py
r4596 r4648 17 17 use_least_squares_list = [False] 18 18 is_fit_list = [True] 19 num_of_points_list = [200, 600, 2000, 6000, 10000, 20000] #[5000] #, 500] #, 10000, 100000] #, 10000000]19 num_of_points_list = [200, 600, 2000, 6000, 10000, 20000] 20 20 maxArea_list = [ 0.008, 0.0016, 0.0008] 21 max_points_per_cell_list = [2,4,8,16,30,64] #,4,8,16,32,64,128,255]21 max_points_per_cell_list = [2,4,8,16,30,64] 22 22 use_file_type_list = ['pts'] 23 24 25 num_of_points_list = [200] 26 maxArea_list = [ 0.008] 27 max_points_per_cell_list = [30] 23 28 24 29 fd = open(ofile,'a') … … 48 53 ,use_file_type=use_file_type 49 54 ,save=True 55 ,run_profile=True 50 56 ) 51 57 print "time",time
Note: See TracChangeset
for help on using the changeset viewer.