Changeset 4651
- Timestamp:
- Aug 1, 2007, 4:13:13 PM (17 years ago)
- Location:
- anuga_core/source/anuga/fit_interpolate
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
r4650 r4651 28 28 from anuga.pmesh.mesh import Mesh 29 29 from anuga.geospatial_data.geospatial_data import Geospatial_data 30 #from anuga.shallow_water import Domain 30 from anuga.shallow_water import Domain 31 from anuga.fit_interpolate.fit import Fit, fit_to_mesh 32 from anuga.fit_interpolate.interpolate import benchmark_interpolate 31 33 32 34 def mem_usage(): … … 96 98 "PPC" + str(max_points_per_cell) + \ 97 99 ".txt" 98 100 101 102 domain = Domain(mesh_dict['vertices'], mesh_dict['triangles'], 103 use_cache=False, verbose=False) 99 104 #Initial time and memory 100 105 t0 = time.time() … … 102 107 m0 = mem_usage() 103 108 104 #domain = Domain(mesh_dict['vertices'], mesh_dict['triangles'],105 # use_cache=False, verbose=False)106 109 if is_fit is True: 107 from anuga.fit_interpolate.fit import Fit, fit_to_mesh108 110 109 111 print "Fit in Fit" 112 geospatial = Geospatial_data(points_dict['points'], 113 points_dict['point_attributes']) 110 114 if use_file_type == None: 111 points = points_dict['points']112 point_attributes = points_dict['point_attributes']115 points = geospatial 116 filename = None 113 117 else: 114 118 #check that the type 115 119 fileName = tempfile.mktemp("." + use_file_type) 116 G1 = Geospatial_data(points_dict['points'], 117 points_dict['point_attributes']) 118 G1.export_points_file(fileName, absolute=True) 119 points = fileName 120 point_attributes = None 121 120 geospatial.export_points_file(fileName, absolute=True) 121 points = None 122 filename = fileName 122 123 if run_profile is True: 123 124 124 s = """ fit_to_mesh(mesh_dict['vertices'], mesh_dict['triangles'],points,point_attributes)"""125 s = """domain.set_quantity('elevation',points,filename=filename,use_cache=False)""" 125 126 pobject = profile.Profile() 126 127 presult = pobject.runctx(s, … … 140 141 os.remove(prof_file) 141 142 else: 142 fit_to_mesh(mesh_dict['vertices'], 143 mesh_dict['triangles'], 144 points, # this can also be a points file name 145 point_attributes) 143 domain.set_quantity('elevation',points,filename=filename, 144 use_cache=False) 146 145 if not use_file_type == None: 147 146 os.remove(fileName) … … 151 150 print "Interpolate!" 152 151 153 interp = Interpolate(mesh_dict['vertices'],154 mesh_dict['triangles'],155 max_vertices_per_cell = max_points_per_cell)156 157 152 if run_profile: 158 s="""calc=interp.interpolate(mesh_dict['vertex_attributes'] 159 ,points_dict['points'],start_blocking_len=blocking_len)""" 153 s="""benchmark_interpolate(mesh_dict['vertices'],mesh_dict['vertex_attributes'],mesh_dict['triangles'],points_dict['points'],max_points_per_cell=max_points_per_cell)""" 160 154 pobject = profile.Profile() 161 155 presult = pobject.runctx(s, … … 176 170 177 171 else: 178 calc = interp.interpolate(mesh_dict['vertex_attributes'] 179 ,points_dict['points'] 180 ,start_blocking_len = 500000) 181 172 benchmark_interpolate(mesh_dict['vertices'], 173 mesh_dict['vertex_attributes'], 174 mesh_dict['triangles'], 175 points_dict['points'], 176 max_points_per_cell=max_points_per_cell) 182 177 time_taken_sec = (time.time()-t0) 183 178 m1 = mem_usage() -
anuga_core/source/anuga/fit_interpolate/interpolate.py
r4648 r4651 291 291 return A 292 292 293 def benchmark_interpolate(vertices, 294 vertex_attributes, 295 triangles, points, 296 max_points_per_cell=None, 297 start_blocking_len=500000): 298 """ 299 No test for this yet. 300 Note, this has no time the input data has no time dimension. Which is 301 different from most of the data we interpolate, eg sww info. 302 303 Output: 304 Interpolated values at inputted points. 305 """ 306 interp = Interpolate(vertices, 307 triangles, 308 max_vertices_per_cell=max_points_per_cell) 309 310 calc = interp.interpolate(vertex_attributes 311 ,points 312 ,start_blocking_len=start_blocking_len) 293 313 def interpolate_sww2csv(sww_file, 294 314 points, -
anuga_core/source/anuga/fit_interpolate/search_functions.py
r4649 r4651 126 126 127 127 # this is where we can call some fast c code. 128 129 # Integrity check - machine precision is too hard 130 # so we use hardwired single precision 131 epsilon = 1.0e-6 132 128 133 xmax = max(xi0[0], xi1[0], xi2[0]) 129 134 xmin = min(xi0[0], xi1[0], xi2[0]) … … 131 136 ymin = min(xi0[1], xi1[1], xi2[1]) 132 137 133 # Integrity check - machine precision is too hard134 # so we use hardwired single precision135 epsilon = 1.0e-6136 138 137 139 if x[0] > xmax + epsilon: … … 143 145 if x[1] < ymin - epsilon: 144 146 return False,0,0,0,0 145 146 147 147 148 # Get the three normals -
anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py
r4650 r4651 14 14 ofile = 'lbm_resultsII.csv' 15 15 delimiter = ',' 16 run_profile = True 17 use_least_squares_list = [False] 16 run_profile = True #False #True 18 17 is_fit_list = [True, False] 19 18 num_of_points_list = [3, 200, 600, 2000, 6000, 10000, 20000] 20 19 maxArea_list = [ 0.008, 0.0016, 0.0008] 21 20 max_points_per_cell_list = [2,4,8,16,30,64] 22 use_file_type_list = ['pts'] 23 num_of_points_list = [10]21 use_file_type_list = ['pts'] #'pts' 22 #num_of_points_list = [10] 24 23 maxArea_list = [ 0.008] 25 24 max_points_per_cell_list = [30]
Note: See TracChangeset
for help on using the changeset viewer.