Speedup scipy griddata for multiple interpolations between two irregular grids

前端 未结 4 1090
一个人的身影
一个人的身影 2020-12-01 00:11

I have several values that are defined on the same irregular grid (x, y, z) that I want to interpolate onto a new grid (x1, y1, z1). i.e., I have <

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 00:55

    You can try to use Pandas, as it provides high-performance data structures.

    It is true that the interpolation method is a wrapper of the scipy interpolation BUT maybe with the improved structures you obtain better speed.

    import pandas as pd;
    wp = pd.Panel(randn(2, 5, 4));
    wp.interpolate();
    

    interpolate() fills the NaN values in the Panel dataset using different methods. Hope it is faster than Scipy.

    If it doesn't work, there is one way to improve the performance (instead of using a parallelized version of your code): use Cython and implement small routine in C to use inside your Python code. Here you have an example about this.

提交回复
热议问题