简体   繁体   中英

Python 2D Interpolation onto Random Points

I have an interpolation problem that should be simple but I can't for the life of me get scipy to handle correctly. I want to interpolate in 2D from regularly sampled points onto irregularly spaced points (in particular, I have a profile measured on a sphere that's sampled on a grid in theta and phi, that I want to project into a different pixellization of the sphere). Creating the interpolator (using scipy.interpolate.interp2d) goes fine, but there doesn't seem to be any way to evaluate it for a list of points that aren't on a grid. In particular, if func2d is the output of interpolate2d, then I want

    zi=func2d(xi,yi)

to return something that's a 1-d array rather than a 2-d array with dimensions (len(xi),len(yi)).

The documentation says

     |      Returns
     |      -------
     |      z : 2D array with shape (len(y), len(x))
     |          The interpolated values.

so perhaps it's impossible? I could obviously loop over points, but that just seems primitive. This seems like such a common use case that there must be a simple solution, but for the life of me I can't find one. Does anyone have a suggestion? It would be most appreciated!

This can be done with scipy.interpolate.RegularGridInterpolator

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