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

If raster contains a single NaN Linear() works but Cubic() returns all NaNs #587

Open
alex-s-gardner opened this issue Mar 13, 2024 · 2 comments

Comments

@alex-s-gardner
Copy link

alex-s-gardner commented Mar 13, 2024

I'm seeing issues when using Cubic interpoaltion of data that contains NaN values. Here's what I see:

using Interpolations
A = rand(100,100);
x = 1:100;
y = 1:100;
interp = Cubic();

itp = Interpolations.extrapolate(Interpolations.scale(Interpolations.interpolate(A, BSpline(interp)), x, y), NaN);

itp has no NaN values

julia> sum(isnan.(itp.itp))
0

add a NaN value

 A[1,1] = NaN
itp = Interpolations.extrapolate(Interpolations.scale(Interpolations.interpolate(A, BSpline(interp)), x, y), NaN);

now all itp values are NaNs

julia> sum(isnan.(itp.itp))
10000

change interp to Linear

interp = Linear();
 itp = Interpolations.extrapolate(Interpolations.scale(Interpolations.interpolate(A, BSpline(interp)), x, y), NaN);

now itp contains only a single NaN

julia> sum(isnan.(itp.itp))
1
@mkitti
Copy link
Collaborator

mkitti commented Mar 13, 2024

What behavior would you expect if there are NaN values?

@alex-s-gardner
Copy link
Author

I would expect something similar to the behavior of when using Linear()... , if any point included within the footprint of the interpolation kernel (5x5 for Cubic) is a NaN then I would expect interpolations to return a NaN. I did not expect the existence of a single NaN in a 100x100 matrix to create NaNs everywhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants