Original Author: R.J. LeVeque, Modified by Christopher Liu to also work on Windows.
For data from the paper
"A Source Clustering Approach for Efficient Inundation Modeling and Regional Scale PTHA" by A.L. Williamson, D. Rim, L.M. Adams, R.J. LeVeque, D. Melgar, and F.I. González, Frontiers in Earth Science, 8 (2020) p. 442. [paper and more data].
This illustrates how to download gauge times series results from some of the 2000 GeoClaw fine-grid runs archived at http://krakatoa.uoregon.edu/cascadia_ptha/ground_truth.
The corresponding coarse-grid run results (on a 9 arcsecond grid) are in the directory http://krakatoa.uoregon.edu/cascadia_ptha/coarse_model_runs.
%pylab inline
import os
from urllib.request import urlretrieve
from IPython.display import Image
Open the gauges.kml
file in Google Earth to see all gauge locations for these runs.
Image('westport_gauges.png', width=600)
# where to put the files downloaded:
datadir = os.path.join(os.getcwd(), 'westport_data')
def get_gauges_urllib(rnums, gaugenos):
# create directory for data if it does not exist
if not os.path.isdir(datadir):
os.mkdir(datadir)
for rnum in rnums:
url = 'http://krakatoa.uoregon.edu/cascadia_ptha/ground_truth/ptha_%s/' % str(rnum).zfill(6)
rundir = os.path.join(datadir, 'run%s' % str(rnum).zfill(6))
if not os.path.isdir(rundir):
os.mkdir(rundir)
print('Data for run %s will go into directory %s' % (rnum, rundir))
for gaugeno in gaugenos:
fname = 'gauge%s.txt' % str(gaugeno).zfill(5)
local_fname = os.path.join(rundir, fname)
if os.path.isfile(local_fname):
print('%s has already been downloaded' % fname)
else:
remote_fname = url + '/' + fname
print('Downloading %s from %s' % (fname,url))
a = urlretrieve(remote_fname, local_fname)
For illustration purposes we will just download a few, including the runs used in the paper.
The script download_gauges.py
can be used to download all gauges from all 2000 simulations, or whatever subset you want.
get_gauges_urllib([1665,1670,1999],[3,120])
def plot_gauges(rnum, gaugenos):
rundir = os.path.join(datadir, 'run%s' % str(rnum).zfill(6))
figure(figsize=(12,5))
for gaugeno in gaugenos:
fname = 'gauge%s.txt' % str(gaugeno).zfill(5)
local_fname = os.path.join(rundir, fname)
d = loadtxt(local_fname, skiprows=3)
print('gauge data has shape ',d.shape)
t = d[:,1] # time in seconds
h = d[:,2] # water depth in meters
eta = d[:,5] # surface elevation B+h in meters
B = eta - h # topography B in meters
plot(t/3600., eta, label='Gauge %s' % str(gaugeno).rjust(5))
grid(True)
legend(loc='upper right')
xlim(0,5)
xlabel('hours')
ylabel('meters')
title('Run %s' % rnum);
plot_gauges(1665,[3,120])
plot_gauges(1670,[3,120])
plot_gauges(1999,[3,120])