爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 67621|回复: 64

[参考资料] 分享一个Python绘图例子的网站(气象绘图),建议有兴趣者学习

  [复制链接]

新浪微博达人勋

发表于 2017-5-7 20:33:26 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 又是那隻貓 于 2017-5-7 22:38 编辑

分享一个Python绘图例子的网站;计算数据,最终都为了绘制图形。去年也无意中浏览过这个网站,今年再次捡起Python,再一次打开这个绘图指导的网站,有很多py的现成例子,大家有兴趣的可以去浏览和下载!


http://matplotlib.org/basemap/users/examples.html

例如:
from mpl_toolkits.basemap import Basemap, cm# requires netcdf4-python (netcdf4-python.googlecode.com)from netCDF4 import Dataset as NetCDFFile
import numpy as np
import matplotlib.pyplot as plt
# plot rainfall from NWS using special precipitation
# colormap used by the NWS, and included in basemap.
nc = NetCDFFile('../../../examples/nws_precip_conus_20061222.nc')
# data from http://water.weather.gov/precip/
prcpvar = nc.variables['amountofprecip']
data = 0.01*prcpvar[:]
latcorners = nc.variables['lat'][:]
loncorners = -nc.variables['lon'][:]
lon_0 = -nc.variables['true_lon'].getValue()
lat_0 = nc.variables['true_lat'].getValue()
# create figure and axes instances
fig = plt.figure(figsize=(8,8))
ax = fig.add_axes([0.1,0.1,0.8,0.8])
# create polar stereographic Basemap instance.
m = Basemap(projection='stere',lon_0=lon_0,lat_0=90.,lat_ts=lat_0,\
           llcrnrlat=latcorners[0],urcrnrlat=latcorners[2],\
            llcrnrlon=loncorners[0],urcrnrlon=loncorners[2],\
            rsphere=6371200.,resolution='l',area_thresh=10000)
# draw coastlines, state and country boundaries, edge of map.
m.drawcoastlines()
m.drawstates()
m.drawcountries()
# draw parallels.
parallels = np.arange(0.,90,10.)
m.drawparallels(parallels,labels=[1,0,0,0],fontsize=10)
# draw meridians
meridians = np.arange(180.,360.,10.)
m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=10)
ny = data.shape[0];
nx = data.shape[1]
lons, lats = m.makegrid(nx, ny) # get lat/lons of ny by nx evenly space grid.
x, y = m(lons, lats) # compute map proj coordinates.
# draw filled contours.
clevs = [0,1,2.5,5,7.5,10,15,20,30,40,50,70,100,150,200,250,300,400,500,600,750]
cs = m.contourf(x,y,data,clevs,cmap=cm.s3pcpn)
# add colorbar.
cbar = m.colorbar(cs,location='bottom',pad="5%")
cbar.set_label('mm')
# add title
plt.title(prcpvar.long_name+' for period ending '+prcpvar.dateofdata)
plt.show()
再附赠几个网站:
Python 常用的安装Module方式汇总 http://www.jb51.net/article/113084.htm
利用numpy+matplotlib绘图的基本操作教程 http://www.jb51.net/article/112815.htm
利用matplotlib+numpy绘制多种绘图的方法实例  http://www.jb51.net/article/112805.htm



0.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-5-9 10:43:52 | 显示全部楼层
又是那隻貓 发表于 2017-5-7 22:39
帮你编辑了下,发帖请认真,好歹自己也看一下

谢谢!后面补充网站的时候,粘的有点慌张!
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2017-5-7 22:39:16 | 显示全部楼层
帮你编辑了下,发帖请认真,好歹自己也看一下
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2017-5-7 23:49:17 | 显示全部楼层
看看,攒点积分
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-5-8 09:20:20 | 显示全部楼层
多谢楼主分享{:5_213:}
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-5-8 11:09:22 | 显示全部楼层
{:5_235:}{:5_235:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-5-8 18:56:17 | 显示全部楼层
多谢楼主分享
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-5-9 08:10:14 | 显示全部楼层
又是那隻貓 发表于 2017-5-7 22:39
帮你编辑了下,发帖请认真,好歹自己也看一下

好好上了一课哈
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-5-10 19:50:17 | 显示全部楼层
学到啦~楼主
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-5-10 22:34:45 来自手机 | 显示全部楼层
这个很厉害啊!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表