MemoryError when starting Numpy Meshgrid

I have 8823 data points with x, y coordinates. I am trying to fulfill the answer on how to get a scatter dataset that will be presented as a heat map , but when I go through

X, Y = np.meshgrid(x, y)

with my datasets I get MemoryError. I am new to numpy and matplotlib and essentially try to run this by adapting examples that I can find.

This is how I built my arrays from the file in which they are stored:

XY_File = open ('XY_Output.txt', 'r')
XY = XY_File.readlines()
XY_File.close()

Xf=[]
Yf=[]
for line in XY:
    Xf.append(float(line.split('\t')[0]))
    Yf.append(float(line.split('\t')[1]))
x=array(Xf)
y=array(Yf)

Is there a problem with my arrays? The same code worked when it was placed in this example , but I'm not sure.

Why am I getting this MemoryError and how can I fix it?

+2
2

meshgrid - 8823 * 8823. 0,6 .

( ) , , , , - , 1024 * 1024, .

+5

numpy 1.7.0, meshgrid sparse. meshgrid , meshgrid . , . meshgrid .

In [2]: np.meshgrid(np.arange(10), np.arange(10), sparse=True)
Out[2]: 
[array([[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]), array([[0],
    [1],
    [2],
    [3],
    [4],
    [5],
    [6],
    [7],
    [8],
    [9]])]

- , :

np.meshgrid(np.arange(10).astype(np.int8), np.arange(10).astype(np.int8),
            sparse=True, copy=False)

numpy 1.9 , (np.setbufsize ) .

+1

Source: https://habr.com/ru/post/1779875/


All Articles