Changeset 17867


Ignore:
Timestamp:
04/28/14 17:06:48 (11 years ago)
Author:
cborstad
Message:

CHG: pass x and y directly; model not otherwise needed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/interp/holefiller.py

    r17551 r17867  
    22from scipy.spatial import cKDTree
    33
    4 def nearestneighbors(md,data,goodids,badids,knn):
     4def nearestneighbors(x,y,data,goodids,badids,knn):
    55        '''
    66        fill holes using nearest neigbors.  Arguments include:
    77
    8         md:             the model
     8
     9        x,y:            the coordinates of data to be filled
    910        data:           the data field to be filled (full field, including holes)
    1011        goodids:        id's into the vertices that have good data
     
    1516
    1617        Usage:
    17                 filleddata=nearestneighbors(md,goodids,badids,knn)
     18                filleddata=nearestneighbors(x,y,data,goodids,badids,knn)
    1819
    1920        Example:
    20                 filledthickness=nearestneighbors(md,goodids,badids,5)
     21                filledthickness=nearestneighbors(x,y,data,goodids,badids,5)
    2122        '''
    2223
     
    2425                raise TypeError('nearestneighbors error: knn should be an integer>1')
    2526
    26         if len(data) != md.mesh.numberofvertices:
    27                 raise StandardError('nearestneighbors error: "data" should have length md.mesh.numberofvertices')
     27        if len(x) != len(data) or len(y) != len(data):
     28                raise StandardError('nearestneighbors error: x and y should have the same length as "data"')
    2829
    2930        filled=data
    3031       
    31         XYGood=npy.dstack([md.mesh.x[goodids],md.mesh.y[goodids]])[0]
    32         XYBad=npy.dstack([md.mesh.x[badids],md.mesh.y[badids]])[0]
     32        XYGood=npy.dstack([x[goodids],y[goodids]])[0]
     33        XYBad=npy.dstack([x[badids],y[badids]])[0]
    3334        tree=cKDTree(XYGood)
    3435        nearest=tree.query(XYBad,k=knn)[1]
Note: See TracChangeset for help on using the changeset viewer.