# Gauges¶

With AMRClaw in two space dimensions and GeoClaw it is possible to specify gauge locations as points (x,y) where the values of all components of q should be output every time step during the computation over some time range (t1,t2).

Still need to add to 3d AMRClaw code, and to Classic codes.

Gauges are useful in several ways, e.g.:

1. To compare computational results to measurements from physical gauges such as a pressure gauge or tide gauge that record data as a function of time at a single point,

2. To better visualize how the solution behaves at a single point,

3. To better compare results obtained with different methods or grid resolutions. Comparing two-dimensional pcolor or contour plots can be difficult whereas comparing to curves that give the solution as a function of time often reveals more clearly differences in accuracy or nonphysical oscillations.

## Gauge parameters in setrun¶

Gauges are specified in setrun by adding lists of gauge data for each desired gauge to the ClawRunData object rundata.gaugedata.gauges. This is initialized as an empty list and new gauges can be specified by:

rundata.gaugedata.gauges.append([gaugeno, x, y, t1, t2])


with values

• gaugeno : integer

the number of this gauge

• x, y : floats

the location of this gauge

• t1, t2 : floats

the time interval over which gauge data should be output.

During the computation the value of all components of q at all gauge locations will be output to a single file fort.gauge in the output directory. Lines of this file have the form:

gaugeno  level  t  q[0]  q[1] ...  q[meqn-1]


where level is the AMR level used to determine the q values at this time. Internally the finest level available at each gauge is used, with bilinear interpolation to the gauge locations from the 4 nearest cell centers.

If you wish to change what is output at these points, you should copy the library routine dumpgauge.f to your own directory and modify it appropriately.

Warning

When doing a restart, previous gauge output is deleted unless you are careful to preserve it. See Output files after a restart.

## Plotting tools¶

Several Python plotting tools are available to plot the gauge data, so you do not have to parse the file fort.gauge yourself.

If you want to read in the data for a particular gauge to manipulate it yourself, you can do, for example:

from clawpack.visclaw.data import ClawPlotData
plotdata = ClawPlotData()
plotdata.outdir = '_output'   # set to the proper output directory
gaugeno = 1                   # gauge number to examine
g = plotdata.getgauge(gaugeno)


Then:

• g.t is the array of times,

• g.q is the array of values recorded at the gauges (g.q[m,n] is the mth variable at time t[n])

In the setplot Python script you can specify plots that are to be done for each gauge, similar to the manner in which you can specify plots that are to be done for each time frame. For example, to plot the component q[0] at each gauge, include in setplot lines of this form:

plotfigure = plotdata.new_plotfigure(name='q[0] at gauges', figno=300, \
type='each_gauge')

# Set up for axes in this figure:
plotaxes = plotfigure.new_plotaxes()
plotaxes.xlimits = 'auto'
plotaxes.ylimits = [-1.5, 1.5]
plotaxes.title = 'q[0]'

# Plot q[0] as blue line:
plotitem = plotaxes.new_plotitem(plot_type='1d_plot')
plotitem.plot_var = 0
plotitem.plotstyle = 'b-'


Note that plotdata.new_plotfigure is called with type=’each_gauge’ which denotes that this plot is to be produced for each gauge found in setgauges.data. (When type is not specified, the default is type=’each_frame’ for time frame data).

If you type: