Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpolation point out of data bounds encountered #593

Open
cyschneck opened this issue Apr 9, 2024 · 0 comments
Open

Interpolation point out of data bounds encountered #593

cyschneck opened this issue Apr 9, 2024 · 0 comments
Labels
bug Something isn't working support Support request opened by outside user/collaborator

Comments

@cyschneck
Copy link
Contributor

Internal package interpolation.py currently throws a UserWarning for interpolation test test_interp_hybrid_to_pressure_extrap_geopotential

interpolation.py:133: UserWarning: Interpolation point out of data bounds encountered
    return func_interpolate(new_levels, xcoords, data, axis=interp_axis)

The interpolation warning is generated by the test test_interp_hybrid_to_pressure_extrap_geopotential that is populated from press_in which is populated with the values

[[[68619.195 68619.195]
  [69344.43  69290.68 ]
  [70799.516 70643.86 ]]]

To be interpolated along the values

[ 50000  92500  95000 100000]

The test calls interp_hybrid_to_pressure as linear, so it ends up calling metpy interpolate_1d. Specifically, the error being thrown is because the interpolate values and the coordinates shapes are equal without a fill_value

Metpy will raise a warning that:

Warn if interpolated values are outside data bounds, will make these the values at end of data range.

Since the input values max value 70272.49076537043 is less than max interpolate value 100000 it can't interpolate to the bounds outside the range (without setting a fill_value). So, by default, It adds the values to the end of the range

An easy way to see this is interpolating to 4.5 when the range is to 4:

import metpy.interpolate
import numpy as np

x = np.array([1., 2., 3., 4.])
y = np.array([1., 2., 3., 4.])
x_interp = np.array([2.5, 3.5])
metpy.interpolate.interpolate_1d(x_interp, x, y)

Where the array position of the max value is out of bounds, so the array appends nan

metpy.interpolate.interpolate_1d(x_interp, x, y)
<stdin>:1: UserWarning: Interpolation point out of data bounds encountered
array([2.5, nan])

When the values are within range, it returns the interpolated values without a nan

import metpy.interpolate
import numpy as np

x = np.array([1., 2., 3., 4.])
y = np.array([1., 2., 3., 4.])
x_interp = np.array([2.5, 3.5])
metpy.interpolate.interpolate_1d(x_interp, x, y)
array([2.5, 3.5])
@cyschneck cyschneck added bug Something isn't working support Support request opened by outside user/collaborator labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working support Support request opened by outside user/collaborator
Projects
None yet
Development

No branches or pull requests

1 participant