回答したすべての方に感謝します。
私は
downshiftのアドバイスに従って、彼が提供するリンク...
に見て、思い付いたfolowing:
nLayers=<Number of layers in program output>
nRows=<Number of rows in layer>
nCols=<Number of columns in layer>
nBytes=<Number of bytes for each value>
noDataValue=<Value used to code no data in program output>
DataType=<appropriate numpy data type for values>
perLayer=nRows*nCols*nBytes
proc = sp.Popen(cmd+args, stdout = sp.PIPE, shell=True)
data=bytearray()
for i in range(0,nLayers):
dump40=proc.stdout.read(40)
data=data+bytearray(proc.stdout.read(perLayer))
ndata = np.frombuffer(data, dtype=DataType)
ndata[ndata == noDataValue]=np.nan
ndata.shape = (nLayers,nRows,nCols)
ここで同じ読み取りを使用していますnumpy.frombuffer
を使用しているキーバッファを使用してダーレを作成し、メモリ内のデータを複製する必要がなくなります。
[このようなバイナリデータをtmpストレージのないnumpy配列にパイプする方法は?](http://stackoverflow.com/questions/13059444/how-to-pipe-binary-data-into-numpy-arrays-without -tmp-storage) – davedwards
どのようなオペレーティングシステムを使用していますか? – DyZ