Linear interpolation with PycontrailsRegularGridInterpolator fails when the field being interpolated only has one non-degenerate dimension (i.e., when evaluate_1d is used).
Note that this bug predates changes made in pycontrails 0.50.1 to accomodate updates in scipy 1.13.0: it's present using e.g. pycontrails 0.49.5 and scipy 1.12.0.
Details
Version: confirmed present in pycontrails 0.49.5 and pycontrails 0.50.1, using both scipy 1.12.0 and 1.13.0
Module: core.interpolation
OS: ubuntu
Steps to Reproduce
import pycontrails
import scipy
print(f"pycontrails {pycontrails.__version__}")
print(f"scipy {scipy.__version__}")
from pycontrails.core.interpolation import PycontrailsRegularGridInterpolator
import numpy as np
x = np.array([0.0, 1.0])
y = np.array([0.0])
z = np.linspace(0, 1, 2)
t = np.array([0.0])
values = np.tile(np.linspace(0, 1, 2), (2, 1, 1, 1)).reshape((2, 1, 2, 1))
target = np.array([[0.0, 0.0, 0.5, 0.0]])
rgi = PycontrailsRegularGridInterpolator(
points=(x, y, z, t),
values=values,
method="linear",
bounds_error=True,
fill_value = np.nan
)
print(rgi(target))
x = np.array([0.0])
y = np.array([0.0])
z = np.linspace(0, 1, 2)
t = np.array([0.0])
values = np.linspace(0, 1, 2).reshape((1, 1, 2, 1))
rgi = PycontrailsRegularGridInterpolator(
points=(x, y, z, t),
values=values,
method="linear",
bounds_error=True,
fill_value = np.nan
)
print(rgi(target))
The first interpolation (with two non-degenerate dimensions) produces the expected result. The second interpolation (with only one non-degenerate dimension) raises ValueError: Buffer has wrong number of dimensions (expected 1, got 2) from evaluate_1d.
Description
Linear interpolation with
PycontrailsRegularGridInterpolator
fails when the field being interpolated only has one non-degenerate dimension (i.e., whenevaluate_1d
is used).Note that this bug predates changes made in pycontrails 0.50.1 to accomodate updates in scipy 1.13.0: it's present using e.g. pycontrails 0.49.5 and scipy 1.12.0.
Details
Steps to Reproduce
The first interpolation (with two non-degenerate dimensions) produces the expected result. The second interpolation (with only one non-degenerate dimension) raises
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
fromevaluate_1d
.