2013-03-20 115 views
0

我有一个二维CFD代码,它给出了网格上每个点的x和y流速。我目前使用gnuplot中的矢量字段来显示数据。我的目标是看看爆发的羽流扩展到多远,如果我能够防止矢量在低于一定的幅度时完全显示出来,那么它会更加干净。有没有人有一个想法如何去做这件事?下面是我现在的gnuplot脚本。我也可以根据需要修改输入文件。Gnuplot:如何从矢量场中删除一定数量级以下的矢量?

reset 
set nokey 
set term png 
set xrange [0:5.1] 
set yrange [0:10.1] 
do for [i=0:10] { 
    set title 'Eruption simulation: Timestep '.i 
    set output 'path/FlowVel'.sprintf('%04.0f',i).'.png' 
    plot 'path/Flow'.sprintf('%04.0f',i).'.dat' using 1:2:3:4 with vec 
} 

回答

0

我猜你想要一个类型的过滤,并不真正具有的gnuplot,但可以用下面的技巧(摘自“使用示例帮助”,在gnuplot的拍摄)来实现:

One trick is to use the ternary `?:` operator to filter data: 

     plot 'file' using 1:($3>10 ? $2 : 1/0) 

which plots the datum in column two against that in column one provided 
the datum in column three exceeds ten. `1/0` is undefined; `gnuplot` 
quietly ignores undefined points, so unsuitable points are suppressed. 
Or you can use the pre-defined variable NaN to achieve the same result. 

所以我想你想你的情况

plot "data.dat" u 1:2:($3**2+$4**2>mag_sq?$3:NaN):($3**2+$4**2>mag_sq?$4:NaN) w vector 

其中mag_sq是您的理想大小的方形这样的事情。