Python Forum
scipy interp2d doesn't work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
scipy interp2d doesn't work
#5
(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.
Reply


Messages In This Thread
scipy interp2d doesn't work - by player1681 - Feb-04-2020, 08:43 AM
RE: scipy interp2d doesn't work - by scidam - Feb-05-2020, 01:06 AM
RE: scipy interp2d doesn't work - by player1681 - Feb-05-2020, 08:23 AM
RE: scipy interp2d doesn't work - by scidam - Feb-05-2020, 09:40 AM
RE: scipy interp2d doesn't work - by player1681 - Feb-05-2020, 09:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Convolution "same" in Python doesn't work as Matlab claw91 4 3,774 Oct-01-2020, 08:59 AM
Last Post: claw91
  Numpy doesn't work in Spyder 4.1.3 player1681 1 2,159 Jun-02-2020, 11:26 AM
Last Post: jefsummers
  interp2d casting ruled not 'safe' sebseb 0 1,867 Jul-05-2018, 09:21 AM
Last Post: sebseb
  cx_Freeze doesn't seem to work owenwalker65 7 16,869 Dec-07-2017, 02:23 AM
Last Post: issac_n
  Matplotlib Doesn't Work Ian12290 6 13,282 Feb-28-2017, 06:18 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020