2017-04-25 52 views
0

我已經給出了一個巨大的9GB二進制數據文件(格式爲'%float%float'),並且gnuplot 5.0在嘗試讀取整個事物時變得肚子痛。限制巨大二進制數據文件的gnuplot圖

如何制定繪圖命令來限制繪圖,使其只讀取1K或2K左右的二進制數據文件?

回答

1

你可以使用的gnuplot的every關鍵字,例如繪製第2000條記錄:

plot 'file.dat' binary format='%float%float' every ::::2000 using 1:2 with lines; 

但似乎在讀取整個文件,然後地塊只有第2000條記錄,這可能不是你想要什麼。所以,你可能需要使用外部工具,如:

plot "<(head --bytes 16000 file.dat)" binary format='%float%float' using 1:2 with lines 

例如這個玩具的測試工作對我來說:

perl -e 'for ($i=0; $i < 21; $i++) { print pack "ff", $i, $i*$i }' > squares.dat 
gnuplot -e "set terminal png;set out 'only5squares.png';plot '<(head --bytes 40 squares.dat)' binary format='%float%float' using 1:2 with lines;" 

enter image description here

+0

是的,你的第一個建議並在整個數據讀取文件。第二個結果是gnuplot警告:跳過沒有有效點的數據文件。結果是空的情節。我不確定gnuplot在二進制數據時是否知道「記錄」的概念? – tansvaal

+0

嗯,一個玩具的例子(我編輯答案來添加它)爲gnuplot 5.0工作。 – MassPikeMike

+0

還有其他一些關鍵字可以和'binary'一起使用,它可以修改gnuplot的「記錄」的概念,但是像'filetype'和'array',以防你使用其中的一種。 – MassPikeMike