[SciPy-User] Memory error with scipy.interpolate

ashwinD12 . winash12 at gmail.com
Wed Jul 20 11:33:44 EDT 2016


>From this old thread -
https://mail.scipy.org/pipermail/scipy-user/2009-April/020607.html

it appears that Scipy.Rbf has a limitation with number of points. If so
what is the alternative to doing an interpolation so I can do a contour
plot ?


On Wed, Jul 20, 2016 at 12:13 PM, ashwinD12 . <winash12 at gmail.com> wrote:

> Hello,
>          I get a memory error when I interpolate a data set of 567 points
> as shown in this stack trace
>
> Traceback (most recent call last):
>  File "contour.py", line 34, in <module>
>  rbf = scipy.interpolate.Rbf(x, y, data, function='linear')
>  File "/usr/local/lib/python3.4/dist-packages/scipy/interpolate/rbf.py", line 200, in __init__
>  r = self._call_norm(self.xi, self.xi)
>  File "/usr/local/lib/python3.4/dist-packages/scipy/interpolate/rbf.py", line 231, in _call_norm
>  return self.norm(x1, x2)
>  File "/usr/local/lib/python3.4/dist-packages/scipy/interpolate/rbf.py", line 118, in _euclidean_norm
>  return np.sqrt(((x1 - x2)**2).sum(axis=0))
>  MemoryError
>
> With numpy earlier I had gotten the same error and I had moved past it
>
> by this option -
> lon,lat = np.meshgrid(lon, lat,sparse=True,copy=False)
>
> This is the minimum code snippet that should reproduce the problem
> grbs = pygrib.open('20000')
>
>
> grb = grbs.select(name='Geopotential',level=500)[0]
> data = grb.values
>
> hgt = [x/10 for x in data]
> lat,lon = grb.latlons()
>
> lon,lat = np.meshgrid(lon, lat,sparse=True,copy=False)
>
> m=Basemap(projection='mill',lat_ts=10,llcrnrlon=lon.min(), \
> urcrnrlon=lon.max(),llcrnrlat=lat.min(),urcrnrlat=lat.max(), \
>       resolution=None)
>
>
> x,y = m(lon,lat)
>
> rbf = scipy.interpolate.Rbf(x, y, data, function='linear')
> zi = rbf(x, y)
>
> Regards,
>
> Ashwin.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20160720/4c25074d/attachment.html>


More information about the SciPy-User mailing list