Changeset 5010
- Timestamp:
- Feb 8, 2008, 5:11:28 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r5004 r5010 261 261 raise Exception, msg 262 262 263 def clip(self, polygon, closed=True ):263 def clip(self, polygon, closed=True, verbose=False): 264 264 """Clip geospatial data by a polygon 265 265 … … 282 282 # Polygon is an object - extract points 283 283 polygon = polygon.get_data_points() 284 #print 'polygon',polygon 284 285 285 286 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) 287 289 288 290 clipped_G = self.get_sample(inside_indices) … … 301 303 302 304 303 def clip_outside(self, polygon, closed=True ):305 def clip_outside(self, polygon, closed=True,verbose=False): 304 306 """Clip geospatial date by a polygon, keeping data OUTSIDE of polygon 305 307 … … 323 325 324 326 points = self.get_data_points() 325 outside_indices = outside_polygon(points, polygon, closed )327 outside_indices = outside_polygon(points, polygon, closed,verbose) 326 328 327 329 clipped_G = self.get_sample(outside_indices) … … 630 632 631 633 def split(self, factor=0.5,seed_num=None, verbose=False): 632 """Returns two 633 634 """Returns two 634 635 geospatial_data object, first is the size of the 'factor' 635 636 smaller the original and the second is the remainder. The two … … 637 638 638 639 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)640 640 641 641 This method create two lists of indices which are passed into … … 679 679 if verbose: print "seed:", get_seed() 680 680 681 #print 'size',self_size, new_size 681 682 random_num = randint(0,self_size-1,(int(new_size),)) 683 #print 'random num',random_num 682 684 random_num = random_num.tolist() 683 685 … … 1447 1449 1448 1450 if mesh_file is None: 1451 if verbose: print "building mesh" 1449 1452 mesh_file='temp.msh' 1450 1453 … … 1475 1478 else: # if mesh file provided 1476 1479 #test mesh file exists? 1480 if verbose: "reading from file: %s" %mesh_file 1477 1481 if access(mesh_file,F_OK) == 0: 1478 1482 msg="file %s doesn't exist!" %mesh_file … … 1480 1484 1481 1485 #split topo data 1486 if verbose: print 'Reading elevation file: %s' %data_file 1482 1487 G = Geospatial_data(file_name = data_file) 1483 if verbose: print ' start split'1488 if verbose: print 'Start split' 1484 1489 G_small, G_other = G.split(split_factor,seed_num, verbose=verbose) 1485 if verbose: print ' finish split'1490 if verbose: print 'Finish split' 1486 1491 points=G_small.get_data_points() 1487 1492 … … 1552 1557 #returns the predicted elevation of the points that were "split" out 1553 1558 #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' 1555 1560 elevation_predicted=domain.quantities[attribute_smoothed].\ 1556 1561 get_values(interpolation_points=points_geo) … … 1565 1570 #print 'memory usage during compare',mem_usage() 1566 1571 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' 1569 1574 # if verbose: print 'Determine difference between predicted results and actual data' 1570 1575 # for i,alpha in enumerate(domains): … … 1602 1607 if verbose: 1603 1608 print 'Final results:' 1604 for i in len(alphas):1609 for i,alpha in enumerate(alphas): 1605 1610 print'covariance for alpha %s = %s ' %(normal_cov[i][0],normal_cov[i][1]) 1606 1611 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.