Changeset 17655


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

added option to plot data for inspecting holes before spline interpolation

File:
1 edited

Legend:

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

    r17598 r17655  
    22import numpy as npy
    33from scipy.interpolate import CloughTocher2DInterpolator, Rbf
     4try:
     5        import matplotlib.pyplot as plt
     6except ImportError:
     7        print 'could not import matplotlib, no plotting functions enabled.\
     8                        Set plotonly=False in function call'
    49
    510def MeshSplineToMesh2d(x,y,data,xi,yi,tol=1e-6,**kwargs):#{{{
     
    6671        return interpdata
    6772#}}}
    68 def GridSplineToMesh2d(x,y,data,xi,yi,default_value=npy.nan):#{{{
     73def GridSplineToMesh2d(x,y,data,xi,yi,default_value=npy.nan,plotonly=False):#{{{
    6974        '''
    7075        python analog to InterpFromGridToMesh.  This routine uses
     
    8489        default_value:  default value if points lie outside the convex hull of input
    8590                                                points (defaults to nan if not specified)
     91        plotonly:               plot the data to be interpolated using imshow (useful for
     92                                                identifying holes in data and problems with interpolation)
    8693
    8794        Usage:
    88                 interpdata=GridToMesh(x,y,data,xi,yi,default_value=npy.nan)
     95                interpdata=GridToMesh(x,y,data,xi,yi,default_value=npy.nan,plotonly=False)
    8996
    9097        Examples:
     
    115122        flatsubdata=subdata.ravel()
    116123
     124        if plotonly:
     125                plt.imshow(npy.flipud(subdata),origin='upper')
     126                plt.show()
     127                return
     128
    117129        # mask out any nan's in the data and corresponding coordinate points
    118130        mask=npy.isnan(flatsubdata)
Note: See TracChangeset for help on using the changeset viewer.