Plot fgmax results¶
This notebook shows a simple example of how to load fgmax results (the maximum value over the entire simulation at specified fixed grid points) and plot the maximum flow depth.
For more details, see https://www.clawpack.org/fgmax.html
In [1]:
%matplotlib inline
In [2]:
from pylab import *
import os
In [3]:
from clawpack.geoclaw import fgmax_tools
from clawpack.visclaw import geoplot
In [4]:
outdir = '_output_flood'
In [5]:
fg = fgmax_tools.FGmaxGrid()
fg.outdir = outdir
data_file = os.path.join(outdir, 'fgmax_grids.data')
fg.read_fgmax_grids_data(fgno=1, data_file=data_file)
fg.read_output()
Reading input for fgno=1, point_style = 2 Reading _output_flood/fgmax0001.txt ...
In [6]:
figure(figsize=(8,5))
# plot dry land where fgmax captured as green:
topo_dry = where(fg.h < 0.01, fg.B, nan)
contourf(fg.X, fg.Y, topo_dry, [0,100], colors=['g'])
clines_h = [0.01] + list(arange(0.5,5,0.5)) # contour levels for depth
colors = geoplot.discrete_cmap_1(clines_h)
h_onshore = where(fg.B>0, fg.h, nan)
contourf(fg.X, fg.Y, h_onshore, clines_h, colors=colors)
colorbar()
contour(fg.X, fg.Y, fg.B,[0.], colors='k') # shore
# fix axes:
ticklabel_format(useOffset=False)
xticks(rotation=20)
gca().set_aspect(1./cos(fg.Y.mean()*pi/180.)) # proper aspect ratio at this latitude
title('Maximum flow depth where B>0');
In the plot above, note that the river is white because B<0
, the dark green areas are where fgmax data was collected but the land remained dry, and the other white areas are where no fgmax values were stored because setrun.py
specified that fgmax values should only be updated on level 3, but these areas were never refined to that level.
In [ ]: