-
Notifications
You must be signed in to change notification settings - Fork 119
Stat File and Utilities
The stat file contains diagnostics such as the max, min L2 norm and integral values of the fields. The information in the .stat file can be read into python with stat parser. It may be useful to use the interactive ipython shell when you first do this. To read in the information, type:
import fluidity_tools
stat = fluidity_tools.stat_parser("filename.stat")
You can find out which fields are contained in a state Fluid via:
stat["Fluid"].keys()
You can type
stat["Fluid"]["Velocity%magnitude"]
where Velocity%magnitude is one of the keys obtained above. This obtains all the values saved for velocity magnitude (usually max, min, L2 norm and integral). You can then select one of these:
stat["Fluid"]["Velocity%magnitude"]["max"]
The “max” statistics of a field “Velocity%magnitude” in this state can be plotted via the following python script:
from matplotlib import pylab
time = stat["ElapsedTime"]["value"]
max_speed = stat["Fluid"]["Velocity%magnitude"]["max"]
pylab.plot(time, max_speed)
pylab.xlabel("Time")
pylab.ylabel("Max Speed")
pylab.show()
Another example of a script that plots multiple values from different directories:
import pylab
import Numeric
import fluidity_tools
from numpy import shape
labels=["200km 1:1000","20km 1:100","2km 1:10", "200m 1:1" ]
dirs=["x-200km","x-20km", "x-2km", "x-200m"]
for i in range (0,4):
stat = fluidity_tools.stat_parser("../../"+(dirs[i])+"/unstruc-test/avlesen-diagnostic.steady_state")
w=stat["BoussinesqFluid"]["Velocity%3"]
t=stat["ElapsedTime"]
print "error in w for 200km", w["error"][len(w["error"])-1]
pylab.plot(t["value"],Numeric.log(w["error"]),label=labels[i])
pylab.ylabel("log (error in w)")
pylab.legend()
pylab.savefig("log_graph.png")
pylab.show()
Statplot is a python function in the tools directory. To use it type:
{FLUIDITY PATH}/tools/statplot file.stat
This allows you to plot the quantities saved in the stat file. Simply choose the quantities you wish to plot from the drop down menu.
Fluidity produces a .stat file as a run is progressing. It is possible to visualise this file using statplot. To do this, open the .stat file in statplot (the command line below assumes you are in a test, within the test directory)
../../tools/statplot foo.stat
This should produce a window like this:
Once statplot has loaded the window there are a number of options available, including
- Refreshing the plot
- Using a scatter plot, rather than line drawing
- Zooming in
- Changing the plot to a log plot
Refreshing the plot can be done by pressing "r" or "R". Using "R" will keep the current data bounds. The type of plot can be selected by using either "l" (lower-case L) for a line-plot or "s" for a scatter plot. Individual axes can be switched from linear to log scale (and back again) by pressing "x" or "y". Finally, you can quit statplot by pressing "q".
Each field recorded in the .stat file can be visualised by selecting the appropriate field from the right-hand drop-down list. For each field you will find a minimum, maximum, L2 norm and integral value. This selects which value is plotted on the y-axis. You can also change which variable is plotted on the x-axis by selecting a field form the left-hand drop-down list.
There are also controls to zoom in and out, pan and export the plot. The controls are highlighted on the figure below and are (from left to right): Reset view, return to previous view, go to next view, pan plot, zoom in, configure subplots (not relevant here) and save plot.


