I'm working on a Python project that uses NumPy and SciPy. I have the following:
x = numpy.arange(-5,5,0.01)
y = numpy.arange(-5,5,0.01)
I also have a function of x and y such that
# fxy = function of x and y in a grid
# fxy.shape = (y.shape[0], x.shape[0])
I want to interpolate fxy such that I have the function values at x and y points that are 0.0001 or 0.001 apart, i.e. I want to evaluate the function fxy at
finer_x = numpy.arange(-5,5,0.0001)
finer_y = numpy.arange(-5,5,0.0001)
# finer_fxy = function of finer_x and finer_y in a grid
# finer_fxy.shape = (finer_y.shape[0], finer_x.shape[0])
I keep trying to use the bisplrep and interp2d functions in scipy.interpolate but I get
File "/usr/lib/python2.7/dist-packages/scipy/interpolate/fitpack.py", line 873, in bisplrep
tx,ty,nxest,nyest,wrk,lwrk1,lwrk2)
MemoryError
and
OverflowError: Too many data points to interpolate
respectively using those functions. What's the best way to create the interpolated data?
Obviously, you're putting too many points on your NumPy plate, sorry about to hear about that.
My advice would be to first plot your data, to find zones that are relatively linear, and skip them. That is, try to decompose your arrays into different zones, and perform a piece-wise interpolation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With