CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Post-Processing

Plot Data from Probes

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   January 9, 2012, 22:01
Default Plot Data from Probes
  #1
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
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
owayz is offline   Reply With Quote

Old   January 10, 2012, 15:53
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by owayz View Post
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
The file format is immediately plotable with Gnuplot (a program that should be on every engineering workstation). It is a bit strange in the beginning because it is driven by a command line, but the advantage of this is that you can easily prepare scripts that automatically generate the pictures you want.

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.
Jonathan, sbusmayer and Uyan like this.
gschaider is offline   Reply With Quote

Old   January 10, 2012, 21:47
Default
  #3
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
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
owayz is offline   Reply With Quote

Old   January 11, 2012, 03:00
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
The last line provides a good clue. You are missing the NumPy package for python: http://numpy.scipy.org/
Bernhard is offline   Reply With Quote

Old   January 11, 2012, 06:07
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by owayz View Post
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
Some of the utilities need the numpy-library (basically the "standard"-library for matrix-computations in Python). You'll have to install it (as pointed out in the other posting). Have a look what the package-manager of your distro provides and go with that. I've added a prerequisites-note to the Wiki-page
gschaider is offline   Reply With Quote

Old   January 11, 2012, 19:26
Default
  #6
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
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
owayz is offline   Reply With Quote

Old   January 12, 2012, 05:49
Default
  #7
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by owayz View Post
Well I have seen the pre-requisites on the wiki page. And only Python is mentioned as a pre-requisite.
That's why I modified it yesterday.

Quote:
Originally Posted by owayz View Post
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
That's a weird one (havn't seen this and I use the command all the time). Could you provide me with the numpy-version (pyFoamVersion.py should print it) you're using and the command line you use.

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
gschaider is offline   Reply With Quote

Old   January 13, 2012, 06:54
Default
  #8
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
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
owayz is offline   Reply With Quote

Old   January 14, 2012, 07:15
Default
  #9
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by owayz View Post
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
I see. The released version doesn't yet have the feature "also print the version number" ... next release. Anyway. Could you provide me with the output of

python -c "import numpy; print numpy.__version__"


Quote:
Originally Posted by owayz View Post
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 ?
Here you are:
http://openfoamwiki.net/index.php/Co...#Prerequisites
gschaider is offline   Reply With Quote

Old   January 15, 2012, 17:23
Default
  #10
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
1.3.0

Thats the output of the command you sent me.

Regards,
Awais
owayz is offline   Reply With Quote

Old   January 15, 2012, 19:45
Default Thanks It worked.
  #11
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
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.
Thanks alot for your help.
I really appreciate that.

Regards,
Awais
owayz is offline   Reply With Quote

Old   January 16, 2012, 06:31
Default
  #12
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by owayz View Post
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.
Thanks alot for your help.
I really appreciate that.

Regards,
Awais
Should you be able to reproduce the behaviour it'd be nice if you let me know (Mantis-Bugreport preferred) so that I can at least catch the user-error in a way that gives a less obscure error message
gschaider is offline   Reply With Quote

Old   January 16, 2012, 15:45
Default
  #13
Senior Member
 
Awais Ali
Join Date: Feb 2010
Location: Germany
Posts: 125
Rep Power: 8
owayz is on a distinguished road
Send a message via MSN to owayz
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
owayz is offline   Reply With Quote

Old   January 17, 2012, 12:52
Default
  #14
Member
 
Join Date: Apr 2010
Posts: 61
Rep Power: 7
alquimista is on a distinguished road
How can I display the probes updated every time the file (of the probes) change?

Thanks.
alquimista is offline   Reply With Quote

Old   January 17, 2012, 13:48
Default
  #15
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by alquimista View Post
How can I display the probes updated every time the file (of the probes) change?
With pyFoam: you can't (I thought about it once but it wasn't that important to me and I never found the time)

I THINK (not sure): there is a way that involves gnuplot, the tail-command and a pipe. But I'm not totally sure
gschaider is offline   Reply With Quote

Old   January 17, 2012, 14:06
Default
  #16
Member
 
Join Date: Apr 2010
Posts: 61
Rep Power: 7
alquimista is on a distinguished road
Thanks gschaider for the tip. I'll post the reply when I reach it.
alquimista is offline   Reply With Quote

Old   March 17, 2014, 13:32
Default
  #17
New Member
 
Timofey Mukha
Join Date: Mar 2012
Location: Göteborg, Sweden
Posts: 27
Rep Power: 5
tiam is on a distinguished road
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?
tiam is offline   Reply With Quote

Old   March 19, 2014, 19:28
Default
  #18
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by tiam View Post
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?
No.

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?
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   March 20, 2014, 08:11
Default
  #19
New Member
 
Timofey Mukha
Join Date: Mar 2012
Location: Göteborg, Sweden
Posts: 27
Rep Power: 5
tiam is on a distinguished road
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
tiam is offline   Reply With Quote

Old   March 20, 2014, 15:43
Default
  #20
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by tiam View Post
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
Can't try it right now, but it seems that the "# Time" line catches the program by surprise. It is possible that it wasn't there in old OF-versions (and this code was written aaaages ago)

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
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to plot the data made by java? jelon STAR-CCM+ 2 April 11, 2010 06:00
How to save 2-D data in contour plot mssound FLUENT 0 February 15, 2010 15:01
How to create an contour plot for arbitrary plane with interpolated data navaladi OpenFOAM Paraview & paraFoam 0 June 4, 2008 07:57
xy data from graph plot to excel Radhika CD-adapco 5 February 23, 2007 08:23
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 18:27


All times are GMT -4. The time now is 23:27.