Reputation: 1
I have a gridded velocity field that I want to interpolate in Python. Currently I'm using scipy.interpolate's RectBivariateSpline
to do this, but I want to be able to define edges of my field by setting certain values in the grid to NaN. However, when I do this it messes up the interpolation of the entire grid, effectively making it NaN everywhere. Apparently this is an error in the scipy fitpack, so what would be the best way to work around this? I want to be able to keep the NaNs in the grid to work with edges and out of bounds later on, but I don't want it to affect the interpolation in the rest of the grid.
Upvotes: 0
Views: 1126
Reputation: 26030
Spline fitting/interpolation is global, so it's likely that even a single nan
is messing up the whole mesh.
Upvotes: 0
Reputation: 234635
All languages that implement floating point correctly (which includes python) allow you to test for a NaN by comparing a number with itself.
x
is not equal to x
if, and only if, x
is NaN.
You'll be able to use that to filter your data set accordingly.
Upvotes: 1