0

Basically, I want to replicate MATLAB's interp3 function in Python with the 'cubic' setting, but I'm not sure what function in Python is appropriate. RGI only uses linear interpolation, while RBF is associated with unstructured measurements (one thing I want to do in my project is to take the gradient of a value associated with the interpolation, and thus a sparse Jacobian matrix for the term associated with the interpolation process is desired for speed). Is there a function in Python for doing this in 3D, whether a library or a publicly available project? I've had no luck exploring so far.

Edit: How do I reopen this question? RBF has noticeable approximation error, and its cubic setting is not equivalent to that of interp3

George
  • 149
  • 10
  • I am looking for a specific method of interpolation (cubic) rather than just generally interpolating in 3D in Python. interpn, the recommended function in that question's answer, does not support splines in 3D – George May 25 '20 at 21:41
  • Spline interpolation in 3D can be done using [scipy.interpolate.Rbf](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.Rbf.html) – DrBwts May 26 '20 at 12:49
  • Ah it turns out RBF is actually rather robust, I was worried about the spurious influence of other points in the domain but it seems that was not an issue. I'll close this question. – George May 27 '20 at 04:45
  • Addendum: RBF has noticeable approximation error for even constant values of 1 in one dimension compared to interp3 (giving 1.013 for points within the domain), so it's not equivalent for my purposes, how do I reopen this question? – George May 28 '20 at 12:34

1 Answers1

0

I have recently done some research into NURBS, although it is way above my education level it was very interesting. It took me about a month to find a library and I'm not sure it can interpolate from flat data, I never used it and instead opted to run my own code (which is a mistake). But if your trying to do interpolation I would recommend it, its at leaste a start. as for 3D, I'm not sure why you would want it, but you can extrapolate a given set of data from the code and give it to matplotlib to 3d plot. As far as I know (granted I've been coding in python for 2 years so not much), numpy doesn't have anything on the basis of NURBS, or peicewise basis functions.

https://github.com/ElsevierSoftwareX/SOFTX_2018_148

(I know NURBS is mainly for CAD, however its very nice when you want to fit something and when you want to emphasize data somewhere. Also the NURBS Book is helpful in the field, chapter 1-3 is a must, and chapt9 is where you get into converting data to control values) I hope this was helpful in some way shape or form.

  • Thank you for the response. I'm having trouble finding the exact functions they use for interpolation, which I am interested in since the interpolation I'm down is part of a regression problem – George May 25 '20 at 21:55
  • https://nurbs-python.readthedocs.io/en/latest/basics.html#working-with-the-curves This is a portion of the library, anything and everything you would need to know about it will be here in the documentation. this portation regards the creation of 2d lines, but theres also documentation on 3d surfaces and more. I hope this helped. I know the github wasnt too specific as to the location of the documentation. – ColorBand12 Jun 02 '20 at 05:15