Ignore:
Timestamp:
Oct 4, 2016, 4:13:00 PM (9 years ago)
Author:
steve
Message:

Commit svn after a lot of git updates

Location:
trunk/anuga_core/anuga/fit_interpolate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/anuga/fit_interpolate/interpolate.py

    r9554 r9737  
    984984                    raise Exception(msg)
    985985
    986         msg = 'Time interval [%.16f:%.16f]' % (self.time[0], self.time[-1])
    987         msg += ' does not match model time: %.16f\n' % t
     986        msg = 'Model time %.16f' % t
     987        msg += ' is not contained in function domain [%.16f:%.16f].\n' % (self.time[0], self.time[-1])
    988988        if t < self.time[0]: raise Modeltime_too_early(msg)
    989989        if t > self.time[-1]: raise Modeltime_too_late(msg)
  • trunk/anuga_core/anuga/fit_interpolate/interpolate2d.py

    r9693 r9737  
    210210    return r
    211211
     212def interpolate_raster(x, y, z, points, mode='linear', bounds_error=False):
     213    """2D interpolation of raster data
     214    It is assumed that data is organised in matrix z as latitudes from
     215    bottom up along the first dimension and longitudes from west to east
     216    along the second dimension.
     217    Further it is assumed that x is the vector of longitudes and y the
     218    vector of latitudes.
     219    See interpolate2d for details of the interpolation routine
     220    :param x: 1D array of x-coordinates of the mesh on which to interpolate
     221    :type x: numpy.ndarray
     222    :param y: 1D array of y-coordinates of the mesh on which to interpolate
     223    :type y: numpy.ndarray
     224    :param z: 2D array of values for each x, y pair
     225    :type z: numpy.ndarry
     226    :param points: Nx2 array of coordinates where interpolated values are
     227        sought
     228    :type points: numpy.narray
     229    :param mode: Determines the interpolation order.
     230        Options are:
     231            * 'constant' - piecewise constant nearest neighbour interpolation
     232            * 'linear' - bilinear interpolation using the four
     233              nearest neighbours (default)
     234    :type mode: str
     235    :param bounds_error: If True (default) a BoundsError exception
     236          will be raised when interpolated values are requested
     237          outside the domain of the input data. If False, nan
     238          is returned for those values
     239    :type bounds_error: bool
     240    :returns: 1D array with same length as points with interpolated values
     241    :raises: Exception, BoundsError (see note about bounds_error)
     242    """
     243
     244    # Flip matrix z up-down to interpret latitudes ordered from south to north
     245    z = numpy.flipud(z)
     246
     247    # Transpose z to have y coordinates along the first axis and x coordinates
     248    # along the second axis
     249    # noinspection PyUnresolvedReferences
     250    z = z.transpose()
     251
     252    # Call underlying interpolation routine and return
     253    res = interpolate2d(x, y, z, points, mode=mode, bounds_error=bounds_error)
     254    return res
    212255
    213256#------------------------
Note: See TracChangeset for help on using the changeset viewer.