-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Multidimensional interpolate_na not working #9392
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
you can only interpolate along a single dimension with that method: |
Hi keewis, According to xarray interpolate_na documentation (https://docs.xarray.dev/en/stable/generated/xarray.DataArray.interpolate_na.html), it says dim is optional and can be None. So that's the reason I have this question. If dim=None raise error, why the documentation says this? |
right, that looks like a documentation bug, and we might want to consider making |
I see. Thank you! |
Encountered a similar problem, I often want to extrapolate nans at the border of a domain (nearest neighbor), and while interpolate_na works in one dimension, I was wondering if there would also be a possibility to add scipy.interpolate.NearestNDInterpolator to xarrays interpolate_na, which looks up the nearest neighbor in higher dimensions. To use it, one has to do something like this with dataarrays: from scipy.interpolate import NearestNDInterpolator (Sources: https://stackoverflow.com/questions/68197762/fill-nan-with-nearest-neighbor-in-numpy-array/68197821#68197821, https://stackoverflow.com/questions/65300732/how-to-fill-nan-with-nearest-non-nan-value-in-2-dimensions) |
What is your issue?
Hi everyone,
According to xarray documentation, I try to fill NaNs by interpolation using multidimensional interpolate_n
u_interp = u.interpolate_na(dim = None, method = 'linear')
but ends up ImplementedError: dim is a required argument.
I also try
u_interp = u.interpolate_na(dim = ['level', 'lat', 'lon'], method = 'linear')
but ends up KeyError: ['level', 'lat', 'lon'].
The xarray version I have tried are: v0.19.0 (Jul 2021), v2023.6.0, v2024.5.0
Could anyone provide some thoughts on this? Thank you!
The text was updated successfully, but these errors were encountered: