Changeset 5010


Ignore:
Timestamp:
Feb 8, 2008, 5:11:28 PM (17 years ago)
Author:
nick
Message:

update 'clip' and clip_outside' with verbose and added some comment statments if verbose

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r5004 r5010  
    261261            raise Exception, msg
    262262
    263     def clip(self, polygon, closed=True):
     263    def clip(self, polygon, closed=True, verbose=False):
    264264        """Clip geospatial data by a polygon
    265265
     
    282282            # Polygon is an object - extract points
    283283            polygon = polygon.get_data_points()
     284            #print 'polygon',polygon
    284285
    285286        points = self.get_data_points()   
    286         inside_indices = inside_polygon(points, polygon, closed)
     287        #print '%s points:%s' %(verbose,points)
     288        inside_indices = inside_polygon(points, polygon, closed, verbose)
    287289
    288290        clipped_G = self.get_sample(inside_indices)
     
    301303       
    302304       
    303     def clip_outside(self, polygon, closed=True):
     305    def clip_outside(self, polygon, closed=True,verbose=False):
    304306        """Clip geospatial date by a polygon, keeping data OUTSIDE of polygon
    305307
     
    323325
    324326        points = self.get_data_points()   
    325         outside_indices = outside_polygon(points, polygon, closed)
     327        outside_indices = outside_polygon(points, polygon, closed,verbose)
    326328
    327329        clipped_G = self.get_sample(outside_indices)
     
    630632   
    631633    def split(self, factor=0.5,seed_num=None, verbose=False):
    632         """Returns two
    633        
     634        """Returns two       
    634635        geospatial_data object, first is the size of the 'factor'
    635636        smaller the original and the second is the remainder. The two
     
    637638       
    638639        Points of the two new object have selected RANDOMLY.
    639         AND if factor is a decimal it will round (2.25 to 2 and 2.5 to 3)
    640640       
    641641        This method create two lists of indices which are passed into
     
    679679        if verbose: print "seed:", get_seed()
    680680       
     681        #print 'size',self_size, new_size
    681682        random_num = randint(0,self_size-1,(int(new_size),))
     683        #print 'random num',random_num
    682684        random_num = random_num.tolist()
    683685
     
    14471449
    14481450    if mesh_file is None:
     1451        if verbose: print "building mesh"
    14491452        mesh_file='temp.msh'
    14501453
     
    14751478    else: # if mesh file provided
    14761479        #test mesh file exists?
     1480        if verbose: "reading from file: %s" %mesh_file
    14771481        if access(mesh_file,F_OK) == 0:
    14781482            msg="file %s doesn't exist!" %mesh_file
     
    14801484
    14811485    #split topo data
     1486    if verbose: print 'Reading elevation file: %s' %data_file
    14821487    G = Geospatial_data(file_name = data_file)
    1483     if verbose: print 'start split'
     1488    if verbose: print 'Start split'
    14841489    G_small, G_other = G.split(split_factor,seed_num, verbose=verbose)
    1485     if verbose: print 'finish split'
     1490    if verbose: print 'Finish split'
    14861491    points=G_small.get_data_points()
    14871492
     
    15521557        #returns the predicted elevation of the points that were "split" out
    15531558        #of the original data set for one particular alpha
    1554         if verbose: print 'get predicted elevation for location to be compared'
     1559        if verbose: print 'Get predicted elevation for location to be compared'
    15551560        elevation_predicted=domain.quantities[attribute_smoothed].\
    15561561                            get_values(interpolation_points=points_geo)
     
    15651570        #print 'memory usage during compare',mem_usage()
    15661571       
    1567         if verbose: print'covariance for alpha ',normal_cov[i][0],'= ',normal_cov[i][1]
    1568 
     1572        if verbose: print'Covariance for alpha ',normal_cov[i][0],'= ',normal_cov[i][1]
     1573        if verbose: print'-------------------------------------------- \n'
    15691574#    if verbose: print 'Determine difference between predicted results and actual data'
    15701575#    for i,alpha in enumerate(domains):
     
    16021607    if verbose:
    16031608        print 'Final results:'
    1604         for i in len(alphas):
     1609        for i,alpha in enumerate(alphas):
    16051610            print'covariance for alpha %s = %s ' %(normal_cov[i][0],normal_cov[i][1])
    16061611        print '\n Optimal alpha is: %s ' % normal_cov_new[(argmin(normal_cov_new,axis=0))[1],0]
Note: See TracChangeset for help on using the changeset viewer.