Plot Data from Probes
Hallo,
My question might sound a little bit simple and old. But I am gonna ask it any for. :) I have a transient simulation, with many probes in my flow domain. I want to plot the probes data. The format of the file for the probed fields doesn't seem plotable to me (atleast with the software I know). I want to plot some points over time. Is there any simple, elegant, easy and time saving way to do it? Or do I have to right my own utility to get individual points data out of that file. Regards, Awais |
Quote:
Another option would be to write a small script in the scripting language of your choice that transforms the file into a CSV-file (basically replace groups of spaces with a comma) which you can open with a lot of programs (including Excel and OpenOffice) I (but I'm biased) prefer pyFoamTimelinePlot from the PyFoam-utilities. For instance pyFoamTimelinePlot.py . --value=T --dir=probes --basic-mode=line prints the Gnuplot-commands to plot the temperature on all probe locations to the terminal, so pyFoamTimelinePlot.py . --value=T --dir=probes --basic-mode=line | gnuplot generates a PNG with that plot pyFoamTimelinePlot.py . --value=T --dir=probes --basic-mode=line --csv=temperature.csv writes a CSV-file with all the temperatures. |
Thanks for your help and I can understand why you are biased. :)
Indeed pyFoam sounds a combination of handy utilities. But I have an error while using the utility you have just mentioned. When I use it, it says: "Traceback (most recent call last): File "/usr/local/bin/pyFoamTimelinePlot.py", line 3, in <module> from PyFoam.Applications.TimelinePlot import TimelinePlot File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/TimelinePlot.py", line 11, in <module> from PyFoam.RunDictionary.TimelineDirectory import TimelineDirectory File "/usr/local/lib/python2.6/dist-packages/PyFoam/RunDictionary/TimelineDirectory.py", line 11, in <module> from PyFoam.Basics.SpreadsheetData import SpreadsheetData File "/usr/local/lib/python2.6/dist-packages/PyFoam/Basics/SpreadsheetData.py", line 6, in <module> import numpy,copy ImportError: No module named numpy " I hope that you will help me again and I really appreciate it. Thanks and Regards, Awais |
The last line provides a good clue. You are missing the NumPy package for python: http://numpy.scipy.org/
|
Quote:
|
Well I have seen the pre-requisites on the wiki page. And only Python is mentioned as a pre-requisite.
I have also installed numpy and now I have this error. "Traceback (most recent call last): File "/usr/local/bin/pyFoamTimelinePlot.py", line 5, in <module> TimelinePlot() File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/TimelinePlot.py", line 32, in __init__ interspersed=True) File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/PyFoamApplication.py", line 155, in __init__ result=self.run() File "/usr/local/lib/python2.6/dist-packages/PyFoam/Applications/TimelinePlot.py", line 403, in run spread=plots[0][-1]() File "/usr/local/lib/python2.6/dist-packages/PyFoam/RunDictionary/TimelineDirectory.py", line 317, in __call__ title="%s_t=%s" % (self.val,self.time)) File "/usr/local/lib/python2.6/dist-packages/PyFoam/Basics/SpreadsheetData.py", line 66, in __init__ self.data=numpy.array(map(tuple,data),dtype=zip(na mes,['f8']*len(names))) TypeError: expected a readable buffer object " Thanks for your quick response again, Awais |
Quote:
Quote:
If I can't figure it out from that information I'll have to ask you to report it on the Mantis of openfoam-extend and provide me some sample data (only the timeline-directory the rest of the case is unneeded) there |
Output from pyFoamVersion.py
" PYTHONPATH: not set OpenFOAM (1, 7, 1) of the installed versions ['171'] pyFoam-Version: 0.5.6 Configuration search path: [('file', '/etc/pyFoam/pyfoamrc'), ('directory', '/etc/pyFoam/pyfoamrc.d'), ('file', '/home/awais/.pyFoam/pyfoamrc'), ('directory', '/home/awais/.pyFoam/pyfoamrc.d')] Configuration files (used): [] Installed libraries: Gnuplot : No Not a problem. Version from ThirdParty is used ply : No Not a problem. Version from ThirdParty is used Numeric : No Not a problem if numpy is present numpy : Yes matplotlib : No Only Gnuplot-plotting possible psyco : No Not a problem. Acceleration not possible hotshot : Yes profile : No Not a problem. Can't profile using this library cProfile : Yes PyQt4 : Yes PyQt4.Qwt5 : No Only an alternate plotting back-end vtk : No Not a problem. Only used for some utilities Tkinter : No Not a problem. Used for the old version of DisplayBlockmesh and some matplotlib-implementations mercurial : No Not a problem. Used for experimental case handling " Plus I still can't see any change in prerequisites on Wiki page. May be I am looking at the wrong page. Could you provide me the link ? Regards, Awais |
Quote:
python -c "import numpy; print numpy.__version__" Quote:
http://openfoamwiki.net/index.php/Co...#Prerequisites |
1.3.0
Thats the output of the command you sent me. Regards, Awais |
Thanks It worked.
Dear Gschaider,
I tried it again and this time I was able to extract the data csv format. May be I was doing something wrong earlier.:o Thanks alot for your help. I really appreciate that. :) Regards, Awais |
Quote:
|
Sure I will do that.
But I would take this opportunity to tell you again, that its a perfect tool for me. I hope it will be useful for others as well. Keep up the good work and thanks. Awais |
How can I display the probes updated every time the file (of the probes) change?
Thanks. |
Quote:
I THINK (not sure): there is a way that involves gnuplot, the tail-command and a pipe. But I'm not totally sure |
Thanks gschaider for the tip. I'll post the reply when I reach it.
|
Hm, I keep getting some bug as well. My probes are in the postProcessing/probes1 directory
so I write pyFoamTimelinePlot.py . --dir=postProcessing/probes1/ --info and get Traceback (most recent call last): File "/usr/local/bin/pyFoamTimelinePlot.py", line 5, in <module> TimelinePlot() File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/TimelinePlot.py", line 31, in __init__ interspersed=True) File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/PyFoamApplication.py", line 309, in __init__ result=self.run() File "/usr/local/lib/python2.7/dist-packages/PyFoam/Applications/TimelinePlot.py", line 236, in run writeTime=self.opts.writeTime) File "/usr/local/lib/python2.7/dist-packages/PyFoam/RunDictionary/TimelineDirectory.py", line 66, in __init__ if TimelineValue(self.dir,v,self.usedTime).isVector: File "/usr/local/lib/python2.7/dist-packages/PyFoam/RunDictionary/TimelineDirectory.py", line 245, in __init__ self.positions.append(poses[i]) Any ideas anyone? |
Quote:
The problem with that class is that it tries to find out what kind of data is inside by looking at the filename and the number of columns in the file. Sometimes it gets thrown of the train. Especially with field names that have a _ Could you give me the filenames in the probes-directory and the first few lines of a file? |
Hi and thank you for the reply!
Here are the files postProcessing │** ├── probes1 │** │** └── 0 │** │** ├── k │** │** ├── nuSgs │** │** ├── p │** │** ├── pMean │** │** ├── pPrime2Mean │** │** ├── U │** │** ├── UMean │** │** └── UPrime2Mean I do have a whole bunch of probes, about 200. Here are the first lines in k, with most of the columns cut of # x 1.5 1.5 1.5 1.5 # y 0 0.1 0.2 0.3 # z 1.5 1.5 1.5 1.5 # Time 0.2 0.000119397 5.58722e-05 4.39089e-05 1.68841e-05 0.4 1.48173e-05 5.61585e-05 4.32905e-05 1.68423e-05 0.6 2.72097e-05 5.63581e-05 4.28651e-05 1.67996e-05 0.8 1.71347e-05 5.65558e-05 4.25659e-05 1.67494e-05 1 8.93701e-06 5.68052e-05 4.23349e-05 1.66891e-05 1.2 5.12171e-06 5.71486e-05 4.21242e-05 1.66199e-05 1.4 3.79153e-06 5.7625e-05 4.18843e-05 1.65415e-05 1.6 3.45644e-06 5.82698e-05 4.15752e-05 1.64632e-05 |
Quote:
BTW: is it sure that this is the file it chokes on? Could you check by (for instance) creating "probes2/0" copying one file over using pyFoamTimelinePlot.py on probes2 until it fails? Thanks |
Hi!
Have no idea why I didn't get that debugging idea, I guess the script fails on me totally or it works for everything. So it works on all fields but UPrime2Mean! It looks like this: # x 1.5 1.5 1.5 1.5 1.5 1.5 # y 0 0.1 0.2 0.3 0.4 0.5 # z 1.5 1.5 1.5 1.5 1.5 1.5 # Time 0.2 (0 0 0 0 0 0) (0 0 0 0 0 0) (0 0 0 0 0 0) 0.4 (2.7993e-08 -7.77667e-10 1.05859e-08 2.16042e-11 -2.94084e-10 4.00318e-09) 0.6 (3.17292e-08 -1.45928e-09 1.17226e-08 8.21429e-11 -5.31962e-10 4.33446e-09) 0.8 (2.85533e-08 -1.82099e-09 1.0425e-08 1.72582e-10 -6.48406e-10 3.81149e-09) 1 (2.40662e-08 -1.85896e-09 8.91598e-09 2.70264e-10 -7.08062e-10 3.32037e-09) 1.2 (2.01257e-08 -1.64986e-09 7.54823e-09 3.69006e-10 -7.58858e-10 2.96515e-09) |
Quote:
|
1 Attachment(s)
Quote:
Attachment 29552 |
Hi, I couldn't find a more relevant thread so I am reviving this one.
I am trying to use pyFoamTimelinePlot.py to plot values from probes but I can find NOTHING except for this thread to help me understand how to use it. First of all, here is my probeDict file: Code:
fields 1) This command DOES work: Code:
pyFoamTimelinePlot.py --fields=p_rgh --basic-mode=lines postProcessing/ | gnuplot 2) This command DID work but is now giving the error listed below: Code:
pyFoamTimelinePlot.py --fields=p_rgh --basic-mode=lines --csv-file=p_rgh.csv postProcessing/ Code:
Traceback (most recent call last): Therefore, I have two specific questions for plotting values at probes: 1) Is it possible to use pyFoamTimelinePlot to specify which probe to plot at? And how would I do this? 2) Has anyone had experience with the error above? I don't understand it at all because this was working for a different case and I can't see where I've gone differently. Any help or advice is much appreciated... I've been spending a loooooong time on this now and getting frustrated with the lack of documentation (aside from the code itself) |
All times are GMT -4. The time now is 23:45. |