2013-03-20 73 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是您的理想大小的方形這樣的事情。