Datalens.ai
← All algorithms

INTERPOLATION

interpn

Multidimensional interpolation on regular or rectilinear grids.

Example of usage

Python API reference included; executable data demonstration pending review.

Usage / limitations

+Use when: Estimate values between samples.

−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.

Mathematical formula

See method documentation: implementation and assumptions vary.
Sample dataShow
{
  "variable": "observations",
  "domain": "Environmental monitoring — regular weather monitoring grid",
  "feature_names": [
    "east_km",
    "north_km",
    "temperature_c"
  ],
  "grid_east_km": [
    0,
    1,
    2
  ],
  "grid_north_km": [
    0,
    1,
    2
  ],
  "grid_temperature_c": [
    [
      18.0,
      19.0,
      20.0
    ],
    [
      19.0,
      20.0,
      21.0
    ],
    [
      20.0,
      21.0,
      22.0
    ]
  ]
}

Code example (Python)

# DataLens.ai example — interpn
# Domain: environmental temperature monitoring.
# Input observations is supplied by the Sample Data section.
import numpy as np
from scipy.interpolate import interpn

# Read recorded measurements with explicit, meaningful feature names.
# Perform the specified interpolation and validate expected properties.
coordinates = (np.asarray(observations["grid_east_km"]), np.asarray(observations["grid_north_km"]))
values = np.asarray(observations["grid_temperature_c"], dtype=float)
query = np.array([[1., 1.]])
result = interpn(coordinates, values, query, method="linear")
assert np.allclose(result, [20.], atol=1e-9)

# Self-test completed without raising an assertion error.
print("Expected output verified")