<p>I have 3 arrays, for longitude, latitude and temperature (so the observations are scattered in space). I want to apply interpolation on these data, but also extrapolation. I 've written the code beow, but I get an error about memory. Each of the three arrays has about 700 points.</p>

<p>The reason that I want to extrapolate is because i want to cover all of the region of the map.</p>

<p>This is the part of my code, which is about what I described:</p>

<pre><code>m = Basemap(projection='merc',llcrnrlat=34,urcrnrlat=42,\
        llcrnrlon=19,urcrnrlon=35,lat_ts=20,resolution='h')

xi = np.arange(19,35,0.01)

yi = np.arange(34,42,0.01)

xi,yi = np.meshgrid(xi,yi)

lon = np.asarray(lon)

lat = np.asarray(lat)

temperature = np.asarray(temperature)

rbf = scipy.interpolate.Rbf(lon, lat, temperature, function='gaussian', smooth=0.)

zi = rbf(xi, yi)

x,y = m(xi, yi)

zi=np.array(zi)

mdata=maskoceans(xi,yi,zi,resolution='f',grid=1.25)

m.drawcoastlines()

m.drawcountries()

m.drawmapboundary(fill_color="#cce6ff")

sc = m.contourf(x,y,mdata, np.arange(-15.0,40.01,1),cmap=jet,extend="both")
</code></pre>

<p>Does anyone have any ideas about the interpolation methods that I should use and how I could make it work?</p>

<p>I've already used griddata, which works fine, but it is just for interpolation, so the new matrix is limited and it doesn't cover the whole area. I've also read that rbf doesn't work for more than 20 points, but is there any other method for large datasets?</p>

CC BY-SA 3.0
2017-09-25T21:49:26.717Z
Unfortunately, this didn't work properly. The map appeared with very weird and extreme values. For the rest of the methods I got a "singleton error". Any other suggestions?
Stavros Keppas
<meteorology><temperature><python>
Interpolation and extrapolation of unstructured data in python: memory error
Stavros Keppas
# Interpolation and extrapolation of unstructured data in python: memory error

(Asked by: username_0 on 2017-08-31)

I have 3 arrays, for longitude, latitude and temperature (so the observations are scattered in space). I want to apply interpolation on these data, but also extrapolation. I 've written the code beow, but I get an error about memory. Each of the three arrays has about 700 points.
The reason that I want to extrapolate is because i want to cover all of the region of the map.
This is the part of my code, which is about what I described:
m = Basemap(projection='merc',llcrnrlat=34,urcrnrlat=42,\
        llcrnrlon=19,urcrnrlon=35,lat_ts=20,resolution='h')

xi = np.arange(19,35,0.01)

yi = np.arange(34,42,0.01)

xi,yi = np.meshgrid(xi,yi)

lon = np.asarray(lon)

lat = np.asarray(lat)

temperature = np.asarray(temperature)

rbf = scipy.interpolate.Rbf(lon, lat, temperature, function='gaussian', smooth=0.)

zi = rbf(xi, yi)

x,y = m(xi, yi)

zi=np.array(zi)

mdata=maskoceans(xi,yi,zi,resolution='f',grid=1.25)

m.drawcoastlines()

m.drawcountries()

m.drawmapboundary(fill_color="#cce6ff")

sc = m.contourf(x,y,mdata, np.arange(-15.0,40.01,1),cmap=jet,extend="both")

Does anyone have any ideas about the interpolation methods that I should use and how I could make it work?
I've already used griddata, which works fine, but it is just for interpolation, so the new matrix is limited and it doesn't cover the whole area. I've also read that rbf doesn't work for more than 20 points, but is there any other method for large datasets?

**Tags:** meteorology, temperature, python

> **Comments:**
> **username_0**: Unfortunately, this didn't work properly. The map appeared with very weird and extreme values. For the rest of the methods I got a "singleton error". Any other suggestions?  

---

## 0 answers

