forked from mhearne-usgs/alertmap
/
alertmap.py
executable file
·603 lines (530 loc) · 20.3 KB
/
alertmap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
#!/usr/bin/env python
#stdlib imports
import os.path
import sys
import ConfigParser
import argparse
from xml.dom.minidom import parse
import csv
from operator import itemgetter
import json
import pprint
import warnings
#local imports
from neicio.cmdoutput import getCommandOutput
from neicio.shake import ShakeGrid
from neicio.esri import EsriGrid
from neicio.gmt import GMTGrid
from travel.travel import TravelTimeCalculator,saveTimeGrid,readTimeGrid
from neicutil.text import commify
#third party imports
from obspy.core.util import locations2degrees
from obspy.fdsn import Client
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from neicutil.text import roundToNearest,ceilToNearest,floorToNearest
from neicutil.colormap import GMTColormap
from matplotlib.colors import ListedColormap,LinearSegmentedColormap,Normalize,BoundaryNorm
WATER_COLOR = [.47,.60,.81]
#CITY_COLOR = '#33FF00'
CITY_COLOR = '#FF0000'
MAX_CITIES_PER_BLOCK = 1
MINTIME = -5
MAXTIME = 40
DTIME = 5
TELEMETRY_DELAY = 4.5
PROCESSING_DELAY = 4.0
TIMEFMT = '%Y-%m-%dT%H:%M:%S'
DATEFMT = '%Y-%m-%d'
EVENT_DEFAULT = '''<?xml version="1.0" encoding="US-ASCII" standalone="yes"?>
<earthquake id="[EVENTID]" lat="[LAT]" lon="[LON]" mag="[MAG]" year="[YEAR]" month="[MONTH]" day="[DAY]" hour="[HOUR]" minute="[MINUTE]" second="[SECOND]" timezone="GMT" depth="[DEPTH]" locstring="[LOCSTR]" created="1407055672" otime="1407054613" type="" network="us" />
'''
GRIND_DEFAULT = '''smVs30default : 686
use_gmpe_sc : true
x_grid_interval : [DX]
y_grid_interval : [DY]
lonspan : [LONSPAN]
latspan : [LATSPAN]
bad_station : 8016 9.9 19990101-
bad_station : 8010 9.9 19990101-
bad_station : 8022 9.9 19990101-
bad_station : 8034 9.9 19990101-
bad_station : 8040 9.9 19990101-
gmpe: [GMPE] 0.0 9.9 0 999
outlier_deviation_level : 3
outlier_max_mag : 7.0
bias_norm : l1
bias_max_range : 120
bias_min_stations : 6
bias_max_mag : 7.0
bias_max_bias : 2.0
bias_min_bias : -2.0
bias_log_amp : true
direct_patch_size : 1000
fwdata_file : forward.xml
topobin : <HOME>/bin/topo2grd <EVID> <BOUND> regime=active
pgm2mi: [GMICE]
mi2pgm: [GMICE]
'''
def printExposure(exposure):
for expbin in exposure:
tpl = (expbin['mintime'],expbin['maxtime'],commify(expbin['exposure']))
print '\t%2i - %2i seconds: %s' % tpl
def getTimeExposure(timegriddata,mmigrid,popfile,mmithresh):
timegrid = GMTGrid()
timegrid.griddata = timegriddata.copy()
timegrid.geodict = mmigrid.geodict.copy()
popgrid = EsriGrid(popfile)
popgrid.load(bounds=timegrid.getRange())
timegrid.interpolateToGrid(popgrid.geodict)
timegrid.griddata[mmigrid.griddata < mmithresh] = np.NaN
times = np.arange(MINTIME,MAXTIME+DTIME,DTIME)
exposure = []
mintime = MINTIME
ireal = np.isfinite(timegrid.griddata)
for time in times[1:]:
ipop = ((timegrid.griddata >= mintime) & (timegrid.griddata < time) & np.isfinite(timegrid.griddata))
exposum = int(np.sum(popgrid.griddata[ipop]))
exposure.append({'mintime':mintime,'maxtime':time,'exposure':exposum})
mintime = time
return (exposure,timegrid.griddata)
def getCityList(xmin,xmax,ymin,ymax,cityfile):
cities = []
nrows = 4
ncols = 4
bins = []
dy = (ymax-ymin)/nrows
dx = (xmax-xmin)/ncols
for i in range(0,nrows):
for j in range(0,ncols):
bxmin = xmin+(j*dx)
bxmax = xmin+((j+1)*dx)
bymin = ymin+(i*dy)
bymax = ymin+((i+1)*dy)
bins.append([(bxmin,bxmax,bymin,bymax),0])
f = open(cityfile,'rt')
for line in f.readlines():
city = {}
parts = line.split('\t')
city['name'] = parts[2].strip()
city['lat'] = float(parts[4].strip())
city['lon'] = float(parts[5].strip())
city['pop'] = int(parts[14].strip())
if not city['name']:
#print 'Found a city with no name'
continue
if not all(ord(c) < 128 for c in city['name']):
continue
if city['lat'] >= ymin and city['lat'] <= ymax and city['lon'] >= xmin and city['lon'] <= xmax:
cities.append(city)
cities.sort(key=itemgetter('pop'),reverse=True)
citylist = []
for city in cities:
clat = city['lat']
clon = city['lon']
for i in range(0,len(bins)):
binbounds = bins[i][0]
bincount = bins[i][1]
if clon >= binbounds[0] and clon <= binbounds[1] and clat >= binbounds[2] and clat <= binbounds[3]:
if bincount >= MAX_CITIES_PER_BLOCK:
continue
bins[i][1] += 1
citylist.append(city)
binfilled = [b[1] == MAX_CITIES_PER_BLOCK for b in bins]
bincounts = [b[1] for b in bins]
if all(binfilled):
break
f.close()
return citylist
def getEventText(eventfile,lat,lon):
root = parse(eventfile)
eq = root.getElementsByTagName('earthquake')[0]
eventdict = {}
eventdict['lat'] = lat
eventdict['lon'] = lon
eventdict['eventid'] = eq.getAttribute('id')
eventdict['mag'] = float(eq.getAttribute('mag'))
eventdict['year'] = int(eq.getAttribute('year'))
eventdict['month'] = int(eq.getAttribute('month'))
eventdict['day'] = int(eq.getAttribute('day'))
eventdict['hour'] = int(eq.getAttribute('hour'))
eventdict['minute'] = int(eq.getAttribute('minute'))
eventdict['second'] = int(round(float(eq.getAttribute('second'))))
eventdict['depth'] = float(eq.getAttribute('depth'))
eventdict['locstr'] = eq.getAttribute('locstring')
root.unlink()
eventtext = EVENT_DEFAULT
for key,value in eventdict.iteritems():
eventtext = eventtext.replace('['+key.upper()+']',str(value))
return eventtext
def getSlowestStation(lat,lon,depth,calc):
client = Client("IRIS")
inventory = client.get_stations(latitude=lat, longitude=lon,maxradius=1.5)
lats = []
lons = []
codes = []
for network in inventory.networks:
for station in network.stations:
lats.append(station.latitude)
lons.append(station.longitude)
codes.append(station.code)
lats = np.array(lats)
lons = np.array(lons)
codes = np.array(codes)
distances = []
times = []
for i in range(0,len(lats)):
slat = lats[i]
slon = lons[i]
distance = locations2degrees(lat,lon,slat,slon)
distances.append(distance)
ptime,stime = calc.getTravelTimes(distance,depth)
times.append(ptime)
times = np.array(times)
distances = np.array(distances)
sortidx = np.argsort(distances)
distances = distances[sortidx]
times = times[sortidx]
lats = lats[sortidx]
lons = lons[sortidx]
codes = codes[sortidx]
distances = distances[0:4]
times = times[0:4] + TELEMETRY_DELAY + PROCESSING_DELAY
lats = lats[0:4]
lons = lons[0:4]
codes = codes[0:4]
idx = times.argmax()
sdict = {'lat':lats[idx],'lon':lons[idx],'time':times[idx],'code':codes[idx]}
return sdict
def writeGrind(config,datadir):
gmpe = config.get('MAP','gmpe')
gmice = config.get('MAP','gmice')
ipe = config.get('MAP','ipe')
xmin = float(config.get('MAP','xmin'))
xmax = float(config.get('MAP','xmax'))
ymin = float(config.get('MAP','ymin'))
ymax = float(config.get('MAP','ymax'))
dx = float(config.get('MAP','dx'))
dy = float(config.get('MAP','dy'))
lonspan = xmax - xmin
latspan = ymax - ymin
grindfile = os.path.join(datadir,'config','grind.conf')
grindstr = GRIND_DEFAULT
grindstr = grindstr.replace('[GMPE]',gmpe)
grindstr = grindstr.replace('[GMICE]',gmice)
grindstr = grindstr.replace('[IPE]',ipe)
grindstr = grindstr.replace('[DX]',str(dx))
grindstr = grindstr.replace('[DY]',str(dy))
grindstr = grindstr.replace('[LONSPAN]',str(lonspan))
grindstr = grindstr.replace('[LATSPAN]',str(latspan))
f = open(grindfile,'wt')
f.write(grindstr)
f.close()
def detectShakeHome():
isFound = False
for shakehome in SHAKEHOMELIST:
grind = os.path.join(shakehome,'bin','grind')
if os.path.isfile(grind):
isFound = True
break
if isFound:
return shakehome
else:
return None
def getMapLines(dmin,dmax):
NLINES = 4
drange = dmax-dmin
if drange > 4:
near = 1
else:
if drange >= 0.5:
near = 0.25
else:
near = 0.125
inc = roundToNearest(drange/NLINES,near)
if inc == 0:
near = pow(10,round(log10(drange))) #make the increment the closest power of 10
inc = ceilToNearest(drange/NLINES,near)
newdmin = floorToNearest(dmin,near)
newdmax = ceilToNearest(dmax,near)
else:
newdmin = ceilToNearest(dmin,near)
newdmax = floorToNearest(dmax,near)
darray = np.arange(newdmin,newdmax,inc)
return darray
def getLatLonGrids(shake):
dims = shake.getData().shape
nrows = dims[0]
ncols = dims[1]
geodict = shake.getGeoDict()
xmin = geodict['xmin']
xmax = geodict['xmax']
ymin = geodict['ymin']
ymax = geodict['ymax']
xdim = geodict['xdim']
ydim = geodict['ydim']
if xmax < xmin:
xmax = xmax + 360
lonrow = np.arange(xmin,xmax,xdim)
latcol = np.arange(ymin,ymax,ydim)
if len(lonrow) < ncols:
lonrow = np.concatenate((lonrow,[xmax]))
elif len(lonrow) > ncols:
lonrow = lonrow[0:-1]
if len(latcol) < nrows:
latcol = np.concatenate((latcol,[ymax]))
elif len(latcol) > nrows:
latcol = latcol[0:-1]
longrid = np.zeros((len(latcol),len(lonrow)),dtype=float)
latgrid = np.zeros((len(latcol),len(lonrow)),dtype=float)
for i in range(0,len(lonrow)):
longrid[:,i] = lonrow[i]
for i in range(0,len(latcol)):
latgrid[i,:] = latcol[i]
return longrid,latgrid
def makeMap(timegrid,method,datadir,popfile,popcolormap,stationdict,citylist,elats,elons):
figwidth = 8.0
bounds = timegrid.getRange()
bounds = list(bounds)
if bounds[1] < 0 and bounds[0] > bounds[1]:
bounds[1] = bounds[1] + 360
clat = bounds[2] + (bounds[3] - bounds[2])/2
clon = bounds[0] + (bounds[1] - bounds[0])/2
dx = (bounds[1] - bounds[0])*111191 * np.cos(np.degrees(clat))
dy = (bounds[3] - bounds[2])*111191
aspect = np.abs(dy/dx)
figheight = aspect * figwidth
fig = plt.figure(figsize=(figwidth,figheight),edgecolor='g',facecolor='g')
ax1 = fig.add_axes([0,0,1.0,1.0])
m = Basemap(llcrnrlon=bounds[0],llcrnrlat=bounds[2],
urcrnrlon=bounds[1],urcrnrlat=bounds[3],
resolution='h',projection='merc',lat_ts=clat)
#get the population grid
popgrid = EsriGrid(popfile)
popgrid.load(bounds=bounds)
popdata = np.flipud(popgrid.griddata)
cmap = GMTColormap(popcolormap)
clist = cmap.getColorList()
boundaries = cmap.getZValues()
palette = ListedColormap(clist,'my_colormap')
i = np.where(np.isnan(popdata))
popdata[i] = -1
popdatam = np.ma.masked_values(popdata, -1)
palette.set_bad(WATER_COLOR,1.0)
ncolors = len(boundaries)
am = m.imshow(popdatam,cmap=palette,norm=BoundaryNorm(boundaries,ncolors),interpolation='nearest')
statgrid = np.flipud(timegrid.griddata)
(lons,lats) = getLatLonGrids(timegrid)
(x,y) = m(lons,lats)
clevels = np.arange(MINTIME,MAXTIME+DTIME,DTIME)
cs = m.contour(x,y,statgrid,clevels)
#plt.clabel(cs, inline=1, fontsize=10)
proxy = [plt.Rectangle((0,0),1,1,fc = pc.get_color()[0]) for pc in cs.collections]
labels = [str(c)+' sec' for c in clevels]
sx,sy = m(stationdict['lon'],stationdict['lat'])
m.plot(sx,sy,'rD')
plt.text(sx,sy,stationdict['code'])
#plot the various epicenters
for elat,elon in zip(elats,elons):
ex,ey = m(elon,elat)
m.plot(ex,ey,'k*')
#plot the cities
for city in citylist:
cx,cy = m(city['lon'],city['lat'])
m.plot(cx,cy,'.',color=CITY_COLOR)
plt.text(cx,cy,city['name'],color=CITY_COLOR)
m.drawrivers(color=WATER_COLOR)
m.drawcountries(color='k',linewidth=2.0)
mer = getMapLines(bounds[0],bounds[1])
par = getMapLines(bounds[2],bounds[3])
xmap_range = m.xmax-m.xmin
ymap_range = m.ymax-m.ymin
xoff = -0.09*(xmap_range)
yoff = -0.04*(ymap_range)
m.drawmeridians(mer,labels=[0,0,1,0],fontsize=8,
linewidth=0.5,color='black',yoffset=yoff,xoffset=xoff,dashes=[1,0.01])
m.drawparallels(par,labels=[0,1,0,0],fontsize=8,
linewidth=0.5,color='black',yoffset=yoff,xoffset=xoff,dashes=[1,0.01])
m.drawmapboundary(color='k',linewidth=2.0)
plt.legend(proxy,labels)
outfile = os.path.join(datadir,method+'.pdf')
plt.savefig(outfile)
plt.close()
def getGlobalConfig():
configfile = os.path.join(os.path.expanduser('~'),'.alertmap','config.ini')
if not os.path.isfile(configfile):
raise Exception,'Could not find global config file "%s".' % configfile
config = ConfigParser.ConfigParser()
config.readfp(open(configfile))
gdict = {}
gdict['shakehome'] = config.get('GLOBAL','shakehome')
gdict['popfile'] = config.get('GLOBAL','popfile')
gdict['popcolormap'] = config.get('GLOBAL','popcolormap')
gdict['cityfile'] = config.get('GLOBAL','cityfile')
return gdict
def main(args):
globaldict = getGlobalConfig()
shakehome = globaldict['shakehome']
popfile = globaldict['popfile']
if shakehome is None:
print 'Cannot find ShakeMap home folder on this system.'
sys.exit(1)
datadir = os.path.join(shakehome,'data',args.event)
if not os.path.isdir(datadir):
print 'Cannot find event %s on the system' % args.event
sys.exit(1)
#Make sure the timeoutput folder is there (can't put our time grids in output - that gets
#wiped out every time shakemap runs
outfolder = os.path.join(datadir,'timeoutput')
if not os.path.isdir(outfolder):
os.makedirs(outfolder)
#now look for config file in top-level folder
configfile = os.path.join(datadir,'alert.conf')
if not os.path.isfile(configfile):
print 'Cannot find alert config file for %s in the data directory' % args.event
sys.exit(1)
config = ConfigParser.ConfigParser()
config.readfp(open(configfile))
#get the bounds of the map so we can find cities
xmin = float(config.get('MAP','xmin'))
xmax = float(config.get('MAP','xmax'))
ymin = float(config.get('MAP','ymin'))
ymax = float(config.get('MAP','ymax'))
citylist = getCityList(xmin,xmax,ymin,ymax,globaldict['cityfile'])
#Get the MMI threshold below which alert times will NOT be saved
mmithresh = float(config.get('MAP','mmithresh'))
#get the array of epicenters
lats = [float(p) for p in config.get('FAULT','lats').split()]
lons = [float(p) for p in config.get('FAULT','lons').split()]
#write out a new grind.conf file
writeGrind(config,datadir)
#instantiate our p/s travel time calculator
calc = TravelTimeCalculator()
#where is the grind binary?
grindbin = os.path.join(shakehome,'bin','grind')
#specify the event.xml file, get the depth of the event
eventfile = os.path.join(datadir,'input','event.xml')
root = parse(eventfile)
eq = root.getElementsByTagName('earthquake')[0]
depth = float(eq.getAttribute('depth'))
root.unlink()
#get the dimensionality of the grid file and of the pop grid we'll interpolate to
gridfile = os.path.join(datadir,'output','grid.xml')
if not os.path.isfile(gridfile):
grindcmd = '%s -event %s' % (grindbin,args.event)
res,stdout,stderr = getCommandOutput(grindcmd)
mmigrid = ShakeGrid(gridfile,variable='MMI')
popgrid = EsriGrid(popfile)
popgrid.load(bounds=mmigrid.getRange())
m,n = popgrid.griddata.shape
#loop over all the event realizations
timefiles = []
timestack = np.zeros((m,n,len(lats)),dtype=np.float32)
for i in range(0,len(lats)):
print 'Calculating arrival times for scenario %i of %i' % (i+1,len(lats))
lat = lats[i]
lon = lons[i]
if i == 0:
lonoff = 0
latoff = 0
else:
lonoff = -1* (lons[i] - lons[i-1])
latoff = lats[i] - lats[i-1]
#modify the event.xml file to have the new lat/lon epicenter
sourcetext = getEventText(eventfile,lat,lon)
f = open(eventfile,'wt')
f.write(sourcetext)
f.close()
sdict = getSlowestStation(lat,lon,depth,calc)
ptime = sdict['time']
stationlat = sdict['lat']
stationlon = sdict['lon']
grindcmd = '%s -latoff %f -lonoff %f -event %s' % (grindbin,latoff,lonoff,args.event)
res,stdout,stderr = getCommandOutput(grindcmd)
if not res:
print 'Grind command failed: "%s", "%s"' % (stdout,stderr)
sys.exit(1)
#Get the grid.xml output, do some time calculations
mmigrid = ShakeGrid(gridfile,variable='MMI')
timegrid = np.zeros((m,n),dtype=np.float32)
for row in range(0,m):
for col in range(0,n):
mmilat,mmilon = mmigrid.getLatLon(row,col)
distance = locations2degrees(lat,lon,mmilat,mmilon)
tmp,stime = calc.getTravelTimes(distance,depth)
timegrid[row,col] = stime - ptime
#debugging
f = plt.figure()
plt.subplot(2,1,1)
plt.imshow(mmigrid.griddata)
plt.colorbar()
plt.subplot(2,1,2)
plt.imshow(timegrid)
plt.colorbar()
plt.savefig(os.path.join(outfolder,'timegrid.png'))
plt.close(f)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
exposure,timegrid = getTimeExposure(timegrid,mmigrid,popfile,mmithresh)
print 'Population Warning Times for epicenter %.4f,%.4f' % (lat,lon)
printExposure(exposure)
expofile = os.path.join(outfolder,'expo%03i.json' % (i+1))
f = open(expofile,'wt')
f.write(json.dumps(exposure))
f.close()
timefile = os.path.join(outfolder,'timegrid%03i.flt' % (i+1))
timefiles.append(timefile)
metadict = {'epilat':lat,'epilon':lon,'eventid':args.event}
saveTimeGrid(timefile,timegrid,mmigrid.geodict,metadict)
timestack[:,:,i] = timegrid
alertgrid = popgrid
alertgrid.griddata = timegrid
makeMap(alertgrid,'alertmap_%i' % i,outfolder,popfile,globaldict['popcolormap'],sdict,citylist,[lat],[lon])
methods = config.get('MAP','output').split(',')
for method in methods:
if method == 'median':
statgrid = np.median(timestack,axis=2)
if method == 'mean':
statgrid = np.nanmean(timestack,axis=2)
if method == 'min':
statgrid = np.nanmin(timestack,axis=2)
if method == 'max':
statgrid = np.nanmax(timestack,axis=2)
timegrid = popgrid
timegrid.griddata = statgrid
makeMap(timegrid,method,outfolder,popfile,globaldict['popcolormap'],sdict,citylist,lats,lons)
if __name__ == '__main__':
desc = '''This script does the following:
1) Find ShakeMap event folder from input ID.
2) Parse alert.conf file in event data folder (i.e. /home/shake/ShakeMap/data/eventID/alert.conf)
[FAULT]
lats = 32.1 32.2 32.3
lons = -118.1 -118.2 -118.3
[MAP]
#output can be comma separated list with any of min,mean,median,max
output = median
#mmithresh - MMI value below which alert times will NOT be saved
mmithresh = 6.0
gmpe = AkkarBommer07
gmice = WGRW11
ipe = AW07_CEUS
xmin = -119.0
xmax = -117.0
ymin = 31.0
ymax = 33.0
dx = 0.01
dy = 0.01
3) Replace grind.conf file in event data folder with one created using information supplied above
4) For each epicenter in (lats,lons):
a) Write new event.xml file
b) Run ShakeMap grind program
c) Find 4 nearest stations to epicenter, calculate P arrival times for each, return the slowest.
d) Calculate S arrival times for each cell in ShakeMap, subtract SlowP+8.5 from each.
e) Save grid of S arrival times
5) TODO SCIENCE
'''
parser = argparse.ArgumentParser(description=desc,formatter_class=argparse.RawDescriptionHelpFormatter,)
parser.add_argument('event', help='Select the event ID')
pargs = parser.parse_args()
main(pargs)