@@ -479,7 +479,7 @@ def tile_slip(rupt,nstrike,ndip,slip_bounds,geographic=False,epicenter=0,epicent
479479
480480 from numpy import genfromtxt ,unique ,where ,zeros ,tile ,sqrt
481481 import matplotlib .pyplot as plt
482- from obspy .core . util . geodetics import gps2DistAzimuth
482+ from obspy .geodetics import gps2dist_azimuth
483483
484484 f = genfromtxt (rupt )
485485 num = f [:,0 ]
@@ -504,19 +504,19 @@ def tile_slip(rupt,nstrike,ndip,slip_bounds,geographic=False,epicenter=0,epicent
504504 slip_min = slip_bounds [0 ]
505505 slip_max = slip_bounds [1 ]
506506 #Aftershocks
507- af = genfromtxt ('/Users/dmelgar/Chiapas2017/afters/afters_10days_close2fault.txt' )
508- lon_afters = af [:,0 ]
509- lat_afters = af [:,1 ]
510- depth_afters = af [:,2 ]
511- print (af )
507+ # af=genfromtxt('/Users/dmelgar/Chiapas2017/afters/afters_10days_close2fault.txt')
508+ # lon_afters=af[:,0]
509+ # lat_afters=af[:,1]
510+ # depth_afters=af[:,2]
511+ # print(af)
512512 if geographic == True : #Get geographic coordinates to compute along strike and along dip distance
513513 lon = f [(epicenter_line - 1 )* nstrike :epicenter_line * nstrike ,1 ] #Only compute line at the epicenter depth
514514 lat = f [(epicenter_line - 1 )* nstrike :epicenter_line * nstrike ,2 ]
515515 depth = - f [:,3 ]
516516 depth = depth [0 :len (unum )]
517517 along_strike = zeros (nstrike )
518518 for k in range (len (lat )):
519- out = gps2DistAzimuth (epicenter [1 ],epicenter [0 ],lat [k ],lon [k ])
519+ out = gps2dist_azimuth (epicenter [1 ],epicenter [0 ],lat [k ],lon [k ])
520520 if lat [k ]< epicenter [1 ]: #It's to the south
521521 #along_strike[k]=-out[0]/1000
522522 along_strike [k ]= out [0 ]/ 1000
@@ -525,15 +525,15 @@ def tile_slip(rupt,nstrike,ndip,slip_bounds,geographic=False,epicenter=0,epicent
525525 along_strike [k ]= - out [0 ]/ 1000
526526 #Now tile
527527 along_strike = tile (along_strike ,ndip )
528- #Process the aftershocks
529- along_strike_afters = zeros (len (lon_afters ))
530- for k in range (len (lat_afters )):
531- out = gps2DistAzimuth (epicenter [1 ],epicenter [0 ],lat_afters [k ],lon_afters [k ])
532- if lat_afters [k ]< epicenter [1 ]: #It's to the south
533- #along_strike_afters[k]=-out[0]/1000
534- along_strike_afters [k ]= out [0 ]/ 1000
535- else :
536- along_strike_afters [k ]= - out [0 ]/ 1000
528+ # #Process the aftershocks
529+ # along_strike_afters=zeros(len(lon_afters))
530+ # for k in range(len(lat_afters)):
531+ # out=gps2dist_azimuth (epicenter[1],epicenter[0],lat_afters[k],lon_afters[k])
532+ # if lat_afters[k]<epicenter[1]: #It's to the south
533+ # #along_strike_afters[k]=-out[0]/1000
534+ # along_strike_afters[k]=out[0]/1000
535+ # else:
536+ # along_strike_afters[k]=-out[0]/1000
537537 #Get indices for plot
538538 istrike = zeros (nstrike * ndip )
539539 idip = zeros (nstrike * ndip )
@@ -1576,7 +1576,8 @@ def plot_data(home,project_name,gflist,vord,decimate,lowpass,t_lim,sort,scale,k_
15761576 #plt.subplots_adjust(left=0.2, bottom=0.05, right=0.8, top=0.95, wspace=0, hspace=0)
15771577 plt .subplots_adjust (left = 0.2 , bottom = 0.15 , right = 0.8 , top = 0.85 , wspace = 0 , hspace = 0 )
15781578
1579- def synthetics (home ,project_name ,run_name ,run_number ,gflist ,vord ,decimate ,lowpass ,t_lim ,sort ,scale ,k_or_g ,uncert = False ,waveforms_as_accel = False ):
1579+ def synthetics (home ,project_name ,run_name ,run_number ,gflist ,vord ,decimate ,lowpass ,t_lim ,
1580+ sort ,scale ,k_or_g ,uncert = False ,waveforms_as_accel = False ,units = 'm' ,uncerth = 0.01 ,uncertv = 0.03 ):
15801581 '''
15811582 Plot synthetics vs real data
15821583
@@ -1630,12 +1631,14 @@ def synthetics(home,project_name,run_name,run_number,gflist,vord,decimate,lowpas
16301631 es = read (synthpath + run_name + '.' + run_number + '.' + sta [i [k ]]+ '.' + synthsuffix + '.e.sac' )
16311632 us = read (synthpath + run_name + '.' + run_number + '.' + sta [i [k ]]+ '.' + synthsuffix + '.u.sac' )
16321633
1633- #Zero out a stations
1634- if sta [i [k ]]== "NILT" :
1635- n [0 ].data = zeros (len (n [0 ].data ))
1636- e [0 ].data = zeros (len (e [0 ].data ))
1637- ns [0 ].data = zeros (len (ns [0 ].data ))
1638- es [0 ].data = zeros (len (es [0 ].data ))
1634+ if units == 'cm' :
1635+ n [0 ].data *= 100
1636+ e [0 ].data *= 100
1637+ u [0 ].data *= 100
1638+ ns [0 ].data *= 100
1639+ es [0 ].data *= 100
1640+ us [0 ].data *= 100
1641+
16391642
16401643 if lowpass != None :
16411644 print ('Lowpassing' )
@@ -1674,9 +1677,9 @@ def synthetics(home,project_name,run_name,run_number,gflist,vord,decimate,lowpas
16741677 axe .grid (which = 'both' )
16751678 axu .plot (u [0 ].times (),u [0 ].data ,'k' ,us [0 ].times (),us [0 ].data ,'r' )
16761679 if uncert == True :
1677- axn .fill_between (n [0 ].times (),n [0 ].data - 0.01 ,n [0 ].data + 0.01 ,alpha = 0.2 ,color = 'k' )
1678- axe .fill_between (e [0 ].times (),e [0 ].data - 0.01 ,e [0 ].data + 0.01 ,alpha = 0.2 ,color = 'k' )
1679- axu .fill_between (u [0 ].times (),u [0 ].data - 0.03 ,u [0 ].data + 0.03 ,alpha = 0.2 ,color = 'k' )
1680+ axn .fill_between (n [0 ].times (),n [0 ].data - uncerth ,n [0 ].data + uncerth ,alpha = 0.2 ,color = 'k' )
1681+ axe .fill_between (e [0 ].times (),e [0 ].data - uncerth ,e [0 ].data + uncerth ,alpha = 0.2 ,color = 'k' )
1682+ axu .fill_between (u [0 ].times (),u [0 ].data - uncertv ,u [0 ].data + uncertv ,alpha = 0.2 ,color = 'k' )
16801683 axu .grid (which = 'both' )
16811684 axe .yaxis .set_ticklabels ([])
16821685 axu .yaxis .set_ticklabels ([])
@@ -1746,13 +1749,23 @@ def synthetics(home,project_name,run_name,run_number,gflist,vord,decimate,lowpas
17461749 axn .set_ylabel (sta [i [k ]],rotation = 0 ,labelpad = 20 )
17471750 if k == 0 :
17481751 if vord .lower ()== 'd' :
1749- axn .set_title ('North (m)' )
1750- axe .set_title ('East (m)' )
1751- axu .set_title ('Up (m)' )
1752+ if units == 'cm' :
1753+ axn .set_title ('North (cm)' )
1754+ axe .set_title ('East (cm)' )
1755+ axu .set_title ('Up (cm)' )
1756+ else :
1757+ axn .set_title ('North (m)' )
1758+ axe .set_title ('East (m)' )
1759+ axu .set_title ('Up (m)' )
17521760 else :
1753- axn .set_title ('North (m/s)' )
1754- axe .set_title ('East (m/s)' )
1755- axu .set_title ('Up (m/s)' )
1761+ if units == 'cm' :
1762+ axn .set_title ('North (cm/s)' )
1763+ axe .set_title ('East (cm/s)' )
1764+ axu .set_title ('Up (cm/s)' )
1765+ else :
1766+ axn .set_title ('North (m/s)' )
1767+ axe .set_title ('East (m/s)' )
1768+ axu .set_title ('Up (m/s)' )
17561769 if k != len (i )- 1 :
17571770 axn .xaxis .set_ticklabels ([])
17581771 axe .xaxis .set_ticklabels ([])
@@ -1866,7 +1879,7 @@ def insar_residual(home,project_name,run_name,run_number,gflist,zlims):
18661879
18671880 matplotlib .rcParams .update ({'font.size' : 14 })
18681881 #Decide what to plot
1869- sta = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = 0 ,dtype = 'S ' )
1882+ sta = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = 0 ,dtype = 'U ' )
18701883 lon_all = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = [1 ],dtype = 'f' )
18711884 lat_all = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = [2 ],dtype = 'f' )
18721885 gf = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = [7 ],dtype = 'f' )
@@ -1909,7 +1922,7 @@ def insar_results(home,project_name,run_name,run_number,gflist,zlims,cmap,figsiz
19091922
19101923 matplotlib .rcParams .update ({'font.size' : 14 })
19111924 #Decide what to plot
1912- sta = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = 0 ,dtype = 'S ' )
1925+ sta = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = 0 ,dtype = 'U ' )
19131926 lon_all = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = [1 ],dtype = 'f' )
19141927 lat_all = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = [2 ],dtype = 'f' )
19151928 gf = genfromtxt (home + project_name + '/data/station_info/' + gflist ,usecols = [7 ],dtype = 'f' )
0 commit comments