當前位置: 首頁>>代碼示例>>Python>>正文


Python Source.from_CMTSOLUTION_file方法代碼示例

本文整理匯總了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)
開發者ID:yanhuay,項目名稱:SeisProc,代碼行數:70,代碼來源:plot_source_util.py


注:本文中的source.Source.from_CMTSOLUTION_file方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。