2017-04-25 88 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