简体   繁体   中英

Interpolate large data Python

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, ie 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.

Your data is on a regular grid: try using RectBivariateSpline.

bisplrep/interp2d are for scattered data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM