Changeset 5146 for anuga_core/source/anuga/geospatial_data
- Timestamp:
- Mar 10, 2008, 3:41:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r5010 r5146 282 282 # Polygon is an object - extract points 283 283 polygon = polygon.get_data_points() 284 #print 'polygon',polygon285 284 286 285 points = self.get_data_points() 287 #print '%s points:%s' %(verbose,points)286 # if verbose: print '%s points:%s' %(verbose,points) 288 287 inside_indices = inside_polygon(points, polygon, closed, verbose) 289 288 290 289 clipped_G = self.get_sample(inside_indices) 290 291 291 # clipped_points = take(points, inside_indices) 292 292 … … 375 375 lats_longs.append((lat_calced, long_calced)) # to hash 376 376 return lats_longs 377 378 377 if absolute is True and geo_reference is None: 379 378 return self.geo_reference.get_absolute(self.data_points) … … 384 383 else: 385 384 return self.data_points 386 385 387 386 388 387 def get_attributes(self, attribute_name=None): … … 617 616 """ 618 617 #FIXME: add the geo_reference to this 619 618 # print 'hello from get_sample' 620 619 points = self.get_data_points() 621 620 sampled_points = take(points, indices) … … 627 626 for key, att in attributes.items(): 628 627 sampled_attributes[key] = take(att, indices) 628 629 # print 'goodbye from get_sample' 629 630 630 631 return Geospatial_data(sampled_points, sampled_attributes) … … 1398 1399 1399 1400 """ 1401 Removes a small random sample of points from 'data_file'. Then creates 1402 models with different alpha values from 'alpha_list' and cross validates 1403 the predicted value to the previously removed point data. Returns the 1404 alpha value which has the smallest covariance. 1405 1400 1406 data_file: must not contain points outside the boundaries defined 1401 1407 and it either a pts, txt or csv file. … … 1431 1437 alpha that created it. PLUS writes a plot of the results 1432 1438 1433 NOTE: code will not work if the data_file exten dis greater than the1434 boundary_polygon or thenorth_boundary...west_boundary1439 NOTE: code will not work if the data_file extent is greater than the 1440 boundary_polygon or any of the boundaries, eg north_boundary...west_boundary 1435 1441 1436 1442 """ … … 1491 1497 points=G_small.get_data_points() 1492 1498 1493 1494 1495 1496 #FIXME: Remove points outside boundary polygon1497 # print 'new point',len(points)1498 #1499 # new_points=[]1500 # new_points=array([],typecode=Float)1501 # new_points=resize(new_points,(len(points),2))1502 # print "BOUNDARY", boundary_poly1503 # for i,point in enumerate(points):1504 # if is_inside_polygon(point,boundary_poly, verbose=True):1505 # new_points[i] = point1506 # print"WOW",i,new_points[i]1507 # points = new_points1508 1509 1510 1499 if verbose: print "Number of points in sample to compare: ", len(points) 1511 1500 … … 1517 1506 else: 1518 1507 alphas=alpha_list 1519 # domains = {}1520 1508 1521 1509 #creates array with columns 1 and 2 are x, y. column 3 is elevation … … 1533 1521 1534 1522 normal_cov=array(zeros([len(alphas),2]),typecode=Float) 1535 1536 1537 1538 1539 1523 1540 1524 if verbose: print 'Setup computational domains with different alphas' … … 1552 1536 verbose = verbose, 1553 1537 alpha = alpha) 1554 # domains[alpha]=domain1555 1538 1556 1539 points_geo=domain.geo_reference.change_points_geo_ref(points) … … 1572 1555 if verbose: print'Covariance for alpha ',normal_cov[i][0],'= ',normal_cov[i][1] 1573 1556 if verbose: print'-------------------------------------------- \n' 1574 # if verbose: print 'Determine difference between predicted results and actual data'1575 # for i,alpha in enumerate(domains):1576 # if verbose: print'Alpha =',alpha1577 #1578 # points_geo=domains[alpha].geo_reference.change_points_geo_ref(points)1579 # #returns the predicted elevation of the points that were "split" out1580 # #of the original data set for one particular alpha1581 # elevation_predicted=domains[alpha].quantities[attribute_smoothed].\1582 # get_values(interpolation_points=points_geo)1583 #1584 # #add predicted elevation to array that starts with x, y, z...1585 # data[:,i+3]=elevation_predicted1586 #1587 # sample_cov= cov(elevation_sample)1588 # #print elevation_predicted1589 # ele_cov= cov(elevation_sample-elevation_predicted)1590 # normal_cov[i,:]= [alpha,ele_cov/sample_cov]1591 # print 'memory usage during compare',mem_usage()1592 #1593 #1594 # if verbose: print'cov',normal_cov[i][0],'= ',normal_cov[i][1]1595 1557 1596 1558 normal_cov0=normal_cov[:,0] … … 1611 1573 print '\n Optimal alpha is: %s ' % normal_cov_new[(argmin(normal_cov_new,axis=0))[1],0] 1612 1574 1575 # covariance and optimal alpha 1613 1576 return min(normal_cov_new[:,1]) , normal_cov_new[(argmin(normal_cov_new,axis=0))[1],0] 1614 1577
Note: See TracChangeset
for help on using the changeset viewer.