Changeset 4648


Ignore:
Timestamp:
Jul 31, 2007, 2:46:30 PM (17 years ago)
Author:
duncan
Message:

comments and updating benchmark

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  
    2020import time
    2121from random import seed, random
     22import tempfile
     23import profile , pstats
    2224import tempfile
    2325
     
    7173              segments_in_mesh=True,
    7274              save=False,
    73               verbose=False):
     75              verbose=False,
     76              run_profile=False):
    7477        '''
    7578        num_of_points
    7679        '''
    77        
    7880        #print "num_of_points",num_of_points
    7981        #print "maxArea",maxArea
     
    8991        #m0 = None on windows
    9092        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                       
    9299        if use_least_squares is True:
    93100            from anuga.where.least_squares import Interpolation
     
    108115        else:
    109116            if is_fit is True:
     117                from anuga.fit_interpolate.fit import Fit
    110118                interp = Fit(mesh_dict['vertices'],
    111119                                 mesh_dict['triangles'],
     
    121129                                         points_dict['point_attributes'])
    122130                    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)
    124153                    os.remove(fileName)
    125154                   
     
    131160                                     mesh_dict['triangles'],
    132161                                 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']
    134163                                          ,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()
    137177        time_taken_sec = (time.time()-t0)
    138178        m1 = mem_usage()
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r4633 r4648  
    436436def fit_to_mesh(vertex_coordinates,
    437437                triangles,
    438                 point_coordinates, # this can also be a .csv/.txt file name
     438                point_coordinates, # this can also be a points file name
    439439                point_attributes=None,
    440440                alpha=DEFAULT_ALPHA,
  • anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py

    r4614 r4648  
    9191       
    9292        if verbose: print 'FitInterpolate: Building quad tree'
     93        # This stores indices of vertices
    9394        self.root = build_quadtree(self.mesh,
    9495                                   max_points_per_cell = max_vertices_per_cell)
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r4614 r4648  
    241241        #Convert point_coordinates to Numeric arrays, in case it was a list.
    242242        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       
    248244        if verbose: print 'Getting indices inside mesh boundary'
    249245        self.inside_poly_indices, self.outside_poly_indices  = \
     
    251247                                            self.mesh.get_boundary_polygon(),
    252248                                            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       
    255250        #Build n x m interpolation matrix
    256251        if verbose and len(self.outside_poly_indices) > 0:
  • anuga_core/source/anuga/fit_interpolate/test_search_functions.py

    r4593 r4648  
    161161                assert found is True
    162162            else:
    163                 assert found is False               
    164            
    165 
    166        
    167                
    168 
    169        
    170        
    171 
    172        
     163                assert found is False   
    173164#-------------------------------------------------------------
    174165if __name__ == "__main__":
  • anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py

    r4596 r4648  
    1717use_least_squares_list = [False]
    1818is_fit_list = [True]
    19 num_of_points_list = [200, 600, 2000, 6000, 10000, 20000]  #[5000] #, 500] #, 10000, 100000] #, 10000000]
     19num_of_points_list = [200, 600, 2000, 6000, 10000, 20000]
    2020maxArea_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]
     21max_points_per_cell_list = [2,4,8,16,30,64]
    2222use_file_type_list = ['pts']
     23
     24
     25num_of_points_list = [200]
     26maxArea_list = [ 0.008]
     27max_points_per_cell_list = [30]
    2328
    2429fd = open(ofile,'a')
     
    4853                                                   ,use_file_type=use_file_type
    4954                                                   ,save=True
     55                                                   ,run_profile=True
    5056                                               )
    5157                    print "time",time
Note: See TracChangeset for help on using the changeset viewer.