Ignore:
Timestamp:
Apr 21, 2006, 5:20:45 PM (19 years ago)
Author:
duncan
Message:

Do interpolation using fit_interpolate/interpolate.py, instead of least_squares.py.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/fit_interpolate/least_squares.py

    r2695 r2750  
    534534        """
    535535
    536 
    537 
    538         #FIXME (Ole): Check that this function is memeory efficient.
    539         #6 million datapoints and 300000 basis functions
    540         #causes out-of-memory situation
    541         #First thing to check is whether there is room for self.A and self.AtA
    542         #
    543         #Maybe we need some sort of blocking
    544 
    545536        from pyvolution.quad import build_quadtree
    546537        from utilities.polygon import inside_polygon
    547538       
    548 
    549         if data_origin is None:
    550             data_origin = self.data_origin #Use the one from
    551                                            #interpolation instance
    552 
    553539        #Convert input to Numeric arrays just in case.
    554540        point_coordinates = ensure_numeric(point_coordinates, Float)
    555 
    556         #Keep track of discarded points (if any).
    557         #This is only registered if precrop is True
    558         self.cropped_points = False
    559 
    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 point
    565         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 coordinates
    573                     #and xi_0 the reference point of the mesh.
    574                     #
    575                     #A point coordinate (x + x_0) is then made relative
    576                     #to xi_0 by
    577                     #
    578                     # x_new = x + x_0 - xi_0
    579                     #
    580                     #and similarly for eta
    581 
    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 origin
    585                     x_offset = data_origin[1]
    586                     y_offset = data_origin[2]
    587 
    588                 point_coordinates[:,0] += x_offset
    589                 point_coordinates[:,1] += y_offset
    590             else:
    591                 if mesh_origin is not None:
    592                     #Use mesh origin for data points
    593                     point_coordinates[:,0] -= mesh_origin[1]
    594                     point_coordinates[:,1] -= mesh_origin[2]
    595 
    596 
    597 
    598         #Remove points falling outside mesh boundary
    599         #This reduced one example from 1356 seconds to 825 seconds
    600 
    601        
    602         if precrop is True:
    603             from Numeric import take
    604 
    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 = True
    614                 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 = indices
    620 
    621 
    622 
    623541
    624542        #Build n x m interpolation matrix
     
    629547        if verbose: print 'Number of basis functions: %d' %m
    630548
    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 yet
    633         #The tests will reveal what needs to be done
    634 
    635         #
    636         #self.A = Sparse_CSR(Sparse(n,m))
    637         #self.AtA = Sparse_CSR(Sparse(m,m))
    638549        self.A = Sparse(n,m)
    639550        self.AtA = Sparse(m,m)
    640551
    641         #Build quad tree of vertices (FIXME: Is this the right spot for that?)
     552        #Build quad tree of vertices
    642553        root = build_quadtree(self.mesh,
    643554                              max_points_per_cell = max_points_per_cell)
Note: See TracChangeset for help on using the changeset viewer.