Calculate statistics for a cellSet with swak4Foam
I have a cellSet that I wan't to perform some simple statistics on (as post not while the calculation is running), e.g. compute the mean and standard deviation of temperature on a set of cells. I'd rather do this with an OF'ish tool as my experiences haven't been too positive with Paraview in this regard. Also this something I'd like to automated so OF lends itself to this well.
It seems swak4Foam - with funkyDoCalc or possible the new funkyPythonPostProc - should do the trick but not quite sure how to do this. I suppose this is question is for you Bernhard - just a gentle nudging in the right direction would be helpful. Thanks, Chris |
Quote:
The absolutely easiest thing would be a new utility Code:
fieldReport T -doSets -time 0: -nrOfQuantiles 4 -distributionDirectory TDistributions -csvName Tdata.csv What it doesn't do is calculate the standard-deviation. Instead with the nrOfQuantiles 4 it calculates the values for which 25%, 50% (==Median) and 75% of the values are smaller (further discussion of the feature see below). That utility is fine if you only need single numbers and want to post-process them yourself. And it might give you more numbers than you wanted (BTW: most numbers come in two variations. Unweighted or weighted - in this case with the cell size) With funkyDoCalc you only get the numbers you asked for and you are more flexible. In the simplest case you write something like this in a dictionary (I'm doing this from memory so some keywords might be wrong - I only write this stuff. This doesn't mean that I know how to use it) Code:
THeater { Code:
THeaterDev { |
Bernard,
Good thing all I asked for was a "nudging" ... wow! Thanks for the super detailed reply. fieldReports will get me what I want right now and I'll migrate to using funkyDoCalc for future calculations. funkyPythonPostProc looks beautiful. Had I known about it before I could have used it on a project I just finished up where I was doing some non-linear LSQ regressions using lmfit (which uses scipy.optimize.leastsq under the hood). I think it might have saved me the pain of using Paraview to strip away the regions of interest. -Chris |
Quote:
Quote:
But feel free to experiment. I'd appreciate any feedback before roling it into a release |
Quote:
Code:
--> FOAM Warning : -Chris |
Quote:
But if you set Code:
interactiveAfterExecute true; Code:
import sys Also make sure that the libraries you set with the SWAK_PYTHON_LINK-variable in swakConfiguaration point to the "right" libs (I don't know a sure-fire recipe to find that out). My suspicion is that the linked python is not the same Python that the libs are installed for (if you can't import sys then we're in deep trouble. But I'm confident. After rlcompleter the code imports readline and THAT seems to work - or you didn't bother me with that warning) |
Quote:
Quote:
Code:
>>> import sys Code:
>>> import sys Quote:
|
Good news (or probably bad): you're not alone
Quote:
Quote:
Quote:
Quote:
The thing is: exactly the same thing happens to me on my CentOS-machine. The story is the following: usually I develop new stuff on my MacBook (where Python and all are shiny and new). Additionally I test it on a virtual Ubüntü-machine. And when all is stable I test it on the Workstation in the office (with the conservative but stable CentOSG). I DID test a previous version on the CentOS machines. I somehow fixed that problem but it seems the intermediate updates have broken it again. The problem is that the old IPython on RHEL-machines behaves a bit differently from the current one (I'm not sure. But the thing is that IPython is rather terminal-oriented and the old version doesn'T seem to like it if initialized with no terminal in sight. Fun fact: if you set 'useIPython false;' then rlcompleter seems to import without problems. If you then do 'import IPython' on the embedded Python-shell you get a different error message) I'll look into this. But don't expect a solution this week. Sorry |
Quote:
Quote:
Quote:
fieldReports and funkyDoCalc is more than meeting my needs for now. Looking into parameterizing their usage in a python script with PyFoam. Quick question in that regard, using the funky* expressions (or any other method), is there a way to query the number of cells in the internalField, boundaryField, or cell set? Thanks again, Chris |
Quote:
Quote:
Quote:
Just discovered during writing: I recently implemented it in the accumulators (size) but it is not available in expressions. fieldReport prints it automatically |
Quote:
Anyway: what doesn't work in old IPython is tab-completion (in new one it does). This seems to be a common problem: Although tab-completion is configured in the embeded standard-shell it doesn't work there either (although it does the same things that make it work in a non-embedded python-shell). So: tab-completion only in new IPython |
I updated and rebuilt. Running the tutorial drops me into an iPython shell successfully.
However when I list the variables with "whos" it reports "Interactive namespace is empty". A quick search on stackoverflow suggests iPython needs to be invoked with -i parameter. |
Quote:
I'm quite surprised that %whos lists the variables with a new IPython (As I understand it %whos only shows the variables that were interactively defined on the shell and all these variables were injected not from the shell). And with the old IPython this is not the case? (currently got no possibility to test it with an old one) |
All times are GMT -4. The time now is 20:22. |