irregularInterpolation package¶
Submodules¶
irregularInterpolation.irregularInterpolation module¶
-
class
irregularInterpolation.irregularInterpolation.KDinterpolationGrid(locations, newlocations, scaling=None, Mask=None, Range=1.0, NoP=None)¶ Bases:
scipy.spatial.kdtree.KDTreeDefines grid of input data and scaling factors for the various dimensions. The geometry needs to be reshaped in 2D [No of data points M x No of Dimensions]. Scaling is 1D [Dimensions] and provides multipliers to use to weight distance across dimensions. Computes look-up table of point interpolators for newlocations [K locations x Dimensions]. Set Range and NoP to desired values to interpolate using the NoP closest points or within the radius of Range. If both are set, the closest NoP are looked up and then Range is applied on the furthest of those. If NoP is not set, scaling should be used to normalise the distances appropriately to Range. If Range is set to None, only the NoP closest points will be used. Returns list of interpolators for locations.
Variables: - shape (tuple of integers) – number of input points
- Mask (boolean array) – mask of positions to exclude (True) from interpolation (e.g. land points in ocean fields)
- scaling (float array) – 1-D array with scaling weights for each dimension in order to differentiate the impact of distances across dimensions
- locations (float array) – 2D array with sequence of point coordinates with positions of original grid [Numper of points X Number of dimensions]
- ips (list of pointIterpolators) – list of interpolators for each output grid point
Set Range and NoP to desired values to interpolate on output grid points using the NoP closest points or within the radius of Range. If both are set, the closest NoP are looked up and then Range is applied as multiple of the furthest of those. If NoP is not set, scaling should be used to normalise the distances appropriately to Range. If Range is set to None, only the NoP closest points will be used.
-
__call__(data)¶ Interpolate data on output grid. Data must be flattened and of the same size as first dimension of input grid.
Parameters: data (float array) – flattened input data Returns: data interpolated on output point (float, None if interpolation fails).
-
__init__(locations, newlocations, scaling=None, Mask=None, Range=1.0, NoP=None)¶ Defines grid of input data and scaling factors for the various dimensions and computes look-up table of point interpolators for newlocations [K locations x Dimensions].
Parameters: - locations (float array) – point coordinates of input grid. The geometry needs to be reshaped in 2D [No of data points M x No of dimensions].
- newlocations (float array) – point coordinates of output grid. The geometry needs to be reshaped in 2D [No of data points M x No of dimensions].
- scaling (float array) – 1D [Dimensions] array that provides multipliers to use to weight distances across dimensions.
- Mask – mask of positions to exclude (True) from interpolation (e.g. land points in ocean fields). This will effectively remove the mask before interpolation, so the mask will not be interoplated to the output grid. Set to None if you want mask interpolation.
- Range – distance of points in input grid to points in output grid to be included in interpolation
- NoP – Number of points of inputgrids to be included in interpolation for each output grid point
-
__module__= 'irregularInterpolation.irregularInterpolation'¶
-
class
irregularInterpolation.irregularInterpolation.KDpointInterpolator(iGrid, location, Range=1.0, NoP=None)¶ Bases:
object-
__call__(data)¶ Interpolate data on output grid. Data must be flattened and of the same size as first dimension of input grid.
Parameters: data (float array) – flattened input data Returns: data interpolated on output grid (float array).
-
__dict__= mappingproxy({'__module__': 'irregularInterpolation.irregularInterpolation', '__init__': <function KDpointInterpolator.__init__>, '__call__': <function KDpointInterpolator.__call__>, '__dict__': <attribute '__dict__' of 'KDpointInterpolator' objects>, '__weakref__': <attribute '__weakref__' of 'KDpointInterpolator' objects>, '__doc__': None})¶
-
__init__(iGrid, location, Range=1.0, NoP=None)¶ Determines interpolation positions and weights from interpolationGrid instance containg the coordinates of the original data. Weights and positions are set to False, if no valid position is found.
Parameters: - iGrid (KDInterpolationGrid) – input grid for interpolation
- location (float array) – coordinates of point to interpolate to
- Range – distance of points in input grid to points in output grid to be included in interpolation
- NoP – Number of points of inputgrids to be included in interpolation for each output grid point
Set Range and NoP to desired values to interpolate on output grid points using the NoP closest points or within the radius of Range. If both are set, the closest NoP are looked up and then Range is applied as multiple of the furthest of those. If NoP is not set, scaling should be used to normalise the distances appropriately to Range. If Range is set to None, only the NoP closest points will be used.
-
__module__= 'irregularInterpolation.irregularInterpolation'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
-
class
irregularInterpolation.irregularInterpolation.interpolationGrid(locations, newlocations, scaling=None, Mask=None, Range=1.0, NoP=None)¶ Bases:
objectClass for interpolation from irregularly distributed data on any output position. It can use two different approaches to interpolate or a combination of the two:
- search for the N closest points
- search for all points within a certain radius
Usage:
- Create an instance for the interpolation grid defined by an arra of size (KxDim) containing the coordinates of your input data an array of size (MxDim) with the coordinates of the desired output.
- Call the interpolation grid with the data you want to interpolate.
Variables: - shape (tuple of integers) – number of input points
- mask (boolean array) – mask of positions to exclude (True) from interpolation (e.g. land points in ocean fields)
- scaling (float array) – 1-D array with scaling weights for each dimension in order to differentiate the impact of distances across dimensions
- locations (float array) – 2D array with sequence of point coordinates with positions of original grid [Numper of points X Number of dimensions]
- ips (list of pointIterpolators) – list of interpolators for each output grid point
-
__call__(idata, treshold=0.5, fillValue=9.969209968386869e+36)¶ Interpolate data on output grid. Data must be flattened and of the same size as first dimension of input grid.
Parameters: - idata (float array) – flattened input data
- treshold (float) – threshold to identify masked points on output grid.
- fillValue (float) – valeu applied to masked points on output grid
Returns: data interpolated on output grid (float array).
Masks of the input data are interpolated from (True) to 0 (False). Any point where the interpolated mask results > threshold will be masked on the output grid. If the Mask attribute of the instance is defined, the mask won’t be interpolated, but data will be extrapolated from the input grid to all output gridpoints.
-
__dict__= mappingproxy({'__module__': 'irregularInterpolation.irregularInterpolation', '__doc__': 'Class for interpolation from irregularly distributed data on any\n output position. It can use two different approaches to interpolate\n or a combination of the two:\n\n - search for the N closest points\n - search for all points within a certain radius\n\n Usage:\n\n - Create an instance for the interpolation grid defined by an arra of\n size (KxDim) containing the coordinates of your input data an array of\n size (MxDim) with the coordinates of the desired output.\n - Call the interpolation grid with the data you want to interpolate.\n\n Attributes:\n\n shape (tuple of integers): number of input points\n mask(boolean array): mask of positions to exclude (True) from\n interpolation (e.g. land points in ocean fields)\n scaling (float array): 1-D array with scaling weights for each dimension\n in order to differentiate the impact of distances across dimensions\n locations (float array): 2D array with sequence of point coordinates with\n positions of original grid [Numper of points X Number of dimensions]\n ips (list of pointIterpolators): list of interpolators for each output grid\n point\n ', '__init__': <function interpolationGrid.__init__>, '__call__': <function interpolationGrid.__call__>, '__dict__': <attribute '__dict__' of 'interpolationGrid' objects>, '__weakref__': <attribute '__weakref__' of 'interpolationGrid' objects>})¶
-
__init__(locations, newlocations, scaling=None, Mask=None, Range=1.0, NoP=None)¶ Defines grid of input data and scaling factors for the various dimensions and computes look-up table of point interpolators for newlocations [K locations x Dimensions].
Parameters: - locations (float array) – point coordinates of input grid. The geometry needs to be reshaped in 2D [No of data points M x No of dimensions].
- newlocations (float array) – point coordinates of output grid. The geometry needs to be reshaped in 2D [No of data points M x No of dimensions].
- scaling (float array) – 1D [Dimensions] array that provides multipliers to use to weight distances across dimensions.
- Mask – mask of positions to exclude (True) from interpolation (e.g. land points in ocean fields). This will effectively remove the mask before interpolation, so the mask will not be interoplated to the output grid. Set to None if you want mask interpolation.
- Range – distance of points in input grid to points in output grid to be included in interpolation
- NoP – Number of points of inputgrids to be included in interpolation for each output grid point
Set Range and NoP to desired values to interpolate on output grid points using the NoP closest points or within the radius of Range. If both are set, the closest NoP are looked up and then Range is applied as multiple of the furthest of those. If NoP is not set, scaling should be used to normalise the distances appropriately to Range. If Range is set to None, only the NoP closest points will be used.
-
__module__= 'irregularInterpolation.irregularInterpolation'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
irregularInterpolation.irregularInterpolation.nearestN(dz, NoP=3)¶ Find the NoP positions of minimal distances for intepolation.
Parameters: - dz (float array) – 1D-array with distances [No of grid points]
- NoP – Number of points with minimal distances do keep.
Returns: list with positions in input array, weights for interpolation and distances for each selected point (list of 1D arrays)
-
irregularInterpolation.irregularInterpolation.nearestR(dz, Range=2)¶ Find all points within the Range distance.
Parameters: - dz (float array) – 1D-array with distances [No of grid points]
- Range – Maximal distance of inclusion.
Returns: list with positions in input array and weights for interpolation and distance for each selected point (list of 1D arrays)
-
class
irregularInterpolation.irregularInterpolation.pointInterpolator(iGrid, location, Range=1.0, NoP=None)¶ Bases:
objectClass for interpolator instances that include weights for all points of the input grid,
Variables: - positions (integer array) – positions in input grid to use for interpolation
- weights (float array) – weights for each point of input grid used for interpolation
-
__call__(data, treshold=0.5)¶ Interpolate data on output grid. Data must be flattened and of the same size as first dimension of input grid.
Parameters: - data (float array) – flattened input data
- treshold (float) – threshold to identify masked points on output grid.
Returns: data interpolated on output point (float, None if masked).
-
__dict__= mappingproxy({'__module__': 'irregularInterpolation.irregularInterpolation', '__doc__': 'Class for interpolator instances that include weights for all points of the\n input grid,\n\n Attributes:\n positions (integer array): positions in input grid to use for interpolation\n weights (float array): weights for each point of input grid used for\n interpolation\n ', '__init__': <function pointInterpolator.__init__>, '__call__': <function pointInterpolator.__call__>, '_interpolate': <function pointInterpolator._interpolate>, '_maskedInterpolate': <function pointInterpolator._maskedInterpolate>, '__dict__': <attribute '__dict__' of 'pointInterpolator' objects>, '__weakref__': <attribute '__weakref__' of 'pointInterpolator' objects>})¶
-
__init__(iGrid, location, Range=1.0, NoP=None)¶ Determines interpolation positions and weights from interpolationGrid instance containg the coordinates of the original data. Weights and positions are set to False, if no valid position is found.
Parameters: - iGrid (interpolationGrid) – input grid for interpolation
- location (float array) – coordinates of point to interpolate to
- Range – distance of points in input grid to points in output grid to be included in interpolation
- NoP – Number of points of inputgrids to be included in interpolation for each output grid point
Set Range and NoP to desired values to interpolate on output grid points using the NoP closest points or within the radius of Range. If both are set, the closest NoP are looked up and then Range is applied as multiple of the furthest of those. If NoP is not set, scaling should be used to normalise the distances appropriately to Range. If Range is set to None, only the NoP closest points will be used.
-
__module__= 'irregularInterpolation.irregularInterpolation'¶
-
__weakref__¶ list of weak references to the object (if defined)
irregularInterpolation.KDInterpolator module¶
Module contents¶
irregularInterpolation package initialisation.