MatPlotLib(Basemap)与Grads、NCL和GMT的对比

10 篇文章 2 订阅
8 篇文章 1 订阅
MatPlotLib是python中大名鼎鼎的绘图包,在绘制图形方面比 GradsNCL(NCAR Command Language)GMT要强大的多,并且借助于python简洁的语法,编程也容易得多,远非后两者可以与之相提并论的.Grads、NCL和GMT只是在Earth System Modeling 和Global Climate  Modeling等方面,一直遥遥领先.不过情况已悄悄变化,现在MatPlotLib已推出basemap 1.0.7,可以说basemap在处理文件 (netCDF,hdf,shapefile等) 和 绘图方面,基本上实现了Grads、NCL和GMT的所有功能.

下面给个例子,让大家感受一下basemap:

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
# set up orthographic map projection with
# perspective of satellite looking down at 50N, 100W.
# use low resolution coastlines.
map = Basemap(projection='ortho',lat_0=45,lon_0=-100,resolution='l')
# draw coastlines, country boundaries, fill continents.
map.drawcoastlines(linewidth=0.25)
map.drawcountries(linewidth=0.25)
map.fillcontinents(color='coral',lake_color='aqua')
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary(fill_color='aqua')
# draw lat/lon grid lines every 30 degrees.
map.drawmeridians(np.arange(0,360,30))
map.drawparallels(np.arange(-90,90,30))
# make up some data on a regular lat/lon grid.
nlats = 73; nlons = 145; delta = 2.*np.pi/(nlons-1)
lats = (0.5*np.pi-delta*np.indices((nlats,nlons))[0,:,:])
lons = (delta*np.indices((nlats,nlons))[1,:,:])
wave = 0.75*(np.sin(2.*lats)**8*np.cos(4.*lons))
mean = 0.5*np.cos(2.*lats)*((np.sin(2.*lats))**2 + 2.)
# compute native map projection coordinates of lat/lon grid.
x, y = map(lons*180./np.pi, lats*180./np.pi)
# contour data over the map.
cs = map.contour(x,y,wave+mean,15,linewidths=1.5)
plt.title('contour lines over filled continent background')
plt.show()

绘制的结果如下:

更多的例子,去Basemap的Example Gallery看看吧:

Basemap的的文档链接为:http://matplotlib.org/basemap/index.html 

Wiki也提供了一点coolbook:

http://wiki.scipy.org/Cookbook/Matplotlib/Maps

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值