Changeset 2750 for inundation/fit_interpolate/least_squares.py
- Timestamp:
- Apr 21, 2006, 5:20:45 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/fit_interpolate/least_squares.py
r2695 r2750 534 534 """ 535 535 536 537 538 #FIXME (Ole): Check that this function is memeory efficient.539 #6 million datapoints and 300000 basis functions540 #causes out-of-memory situation541 #First thing to check is whether there is room for self.A and self.AtA542 #543 #Maybe we need some sort of blocking544 545 536 from pyvolution.quad import build_quadtree 546 537 from utilities.polygon import inside_polygon 547 538 548 549 if data_origin is None:550 data_origin = self.data_origin #Use the one from551 #interpolation instance552 553 539 #Convert input to Numeric arrays just in case. 554 540 point_coordinates = ensure_numeric(point_coordinates, Float) 555 556 #Keep track of discarded points (if any).557 #This is only registered if precrop is True558 self.cropped_points = False559 560 #Shift data points to same origin as mesh (if specified)561 562 #FIXME this will shift if there was no geo_ref.563 #But all this should be removed anyhow.564 #change coords before this point565 mesh_origin = self.mesh.geo_reference.get_origin()566 if point_coordinates is not None:567 if data_origin is not None:568 if mesh_origin is not None:569 570 #Transformation:571 #572 #Let x_0 be the reference point of the point coordinates573 #and xi_0 the reference point of the mesh.574 #575 #A point coordinate (x + x_0) is then made relative576 #to xi_0 by577 #578 # x_new = x + x_0 - xi_0579 #580 #and similarly for eta581 582 x_offset = data_origin[1] - mesh_origin[1]583 y_offset = data_origin[2] - mesh_origin[2]584 else: #Shift back to a zero origin585 x_offset = data_origin[1]586 y_offset = data_origin[2]587 588 point_coordinates[:,0] += x_offset589 point_coordinates[:,1] += y_offset590 else:591 if mesh_origin is not None:592 #Use mesh origin for data points593 point_coordinates[:,0] -= mesh_origin[1]594 point_coordinates[:,1] -= mesh_origin[2]595 596 597 598 #Remove points falling outside mesh boundary599 #This reduced one example from 1356 seconds to 825 seconds600 601 602 if precrop is True:603 from Numeric import take604 605 if verbose: print 'Getting boundary polygon'606 P = self.mesh.get_boundary_polygon()607 608 if verbose: print 'Getting indices inside mesh boundary'609 indices = inside_polygon(point_coordinates, P, verbose = verbose)610 611 612 if len(indices) != point_coordinates.shape[0]:613 self.cropped_points = True614 if verbose:615 print 'Done - %d points outside mesh have been cropped.'\616 %(point_coordinates.shape[0] - len(indices))617 618 point_coordinates = take(point_coordinates, indices)619 self.point_indices = indices620 621 622 623 541 624 542 #Build n x m interpolation matrix … … 629 547 if verbose: print 'Number of basis functions: %d' %m 630 548 631 #FIXME (Ole): We should use CSR here since mat-mat mult is now OK.632 #However, Sparse_CSR does not have the same methods as Sparse yet633 #The tests will reveal what needs to be done634 635 #636 #self.A = Sparse_CSR(Sparse(n,m))637 #self.AtA = Sparse_CSR(Sparse(m,m))638 549 self.A = Sparse(n,m) 639 550 self.AtA = Sparse(m,m) 640 551 641 #Build quad tree of vertices (FIXME: Is this the right spot for that?)552 #Build quad tree of vertices 642 553 root = build_quadtree(self.mesh, 643 554 max_points_per_cell = max_points_per_cell)
Note: See TracChangeset
for help on using the changeset viewer.