safe.gis.interpolation module

Commonalities used in both 1d and 2d interpolation

This module provides commonalities shared between interpolation1d and interpolation2d. This includes input data validation methods.

safe.gis.interpolation.validate_coordinate_vector(coordinates, coordinate_name)[source]

Validate that the coordinates vector are valid

Parameters:
  • coordinates (numpy.ndarray) – The coordinates vector
  • coordinate_name (str) – The user recognizable name of the coordinates.
Raise:

Exception, InaSAFEError

Returns:

Coordinates cast as a numpy arry

safe.gis.interpolation.validate_inputs(x=None, y=None, z=None, points=None, bounds_error=None)[source]

Check inputs for interpolate1d and interpolate2d functions

Parameters:
  • x (numpy.ndarray) – 1D array of x-coordinates on which to interpolate
  • y – 1D array of y-coordinates on which to interpolate
  • z (numpy.ndarray) – array of values for each x
  • points (numpy.ndarray) – 1D array of coordinates where interpolated values are sought
  • bounds_error (bool) – Flag to indicate whether an exception will be raised when interpolated values are requested outside the domain of the input data. If False, nan is returned for those values.
Returns:

x, z and points

Raises:

RuntimeError, Exception

safe.gis.interpolation.validate_mode(mode)[source]

Validate that the mode is an allowable value.

Parameters:mode (str) –

Determines the interpolation order. Options are:

  • ‘constant’ - piecewise constant nearest neighbour interpolation
  • ‘linear’ - bilinear interpolation using the two nearest neighbours (default)
Raises:InaSAFEError