本文整理汇总了Python中source.Source.from_CMTSOLUTION_file方法的典型用法代码示例。如果您正苦于以下问题:Python Source.from_CMTSOLUTION_file方法的具体用法?Python Source.from_CMTSOLUTION_file怎么用?Python Source.from_CMTSOLUTION_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类source.Source
的用法示例。
在下文中一共展示了Source.from_CMTSOLUTION_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_si_result
# 需要导入模块: from source import Source [as 别名]
# 或者: from source.Source import from_CMTSOLUTION_file [as 别名]
def plot_si_result(basedir, event_name, outputdir, type_tag):
cmtbase = os.path.join(basedir, "CMTSOLUTION_%s" % event_name)
runfilebase = os.path.join(basedir, "xcmt3d_%s" % event_name)
print "Plotting event:", event_name
print "Base:", cmtbase
fig1 = plt.figure(num=2, figsize=(7, 10), dpi=80, facecolor="w", edgecolor="k")
G = gridspec.GridSpec(3, 3)
loc_mapping = {
"6p_ZT": G[0, 0],
"7p_ZT": G[0, 1],
"9p_ZT": G[0, 2],
"6p_ZT_DC": G[1, 0],
"7p_ZT_DC": G[1, 1],
"9p_ZT_DC": G[1, 2],
}
# Original CMT
ax = plt.subplot(G[2, 2])
cmtfile = cmtbase + "_init"
print "cmtfile:", cmtfile
cmt_init = Source.from_CMTSOLUTION_file(cmtfile)
mt_init = [cmt_init.m_rr, cmt_init.m_tt, cmt_init.m_pp, cmt_init.m_rt, cmt_init.m_rp, cmt_init.m_tp]
print mt_init
# print cmt_init.moment_magnitude
# plot_si_bb(ax, cmt_init)
# Source Inversion result
for tag, position in loc_mapping.iteritems():
ax = plt.subplot(position)
cmtfile = cmtbase + "_" + tag
print "cmtfile:", cmtfile
runfile = runfilebase + "_" + tag + ".out"
cmt = Source.from_CMTSOLUTION_file(cmtfile)
# print cmt.moment_magnitude
mt = [cmt.m_rr, cmt.m_tt, cmt.m_pp, cmt.m_rt, cmt.m_rp, cmt.m_tp]
plot_si_bb_comp(ax, cmt, cmt_init, tag, runfile)
# Map and source location
ax = plt.subplot(G[2, :-1])
m = Basemap(projection="cyl", lon_0=142.36929, lat_0=0.0, resolution="c")
m.drawcoastlines()
m.fillcontinents()
m.drawparallels(np.arange(-90.0, 120.0, 30.0))
m.drawmeridians(np.arange(0.0, 420.0, 60.0))
m.drawmapboundary()
# Beachball on the map
# calibrate longitude
if cmt.longitude < 0:
lon = cmt.longitude + 360
else:
lon = cmt.longitude
x, y = m(lon, cmt.latitude)
# print cmt.longitude, cmt.latitude
# print x, y
# b = Beach(mt_init, xy=(x,y), width=20, linewidth=1, alpha=0.85)
# b.set_zorder(100)
# ax.add_collection(b)
fig_title = "%s_%s" % (event_name, type_tag)
plt.title(fig_title)
outputfile = "%s_%s.pdf" % (event_name, type_tag)
path = os.path.join(outputdir, outputfile)
print "Output file:", path
fig1.savefig(path)