2023-05-11 pygmt畫(huà)門(mén)源地圖,加指北針、比例尺等

fig = pygmt.Figure()
region=[100.9, 101.6, 37.5, 38]
pygmt.config(FORMAT_GEO_MAP="ddd.xx")

df_EQ = pd.read_csv('./12-16th_E-timestamp-Tpre.csv')
df_EQ_yes = df_EQ[(df_EQ['detected?']=='yes')]

df_EQ_no = df_EQ[(df_EQ['detected?']=='no')]

region=[100.9, 101.6, 37.5, 38]
# grid = pygmt.datasets.load_earth_relief(resolution="01s", region=region)

pygmt.makecpt(cmap="terra", series=[-7000, 7000])
fig.grdimage(grid=grid, projection="M15c", cmap="grayC", shading = '-I+d')
# fig.basemap(region=region, projection="M10c", frame=True, rose="-R101/101.2/37.5/37.7+w1c+f+l")
fig.basemap(
    frame=True,
    projection="M15c",
    rose="n0.9/0.92+w1.5c+f",
    map_scale="n0.9/0.05+w10k+f+l",
)

fig.plot('fault-Menyuan.gmt', pen="1p,black")
fig.plot('cabel.gmt', pen="1p,red")


c0 = '31/119/180'
c1 = '255/127/14'
c2 = '44/160/44'

mags = [[5,10],[4,5],[3,4],[2,3],[0,2]]
sizes = [0.18, 0.16, 0.14, 0.12, 0.1]

for i in range(len(mags)):
    m = df_EQ[(df_EQ['day']==12)&(df_EQ['magnitude']>=mags[i][0])&(df_EQ['magnitude']<mags[i][1])]
    if len(m) == 0:
        continue
    else:
        fig.plot(
            x=m['longitude'],
            y=m['latitude'],
            size=sizes[i]*m['magnitude'],
            style="cc",
            color=c0,
            pen="black",
            cmap=False,
        )
    
for i in range(len(mags)):
    m = df_EQ[(df_EQ['day']!=12)&(df_EQ['magnitude']>=mags[i][0])&(df_EQ['magnitude']<mags[i][1])]
    if len(m) == 0:
        continue
    else:
        fig.plot(
            x=m['longitude'],
            y=m['latitude'],
            size=sizes[i]*m['magnitude'],
            style="cc",
            color=c1,
            pen="black",
            cmap=False,
        )
# fig.legend()
fig.text(text="F3", x=101.1, y=37.94, fill="white", angle=330)
fig.text(text="F2", x=101.09, y=37.81, fill="white", angle=-15)
fig.text(text="F1", x=101.30, y=37.80, fill="white", angle=-30)
fig.text(text="F4", x=101.32, y=37.625, fill="white", angle=-35)

names = ['520', '1100', '1720', '1800', '2455', '3800', '4800']
fig.plot(
    x=np.array([100.9412, 100.960338, 100.975805, 100.978373, 100.997423, 101.035487, 101.068287]),
    y=np.array([37.9618, 37.942160,  37.926779,  37.924955,  37.911520,  37.878764,  37.862946]),
    size=0.1*np.ones(len(names)),
    style="cc",
    color=None,
    pen="black",
    cmap=False,
)
fig.text(text=['520', '1100', '1720', '2455', '3800', '4800'], 
         x=np.array([100.9412, 100.961338, 100.976805, 100.997423, 101.035487, 101.068287])-0.025,
         y=np.array([37.9618, 37.942160,  37.926779, 37.911520,  37.878764,  37.862946]), 
         )
fig.text(text='1800',
         x=np.array([100.978373])+0.021,
         y=np.array([37.924955]), 
         )

fig.plot(
    x=np.array([100.942304]),
    y=np.array([37.969273]),
    size=0.5*np.array([1]),
    style="tc",
    color='red',
    pen="white",
    cmap=False,
)

fig.show()
fig.savefig('Fig2a.png', dpi=300)
Fig2a.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容