20171230 GMT/Python之初體驗
阿新 • • 發佈:2018-11-09
安裝粗大(CUDA)老是不成功,一怒之下搜尋了GMT,然後發現有了Python3版本的,回想起當初學校GMT的各種蛋疼,於是一頓下載安裝加測試。
簡單記錄如下:
import gmt
import pandas as pd
import numpy as np
fig=gmt.Figure()
fig.coast(region=[-90,-70,0,20],projection='M6i',land='chocolate' ,frame=True)
fig.savefig('hehe.png',show=True)
fig.show(external=True)
np.random.seed(42)
ndata=100
region=[150,240,-10,60]
lon=np.random.uniform(region[0],region[1],ndata)
lat=np.random.uniform(region[2],region[3],ndata)
magnitude=np.random.uniform(1,9,ndata)
depth=np.random.uniform(1,600,ndata)
fig2=gmt.Figure()
fig2.coast(region='g' ,projection='G200/20/6i',frame='g',land='gray',water='white')
fig2.plot(x=lon,y=lat,style='c0.1c',color='black')
fig2.savefig('my2.png',show=True)
fig3=gmt.Figure()
fig3.coast(region='g',projection='G200/20/6i',frame='g',land='gray',water='white')
fig3.plot(x=lon,y=lat,color='black',style='cc',sizes=0.01*(1.7**magnitude))
fig3.savefig('my3.png' ,show=True)
log_depth=np.log10(depth)
log_depth_norm = (log_depth)/(log_depth.max())
fig4=gmt.Figure()
fig4.coast(region='g',projection='G200/20/6i',frame='g',land='gray',water='white')
fig4.plot(x=lon,y=lat,style='cc',sizes=0.01*(1.7**magnitude),color=log_depth_norm,cmap='viridis')
fig4.savefig('my4.png',show=True)
np.savetxt('first-steps-data.txt',np.transpose([lon,lat,magnitude,depth]))
fig5=gmt.Figure()
fig5.coast(region=region,projection='M6i',frame='afg',land='white',water='skyblue')
fig5.plot(data='first-steps-data.txt',style='cc',cmap='inferno',columns=[0,1,'3ls0.36','2s0.05'])
fig5.savefig('fig5.png',show=True)
fig6=gmt.Figure()
fig6.coast(region=[130,150,35,50],water='lightblue',land='white',projection='M6i',frame='afg',shorelines=True)
fig6.plot(data='@tut_quakes.ngdc',style='c0.3c',color='black',columns=[4,3])
fig6.savefig('fig6.png',show=True)