Changeset 4650
- Timestamp:
- Aug 1, 2007, 12:14:07 PM (17 years ago)
- Location:
- anuga_core/source/anuga/fit_interpolate
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
r4649 r4650 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 31 31 32 def mem_usage(): … … 68 69 max_points_per_cell=4, 69 70 is_fit=True, 70 use_least_squares=False,71 71 use_file_type=None, 72 72 blocking_len=500000, … … 86 86 save=save) 87 87 points_dict = self._build_points_dict(num_of_points=num_of_points) 88 89 #Initial time and memory 90 t0 = time.time() 91 #m0 = None on windows 92 m0 = mem_usage() 88 89 93 90 if is_fit is True: 94 91 op = "Fit_" … … 100 97 ".txt" 101 98 102 if use_least_squares is True: 103 from anuga.where.least_squares import Interpolation 104 interp = Interpolation(mesh_dict['vertices'], 105 mesh_dict['triangles'], 106 points_dict['points'], 107 expand_search=True, 108 verbose = False, 109 max_points_per_cell = max_points_per_cell) 110 if is_fit is True: 111 print "Fit in least squares" 112 calc = interp.fit_points(points_dict['point_attributes']) 99 #Initial time and memory 100 t0 = time.time() 101 #m0 = None on windows 102 m0 = mem_usage() 103 104 #domain = Domain(mesh_dict['vertices'], mesh_dict['triangles'], 105 # use_cache=False, verbose=False) 106 if is_fit is True: 107 from anuga.fit_interpolate.fit import Fit, fit_to_mesh 108 109 print "Fit in Fit" 110 if use_file_type == None: 111 points = points_dict['points'] 112 point_attributes = points_dict['point_attributes'] 113 else: 114 #check that the type 115 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 113 121 122 if run_profile is True: 123 124 s = """fit_to_mesh(mesh_dict['vertices'], mesh_dict['triangles'],points,point_attributes)""" 125 pobject = profile.Profile() 126 presult = pobject.runctx(s, 127 vars(sys.modules[__name__]), 128 vars()) 129 prof_file = tempfile.mktemp(".prof") 130 presult.dump_stats(prof_file) 131 # 132 # Let process these results 133 S = pstats.Stats(prof_file) 134 saveout = sys.stdout 135 pfile = open(profile_file, "w") 136 sys.stdout = pfile 137 s = S.sort_stats('cumulative').print_stats(30) 138 sys.stdout = saveout 139 pfile.close() 140 os.remove(prof_file) 114 141 else: 115 # run an interploate problem. 116 print "Interpolate!" 117 calc = interp.interpolate(mesh_dict['vertex_attributes']) 118 else: 119 if is_fit is True: 120 from anuga.fit_interpolate.fit import Fit 121 interp = Fit(mesh_dict['vertices'], 142 fit_to_mesh(mesh_dict['vertices'], 143 mesh_dict['triangles'], 144 points, # this can also be a points file name 145 point_attributes) 146 if not use_file_type == None: 147 os.remove(fileName) 148 149 else: 150 # run an interploate problem. 151 print "Interpolate!" 152 153 interp = Interpolate(mesh_dict['vertices'], 122 154 mesh_dict['triangles'], 123 155 max_vertices_per_cell = max_points_per_cell) 124 print "Fit in Fit" 125 if use_file_type == None: 126 calc = interp.fit(points_dict['points'], 127 points_dict['point_attributes']) 128 else: 129 #check that the type 130 fileName = tempfile.mktemp("." + use_file_type) 131 G1 = Geospatial_data(points_dict['points'], 132 points_dict['point_attributes']) 133 G1.export_points_file(fileName, absolute=True) 134 135 if run_profile: 136 137 s = """interp.fit(fileName, verbose=verbose)""" 138 pobject = profile.Profile() 139 presult = pobject.runctx(s, 140 vars(sys.modules[__name__]), 141 vars()) 142 prof_file = tempfile.mktemp(".prof") 143 presult.dump_stats(prof_file) 144 # 145 # Let process these results 146 S = pstats.Stats(prof_file) 147 saveout = sys.stdout 148 pfile = open(profile_file, "w") 149 sys.stdout = pfile 150 s = S.sort_stats('cumulative').print_stats(30) 151 sys.stdout = saveout 152 pfile.close() 153 os.remove(prof_file) 154 else: 155 interp.fit(fileName, verbose=verbose) 156 os.remove(fileName) 156 157 if run_profile: 158 s="""calc=interp.interpolate(mesh_dict['vertex_attributes'] 159 ,points_dict['points'],start_blocking_len=blocking_len)""" 160 pobject = profile.Profile() 161 presult = pobject.runctx(s, 162 vars(sys.modules[__name__]), 163 vars()) 164 prof_file = tempfile.mktemp(".prof") 165 presult.dump_stats(prof_file) 166 # 167 # Let process these results 168 S = pstats.Stats(prof_file) 169 saveout = sys.stdout 170 pfile = open(profile_file, "w") 171 sys.stdout = pfile 172 s = S.sort_stats('cumulative').print_stats(30) 173 sys.stdout = saveout 174 pfile.close() 175 os.remove(prof_file) 157 176 158 177 else: 159 # run an interploate problem. 160 print "Interpolate!" 161 162 interp = Interpolate(mesh_dict['vertices'], 163 mesh_dict['triangles'], 164 max_vertices_per_cell = max_points_per_cell) 165 166 if run_profile: 167 s="""calc=interp.interpolate(mesh_dict['vertex_attributes'] 168 ,points_dict['points'],start_blocking_len=blocking_len)""" 169 pobject = profile.Profile() 170 presult = pobject.runctx(s, 171 vars(sys.modules[__name__]), 172 vars()) 173 prof_file = tempfile.mktemp(".prof") 174 presult.dump_stats(prof_file) 175 # 176 # Let process these results 177 S = pstats.Stats(prof_file) 178 saveout = sys.stdout 179 pfile = open(profile_file, "w") 180 sys.stdout = pfile 181 s = S.sort_stats('cumulative').print_stats(30) 182 sys.stdout = saveout 183 pfile.close() 184 os.remove(prof_file) 185 186 else: 187 calc = interp.interpolate(mesh_dict['vertex_attributes'] 178 calc = interp.interpolate(mesh_dict['vertex_attributes'] 188 179 ,points_dict['points'] 189 180 ,start_blocking_len = 500000) 190 181 191 182 time_taken_sec = (time.time()-t0) 192 183 m1 = mem_usage() -
anuga_core/source/anuga/fit_interpolate/fit.py
r4648 r4650 465 465 if isinstance(point_coordinates, basestring): 466 466 # We assume that point_coordinates is the name of a .csv/.txt 467 # file which must be passed onto caching as a dependency (in case it468 # has changed on disk)467 # file which must be passed onto caching as a dependency 468 # (in case it has changed on disk) 469 469 dep = [point_coordinates] 470 470 else: -
anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py
r4649 r4650 21 21 max_points_per_cell_list = [2,4,8,16,30,64] 22 22 use_file_type_list = ['pts'] 23 #num_of_points_list = [3, 200]23 num_of_points_list = [10] 24 24 maxArea_list = [ 0.008] 25 25 max_points_per_cell_list = [30]
Note: See TracChangeset
for help on using the changeset viewer.