![]() |
How to plot a forces.dat file (with all the brackets)?
The wall forces calculation method in the recent versions of OF work very nicely, but produce a file (by default called forces.dat) with a lot of brackets (or parentheses, if you speak that variant of English). A typical line in the file looks like this:
(((6.57 128.05 364.35) (34.46 2.43 4.29)) (( etc .....) (......) (......))) Now I really like to plot the force history as a means of judging convergence, but this format is not amenable to easy plotting with Gnuplot. One can obviously import into a spreadsheet, but that is mighty tedious. The question is this: Is there an easy way of telling Gnuplot to ignore the brackets, or is there another plotting program that can do it easily? I'm sure that one can give Gnuplot a "plot using " command that can deal with the format .... I just don't seem to get it right! Any advice? |
I plotted my stuff in Excel but only after I'd extracted and compiled all the data into one tab delimited file using a bash script. It's not too difficult. A few hours reading of bash scripting if you have no experience should be good enough.
|
Hello,
you could use "sed" to filter your gunplot input. Use following line in gnuplot (the input for gnuplot will be the output of sed): plot "< sed s/[\\(\\)]//g input.dat" using 1:2 Regards, Malte |
Thanks!
Great, thanks for that, it has got me going along the right lines!
|
Another solution is to use python to parse and plot, e.g.,
Code:
import reOf course, you need numpy and matplotlib loaded for the above example to work. I would also recommend using ipython as it permits an improved interactive environment. If you haven't studied regular-expressions (regex), I would recommend the python regex howto and the book by H.P. Langtangen, "Python Scripting for Computational Science." |
typos
I found some typos in the python code. The corrected code should be:
Code:
#!/usr/bin/python |
Quote:
|
| All times are GMT -4. The time now is 16:37. |