이것은 pytables로 할 수있는 방법입니다. 나는 네가 참을성이 있고 많은 공간을 가지길 희망한다.
import tables as tb
import numpy as np
import time
f = tb.openFile('humongusFile.h5', 'w')
n = 100000
x = f.createCArray(f.root, 'x', tb.Float16Atom(), (n,n), filters=tb.Filters(5, 'blosc'))
t0 = time.time()
for i in range(n):
x[i] = np.random.random_sample(n)* 10
x.flush() # dump data to disk
t1 = time.time()
print t1 - t0
print "Done creating test data"
y1 = f.createCArray(f.root, 'y1', tb.Float16Atom(), (n,n), filters=tb.Filters(5, 'blosc'))
y2 = f.createCArray(f.root, 'y2', tb.Float16Atom(), (n,n), filters=tb.Filters(5, 'blosc'))
t2 = time.time()
print t2 - t1
print "Done creating output array"
expr = tb.Expr("where((x >= 5.23) & (x < 8.55), x, 0)")
expr.setOutput(y1)
expr2 = tb.Expr("where((x >= 5.23) & (x < 8.55), x, 0)")
expr2.setOutput(y2)
t3 = time.time()
print t3 - t2
print "Starting evaluating first output"
expr.eval()
print "Starting evaluating second output"
expr2.eval()
print "Done"
t4 = time.time()
print t4 - t3
문제가 메모리 일 때 제목 속도는 왜입니까? – cyborg
1e6 x 1e6 항목의 배열에는 1 조 (1e12) 개의 항목이 있습니다. 하나의 항목 당 하나의 비트를 저장했다 할지라도, 단순히 'raster_data' 배열을 저장하기 위해 125 GB가 필요합니다 ** 단 정밀도 부동 소수점을 사용하면 4 TB의 메모리가 필요합니다 ... – Jaime
대답은 당신이 가고있는 것에 달려 있습니다 클래스와 관련된 작업, 클래스에있는 요소 수 (희소 행렬) 및 데이터 저장 방법에 대해 설명합니다. – cyborg