current_data¶
The Python plotting routines often allow the user to specify a call back function as plotting parameters, for example ClawPlotAxes has an attribute afteraxes that can be set to a function to be executed after performing all plots on the specified axes. This is useful for setting parameters for these axes that are not covered by the provided attributes, for annotating the plots on these axes, for adding a plot of the true solution, etc.
Call back functions include:
beforeframe and afterframe attributes of ClawPlotData
afteraxes attribute of ClawPlotAxes
afteritem, afterpatch, plot_var, map2d_to_1d attributes of ClawPlotItem
All of these functions are designed to take a single argument current_data, an object with attributes that may be useful to the user in evaluating the function.
Warning
The mapc2p function is one exception that does not take argument current_data.
Attributes of current_data:¶
Some of these may be unavailable because they don’t make sense in the current context, e.g. in a beforeframe function.
-
plotdata :
parent ClawPlotData object. From this object virtually any relevant data can be accessed. Other attributes are defined for convenience. If you find you frequently need something else, you could modify
pyclaw.plotters.frametools
to add this to current_data.
-
frameno :
The current frame number
-
patch :
Object of
pyclaw.solution.patch
with data for the last patch plotted.
-
patchno :
Grid number of this patch, of interest only in AMR calculations.
-
q :
q array for current frame, so for example the in a scalar 2d problem the value in the (i,j) cell would be current_data.q[0,i,j] (remember that Python always indexes starting at 0).
In an AMR calculation q will be from the last patch plotted.
-
aux :
aux array for current frame, provided these have been output by the Fortran code. At the moment this requires modifying the library routine outN.f to set outaux = .true. so that fort.a files are produced along with fort.q files. [This should be an input parameter!]
If fort.a files are not found then current_data.aux will be None.
In an AMR calculation aux will be from the last patch plotted.
-
var :
array of the variable actually plotted most recently, e.g. if plotitem.plot_var == 0 then in 2d current_data.var[i,j] == current_data.q[0,i,j].
-
level :
For AMR computations, where current_data.patch is for the last patch plotted, current_data.level is the AMR level of this patch. Particularly useful in afterpatch functions.
-
t :
the current time t.
-
x :
x array of cell centers corresponding to current_data.q.
-
y :
y array of cell centers corresponding to current_data.q (only in 2d).
-
xlower :
left edge of current patch.
-
ylower :
left edge of current patch in y (only in 2d).