podpac.interpolators.NearestPreview

class podpac.interpolators.NearestPreview(**kwargs: Any)[source]

Bases: NearestNeighbor

Nearest Neighbor (Preview) Interpolation

method

Current interpolation method to use in Interpolator (i.e. ‘nearest’). This attribute is set during node evaluation when a new Interpolation class is constructed. See the podpac.data.DataSource interpolation attribute for more information on specifying the interpolator method.

Type:

str

dims_supported

List of unstacked dimensions supported by the interpolator. This attribute should be defined by the implementing Interpolator. Used by private convience method _filter_udims_supported().

Type:

list

spatial_tolerance

Default is inf. Maximum distance to the nearest coordinate in space. Cooresponds to the unit of the space measurement.

Type:

float

time_tolerance

Default is inf. Maximum distance to the nearest coordinate in time coordinates. Accepts p.timedelta64() (i.e. np.timedelta64(1, ‘D’) for a 1-Day tolerance)

Type:

float

alt_tolerance

Default is inf. Maximum distance to the nearest coordinate in altitude coordinates. Corresponds to the unit of the altitude as part of the requested coordinates

Type:

float

spatial_scale

Default is 1. This only applies when the source has stacked dimensions with different units. The spatial_scale defines the factor that lat, lon coordinates will be scaled by (coordinates are divided by spatial_scale) to output a valid distance for the combined set of dimensions.

Type:

float

time_scale

Default is 1. This only applies when the source has stacked dimensions with different units. The time_scale defines the factor that time coordinates will be scaled by (coordinates are divided by time_scale) to output a valid distance for the combined set of dimensions.

Type:

float

alt_scale

Default is 1. This only applies when the source has stacked dimensions with different units. The alt_scale defines the factor that alt coordinates will be scaled by (coordinates are divided by alt_scale) to output a valid distance for the combined set of dimensions.

Type:

float

respect_bounds

Default is True. If True, any requested dimension OUTSIDE of the bounds will be interpolated as ‘nan’. Otherwise, any point outside the bounds will have NN interpolation allowed.

Type:

bool

remove_nan

Default is False. If True, nan’s in the source dataset will NOT be interpolated. This can be used if a value for the function is needed at every point of the request. It is not helpful when computing statistics, where nan values will be explicitly ignored. In that case, if remove_nan is True, nan values will take on the values of neighbors, skewing the statistical result.

Type:

bool

use_selector

Default is True. If True, a subset of the coordinates will be selected BEFORE the data of a dataset is retrieved. This reduces the number of data retrievals needed for large datasets. In cases where remove_nan = True, the selector may select only nan points, in which case the interpolation fails to produce non-nan data. This usually happens when requesting a single point from a dataset that contains nans. As such, in these cases set use_selector = False to get a non-nan value.

Type:

bool

Methods

__init__(**kwargs)

can_interpolate(udims, source_coordinates, ...)

Interpolate data from requested coordinates to source coordinates.

can_select(udims, source_coordinates, ...)

Evaluate if interpolator can downselect the source coordinates from the requested coordinates for the unstacked dims supplied.

init()

Overwrite this method if a Interpolator needs to do any additional initialization after the standard initialization.

interpolate(udims, source_coordinates, ...)

Interpolate data from requested coordinates to source coordinates.

select_coordinates(udims, ...[, index_type])

Downselect coordinates with interpolator method

trait_defaults(*names, **metadata)

Return a trait's default value or a dictionary of them

trait_has_value(name)

Returns True if the specified trait has a value.

trait_values(**metadata)

A dict of trait names and their values.

Attributes

alt_scale

A float trait.

alt_tolerance

A float trait.

definition

Interpolator definition

dims_supported

method

A trait for unicode strings.

methods_supported

name

Interpolator definition

remove_nan

A boolean (True, False) trait.

respect_bounds

A boolean (True, False) trait.

spatial_scale

A float trait.

spatial_tolerance

A float trait.

time_scale

A trait type representing a Union type.

time_tolerance

A trait type representing a Union type.

use_selector

A boolean (True, False) trait.

Members:

__init__(**kwargs)
can_select(udims, source_coordinates, eval_coordinates)[source]

Evaluate if interpolator can downselect the source coordinates from the requested coordinates for the unstacked dims supplied. If not overwritten, this method returns an empty tuple (tuple())

Parameters:
Returns:

Returns a tuple of dimensions that can be selected with this interpolator If no dimensions can be selected, method should return an emtpy tuple

Return type:

tuple

method

A trait for unicode strings.

methods_supported = ['nearest_preview']
select_coordinates(udims, source_coordinates, eval_coordinates, index_type='numpy')[source]

Downselect coordinates with interpolator method

Parameters:
  • udims (tuple) – dimensions to select coordinates

  • source_coordinates (podpac.Coordinates) – Description

  • source_coordinates_index (list) – Description

  • eval_coordinates (podpac.Coordinates) – Description

Returns:

returns the new down selected coordinates and the new associated index. These coordinates must exist in the coordinates of the source data

Return type:

(podpac.Coordinates, list)

Raises:

NotImplementedError

spatial_tolerance

A float trait.