Changeset 1891
- Timestamp:
- Oct 11, 2005, 1:52:46 PM (19 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/least_squares.py
r1888 r1891 279 279 verbose = False, 280 280 expand_search = True, 281 interp_only = False, 281 282 max_points_per_cell = 30, 282 283 mesh_origin = None, … … 345 346 self.alpha = alpha 346 347 348 349 if point_coordinates is not None: 350 if verbose: print 'Building interpolation matrix' 351 self.build_interpolation_matrix_A(point_coordinates, 352 verbose = verbose, 353 expand_search = expand_search, 354 interp_only = interp_only, 355 max_points_per_cell =\ 356 max_points_per_cell, 357 data_origin = data_origin, 358 precrop = precrop) 347 359 #Build coefficient matrices 348 self.build_coefficient_matrix_B(point_coordinates, 360 if interp_only == False: 361 self.build_coefficient_matrix_B(point_coordinates, 349 362 verbose = verbose, 350 363 expand_search = expand_search, … … 356 369 357 370 def set_point_coordinates(self, point_coordinates, 358 data_origin = None): 371 data_origin = None, 372 verbose = False, 373 precrop = True): 359 374 """ 360 375 A public interface to setting the point co-ordinates. 361 376 """ 377 if point_coordinates is not None: 378 if verbose: print 'Building interpolation matrix' 379 self.build_interpolation_matrix_A(point_coordinates, 380 verbose = verbose, 381 data_origin = data_origin, 382 precrop = precrop) 362 383 self.build_coefficient_matrix_B(point_coordinates, data_origin) 363 384 … … 375 396 376 397 if point_coordinates is not None: 377 378 if verbose: print 'Building interpolation matrix'379 self.build_interpolation_matrix_A(point_coordinates,380 verbose = verbose,381 expand_search = expand_search,382 max_points_per_cell =\383 max_points_per_cell,384 data_origin = data_origin,385 precrop = precrop)386 387 398 if self.alpha <> 0: 388 399 self.B = self.AtA + self.alpha*self.D … … 397 408 max_points_per_cell=30, 398 409 data_origin = None, 399 precrop = False): 410 precrop = False, 411 interp_only = False): 400 412 """Build n x m interpolation matrix, where 401 413 n is the number of data points and … … 556 568 self.A[i,j] = sigmas[j] 557 569 for k in js: 558 self.AtA[j,k] += sigmas[j]*sigmas[k] 570 if interp_only == False: 571 self.AtA[j,k] += sigmas[j]*sigmas[k] 559 572 else: 560 573 pass -
inundation/pyvolution/test_data_manager.py
r1875 r1891 2514 2514 os.remove(root + '_100.dem') 2515 2515 2516 def xxxtestz_sww2ers_real(self): 2517 """Test that sww information can be converted correctly to asc/prj 2518 format readable by e.g. ArcView 2519 """ 2520 2521 import time, os 2522 from Numeric import array, zeros, allclose, Float, concatenate 2523 from Scientific.IO.NetCDF import NetCDFFile 2524 2525 # the memory optimised least squares 2526 # cellsize = 20, # this one seems to hang 2527 # cellsize = 200000, # Ran 1 test in 269.703s 2528 #Ran 1 test in 267.344s 2529 # cellsize = 20000, # Ran 1 test in 460.922s 2530 # cellsize = 2000 #Ran 1 test in 5340.250s 2531 # cellsize = 200 #Ran 1 test in 2532 2533 # not optimised 2534 # seems to hang 2535 # cellsize = 2000 # Ran 1 test in 5334.563s 2536 #Export to ascii/prj files 2537 sww2dem('karratha_100m', 2538 quantity = 'depth', 2539 cellsize = 200000, 2540 verbose = True) 2541 2516 2542 2517 2543 … … 2520 2546 if __name__ == "__main__": 2521 2547 suite = unittest.makeSuite(Test_Data_Manager,'test') 2548 #suite = unittest.makeSuite(Test_Data_Manager,'xxxtest') 2522 2549 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_boundingbox') 2523 2550 #suite = unittest.makeSuite(Test_Data_Manager,'test_dem2pts_bounding_box') -
inundation/pyvolution/test_least_squares.py
r1890 r1891 490 490 491 491 492 def test_interpolate_attributes_to_points_interp_only(self): 493 v0 = [0.0, 0.0] 494 v1 = [0.0, 5.0] 495 v2 = [5.0, 0.0] 496 497 vertices = [v0, v1, v2] 498 triangles = [ [1,0,2] ] #bac 499 500 d0 = [1.0, 1.0] 501 d1 = [1.0, 2.0] 502 d2 = [3.0, 1.0] 503 point_coords = [ d0, d1, d2] 504 505 interp = Interpolation(vertices, triangles, point_coords, 506 interp_only = True) 507 508 f = linear_function(vertices) 509 z = interp.interpolate(f) 510 answer = linear_function(point_coords) 511 #print "answer", answer 512 #print "z", z 513 514 assert allclose(z, answer) 515 492 516 def test_interpolate_attributes_to_pointsII(self): 493 517 a = [-1.0, 0.0]
Note: See TracChangeset
for help on using the changeset viewer.