Feb-05-2020, 09:50 AM
(Feb-05-2020, 01:06 AM)scidam Wrote: Loops are slow in Python, so I need to clarify, does it hang when you call interp2d, or it hangs when you fill your arrays positionX and positionY?
(Feb-05-2020, 08:23 AM)player1681 Wrote:(Feb-04-2020, 08:43 AM)player1681 Wrote: Hello everybody. I have a .txt file in which a grid of X and Y points and values of f(X, Y) in said grid are constructed as columns. I am trying to program the Shannon Interpolation. For that I need to do the regular interpolation on the grid. To do it, first I construc three lists of values as
f = open('XdataTXT.txt','r') linesX=f.readlines() X_column_number = 0 positionX=[] Y_column_number = 1 positionY=[] WindX_column_number=2 windX=[] for x in linesX: positionX.append(float(x.split()[X_column_number])) positionY.append(float(x.split()[Y_column_number])) windX.append(float(x.split()[WindX_column_number])) f.close()Then I try to do the regular interpolation as defined here
windXInterpFunc = interpolate.interp2d(positionX, positionY, windX, kind='cubic')However, when I run this, python just keeps running without finishing, doesn't matter how long I leave the program running.
Can someone assist me?
Regards.
EDIT: I have tested with a smaller set of points and the program runs well enough. Therefore my issue is not a syntax one, but the fact that I am using plenty of points. I would need a way to speed up my process.
It hangs on the interpolate.interp2d. The loop is almost instantaneous.
I cannot upload the text file to make it easier for you to because it is too large.
(Feb-05-2020, 09:40 AM)scidam Wrote: I don't think it will be easy to improve performance of interp2d
. It is already written in C (fitpackmodule.c). However, you can try to estimate the time you need to get all work done. You can pass PositionX[:100], PositionX[:1000], PositionX[:10000] and measure the time required for computations. Finally, you can extrapolate the result for the entire dataset.
Very well. I will try to estimate the time and perhaps let the program run during the weekend. Thanks for your advice.