Chaquopy with Scipy.Griddata bugs
See original GitHub issueHello,
So i tried to use Scipy Griddata function in a small app with the following code.
import numpy as np
from scipy.interpolate import griddata
X = np.array([.......])
Y = np.array([.......])
Z = np.array([.......])
D = np.array([.......])
Y0=1
X0=5
points = np.array((X.flatten(), Y.flatten(), Z.flatten())).T
values = D.flatten()
D0 = griddata(points, values, (X0,Y0,Z0))`
I inserted this code inside the Chaquopy Demo app, in ui_demo.py exactly. Inside “def onCreate(self, state):” function.
The app takes about 5 mins to open the screen, sometimes never. Ofc the app works perfectly without this chunk of code.
Is there a way i could use to speedup the code. It’s really a small code and i intend to develop a small app that interpolate a small set of data thanks to Python Numpy and Scipy capabilities. No plotting, just that specific small of code that returns a float value.
Just for info this is what i intend to achieve: I have a set of data for example: X Y Z 1 3 7 2 5 8 1 4 9 3 6 10 I would like to interpolate Z for X=2.5 and Y=3.5.
I can use interp2.griddata from Scipy in Python or ScatteredInterpolant in Matlab like this:
z = griddata( [1 2 1 3], [3 5 4 6], [7 8 9 10], 2.5, 3.5, 'nearest' )
or
S = scatteredInterpolant(x,y,z,d);
Is there a way i could use something similar in Swift/Objective-c or any other compatible language to develop a small app for iOS (as well as for Android if possible) where i insert scattered data and when the user enter a value for a given X and Y he gets an interpolated value for Z (i intend to use this with 4D dimension).
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
I can confirm that
griddata
hangs forever on a physical device even for simple examples, and crashes on the emulator.Your simple X=2.5 and Y=3.5 example would never actually work with
griddata
because those coordinates are outside the convex hull of the dataset. In this caseRbf
might be more appropriate, but unfortunately that crashes or hangs in the same way.We’ll try updating SciPy and NumPy to the newest versions as soon as possible. Meanwhile, if your data is 2-dimensional,
interp2d
does work, though it may give extreme results for coordinates which are far away from the dataset.It worked! Very much appreciated sir!