20171230 GMT/Python之初体验

安装粗大(CUDA)老是不成功,一怒之下搜索了GMT,然后发现有了Python3版本的,回想起当初学校GMT的各种蛋疼,于是一顿下载安装加测试。
简单记录如下:

[https://hub.mybinder.org/user/genericmappingt–try-gmt-python-aln0nj0a/notebooks/try-gmt-python.ipynb]

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)

fig6的效果

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值