MemoryError: Unable to allocate 3.60 GiB for an array with shape (280000, 1728) and data type float64 #191
-
Hi, i I would like to use kriging to interpolate station data to grid, following the code 00_ordinary.py in example directory, i made my code under windows, as follows: import numpy as np
import pykrige.kriging_tools as kt
from pykrige.ok import OrdinaryKriging
import matplotlib.pyplot as plt
filename=r'D:\workspace\pyb\interp\data.xlsx'
df=pd.read_excel(filename,header=None, names = ['lat','lon','data'] )
lon=df['lon']
lat=df['lat']
PM=df['data']
olon=np.linspace(70,140,700)
olat=np.linspace(15,55,400)
OK = OrdinaryKriging(
lon,
lat,
PM,
variogram_model="linear",
verbose=False,
enable_plotting=False,
)
z, ss = OK.execute("grid", olon, olat) but some error occurred when run the last line: File "<stdin>", line 1, in <module>
File "C:\Users\Administrator\anaconda3\lib\site-packages\pykrige\ok.py", line 985, in execute
zvalues, sigmasq = self._exec_vector(a, bd, mask)
File "C:\Users\Administrator\anaconda3\lib\site-packages\pykrige\ok.py", line 656, in _exec_vector
b[:, :n, 0] = -self.variogram_function(self.variogram_model_parameters, bd)
File "C:\Users\Administrator\anaconda3\lib\site-packages\pykrige\variogram_models.py", line 29, in linear_variogram_model
return slope * d + nugget
MemoryError: Unable to allocate 3.60 GiB for an array with shape (280000, 1728) and data type float64 it seems that the computer memory resulted in this error, so i try at another computer to run this code, the same error info showed, i don't know how to correct this problem. any help will be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You could try to use smaller chunks for olon = np.linspace(70,140,700)
olon1 = olon[0:100]
olon2 = olon[100:200]
olon3 = olon[200:300]
...
z1, ss1 = OK.execute("grid", olon1, olat)
z2, ss2 = OK.execute("grid", olon2, olat)
z3, ss3 = OK.execute("grid", olon3, olat)
... And then you can merge the fields You could also use the GSTools kriging routines, which provide a separate argument for chunking because of your exact problem: Does this help? |
Beta Was this translation helpful? Give feedback.
You could try to use smaller chunks for
olon
for example:And then you can merge the fields
z1,z2,...
back together.You could also use the GSTools kriging routines, which provide a separate argument for chunking because of your exact problem:
https://geostat-framework.readthedocs.io/projects/gstools/en/stable/generated/gstools.krige.Ordinary.html#gstools.krige.Ordinary.__call__
Does this help?
Cheers, Sebastian