def map_stream(st,showpath=True,showplot=True,Lat_0=0.0,Lon_0=60.0):
from mpl_toolkits.basemap import Basemap
fig = plt.figure()
plt.ion()
m = Basemap(projection='ortho',lat_0=Lat_0,lon_0=Lon_0,resolution='l')
m.drawmapboundary()
m.drawcoastlines()
m.fillcontinents(color='gray',lake_color='white')
gc_lines = []
for tr in st:
x1,y1 = m(tr.stats.sac['evlo'],tr.stats.sac['evla'])
x2,y2 = m(tr.stats.sac['stlo'],tr.stats.sac['stla'])
m.scatter(x1,y1,s=200.0,marker='*',facecolors='y',edgecolors='k',zorder=99)
station_pt = m.scatter(x2,y2,s=20.0,marker='^',color='b',zorder=99,picker=1)
station_pt.set_label(tr.stats.station)
if showpath == True:
gc_line = m.drawgreatcircle(tr.stats.sac['evlo'],tr.stats.sac['evla'],
tr.stats.sac['stlo'],tr.stats.sac['stla'],
linewidth=1,color='k',alpha=0.5)
gc_line[0].set_label(tr.stats.station)
gc_lines.append(gc_line)
def onpick(event):
art = event.artist
picked = art.get_label()
print "removing station(s) ", picked
st_to_remove = st.select(station=picked)
for killed_tr in st_to_remove:
st.remove(killed_tr)
art.remove()
for gc in gc_lines:
gc_line_label = gc[0].get_label()
if gc_line_label == picked:
gc[0].remove()
fig.canvas.draw()
fig.canvas.mpl_connect('pick_event', onpick)
if showplot == True:
plt.show()
else:
return m
#########################################################################
# Plot multiple traces ontop of eachother, aligned on a phase and windowed
#########################################################################
评论列表
文章目录