Finding Derivatives of a 2D Interpolation Using RectBivariateSpline.__call__
Hi. I need to find partial derivatives of 2d interpolation using RectBivariateSpline.__call__ from scipy. This is the code that I have so far: import numpy as np from scipy import interpolate xm = np.arange(-180.,182.,2) #rank-1 array length 181 ym = np.arange(-180.,182.,2) #rank-1 array length 181 zm = np.loadtxt('data.dat', dtype = np.double) #rank-2 array length (181x181) V = interpolate.RectBivariateSpline(xm, ym, zm, s=0) this code works fine when I need to know the value of the interpolated function at a given point, now how should I proceed from here to also find the derivatives at any specific point. Thanks a lot for the help. -- Delaram Ghoreishi Ph.D. Student Department of Physics University of Florida P.O. Box 118440 Gainesville, Florida 32611
In [20]: x = np.arange(8) In [21]: y = np.arange(8) In [22]: z = x[:, None] + y[None, :] In [23]: spl = RectBivariateSpline(x, y, z) In [24]: spl(x, y, grid=False, dx=1) # Notice the dx argument. Out[24]: array([ 1., 1., 1., 1., 1., 1., 1., 1.]) HTH, Evgeni On Sun, Nov 22, 2015 at 9:21 PM, Delaram Ghoreishi <delaramq@gmail.com> wrote:
Hi. I need to find partial derivatives of 2d interpolation using RectBivariateSpline.__call__ from scipy. This is the code that I have so far:
import numpy as np from scipy import interpolate xm = np.arange(-180.,182.,2) #rank-1 array length 181 ym = np.arange(-180.,182.,2) #rank-1 array length 181 zm = np.loadtxt('data.dat', dtype = np.double) #rank-2 array length (181x181) V = interpolate.RectBivariateSpline(xm, ym, zm, s=0)
this code works fine when I need to know the value of the interpolated function at a given point, now how should I proceed from here to also find the derivatives at any specific point.
Thanks a lot for the help.
-- Delaram Ghoreishi Ph.D. Student Department of Physics University of Florida P.O. Box 118440 Gainesville, Florida 32611
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
Hello Evgeni, I tried what you told me to do (copy and pasted your code basically) but I got this error: __call__() got an unexpected keyword argument 'grid' I have no idea what's wrong here. I appreciate your help a lot. On Sun, Nov 22, 2015 at 6:18 PM, Evgeni Burovski <evgeny.burovskiy@gmail.com
wrote:
In [20]: x = np.arange(8)
In [21]: y = np.arange(8)
In [22]: z = x[:, None] + y[None, :]
In [23]: spl = RectBivariateSpline(x, y, z)
In [24]: spl(x, y, grid=False, dx=1) # Notice the dx argument. Out[24]: array([ 1., 1., 1., 1., 1., 1., 1., 1.])
HTH,
Evgeni
On Sun, Nov 22, 2015 at 9:21 PM, Delaram Ghoreishi <delaramq@gmail.com> wrote:
Hi. I need to find partial derivatives of 2d interpolation using RectBivariateSpline.__call__ from scipy. This is the code that I have so far:
import numpy as np from scipy import interpolate xm = np.arange(-180.,182.,2) #rank-1 array length 181 ym = np.arange(-180.,182.,2) #rank-1 array length 181 zm = np.loadtxt('data.dat', dtype = np.double) #rank-2 array length (181x181) V = interpolate.RectBivariateSpline(xm, ym, zm, s=0)
this code works fine when I need to know the value of the interpolated function at a given point, now how should I proceed from here to also find the derivatives at any specific point.
Thanks a lot for the help.
-- Delaram Ghoreishi Ph.D. Student Department of Physics University of Florida P.O. Box 118440 Gainesville, Florida 32611
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org https://mail.scipy.org/mailman/listinfo/scipy-user
-- Delaram Ghoreishi Ph.D. Student Department of Physics University of Florida P.O. Box 118440 Gainesville, Florida 32611
participants (2)
-
Delaram Ghoreishi -
Evgeni Burovski