Example 2 - contour plots
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
begin
cdf_file = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/contour.cdf","r")
temp = cdf_file->T(0,0,:,:) ; 变量temperature
Z = cdf_file->Z(0,0,:,:) ; 变量geopotential height
pres = cdf_file->Psl(0,:,:) ; 变量pressure at mean sea level
lat = cdf_file->lat ; 变量latitude
lon = cdf_file->lon ; 变量longitude
temp = temp - 273.15 ; 温度转换 Kelvin -> Celsius
pres = pres * 0.01 ; 气压转换 Pa -> mb
temp@units = "(C)" ; 改变单位
pres@units = "(mb)" ; 改变单位
xwks = gsn_open_wks("x11","gsun02n") ; 打开x11的工作空间.
plot = gsn_contour(xwks,temp,False) ; 绘制一个等值线图
;----------- Begin second plot -----------------------------------------
resources = True ; 资源设置
resources@cnMonoLineColor = False ; 关闭绘制一种颜色的方案
resources@tiMainString = "Temperature (C)" ; 标题
plot = gsn_contour(xwks,temp,resources) ; 绘制等值线图
;----------- Begin third plot -----------------------------------------
resources@cnFillOn = True ; 打开等值线图填充
resources@cnMonoFillPattern = False ; 关闭等值线图单线填充
resources@cnMonoFillColor = True
resources@cnMonoLineColor = True
resources@tiXAxisString = lon@long_name
resources@tiYAxisString = lat@long_name
resources@sfXArray = lon
resources@sfYArray = lat
plot = gsn_contour(xwks,temp,resources) ; 绘制等值线图
;---------- Begin fourth plot ------------------------------------------
resources@cnMonoFillPattern = True ; 使用solid填充
resources@cnMonoFillColor = False ; 使用复杂颜色
resources@cnLineLabelsOn = False ; 线条标签
resources@cnInfoLabelOn = False ; 信息标签
resources@cnLinesOn = False ; 等值线
resources@pmLabelBarDisplayMode = "Always" ; 工具栏
resources@lbPerimOn = False ; 关闭周长
resources@tiMainString = Z@long_name
resources@tiMainFont = 26
resources@tiXAxisFont = 26
resources@tiYAxisFont = 26
plot = gsn_contour(xwks,Z,resources) ; 绘制等值线图
;---------- Begin fifth plot ------------------------------------------
cmap = (/(/0.,0.,0./),(/1.,1.,1./),(/.1,.1,.1/),(/.15,.15,.15/),\
(/.2,.2,.2/),(/.25,.25,.25/),(/.3,.3,.3/),(/.35,.35,.35/),\
(/.4,.4,.4/),(/.45,.45,.45/),(/.5,.5,.5/),(/.55,.55,.55/),\
(/.6,.6,.6/),(/.65,.65,.65/),(/.7,.7,.7/),(/.75,.75,.75/),\
(/.8,.8,.8/),(/.85,.85,.85/)/)
gsn_define_colormap(xwks,cmap) ; 定义一个新的颜色map
resources@tiMainString = pres@long_name
plot = gsn_contour(xwks,pres,resources) ; 绘制一个等值线图
print(temp(2:5,7:9)) ;输出temp变量
print(temp!0) ; 输出temp的一维名称
print(temp!1) ; 输出temp的二维名称
print(temp@long_name) ; 输出属性long_name和units
print(temp@units)
print(temp&lat) ; 输出变量lat
print(temp&lon) ; 输出变量lon
ascii_file = "data.asc" ;创建ASC11文件名
system("/bin/rm -f " + ascii_file) ; 移除asc11文件
asciiwrite(ascii_file,temp(7:3:2,0:4)) ; 写入ASC11
delete(plot) ;清除
delete(temp)
delete(resources)
end
Example 2 - contour plots的更多相关文章
- 机器学习笔记(一)- from Andrew Ng的教学视频
最近算是一段空闲期,不想荒废,记得之前有收藏一个机器学习的链接Andrew Ng的网易公开课,其中的overfiting部分做组会报告时涉及到了,这几天有时间决定把这部课程学完,好歹算是有个粗浅的认识 ...
- Matlab绘图基础——绘制等高线图
% 等高线矩阵的获取 C = contourc(peaks(20),3); % 获取3个等级的等高线矩阵 % 等高线图形的绘制 contour(peaks(20),10);c ...
- 学习笔记之Introduction to Data Visualization with Python | DataCamp
Introduction to Data Visualization with Python | DataCamp https://www.datacamp.com/courses/introduct ...
- python绘制三维图
作者:桂. 时间:2017-04-27 23:24:55 链接:http://www.cnblogs.com/xingshansi/p/6777945.html 本文仅仅梳理最基本的绘图方法. 一. ...
- 44-python-三维画图
https://www.cnblogs.com/xingshansi/p/6777945.html python绘制三维图 作者:桂. 时间:2017-04-27 23:24:55 链接:htt ...
- R2—《R in Nutshell》 读书笔记(连载)
R in Nutshell 前言 例子(nutshell包) 本书中的例子包括在nutshell的R包中,使用数据,需加载nutshell包 install.packages("nutshe ...
- Matplotlib Tutorial(译)
Matplotlib Tutorial(译) 翻译自:Matplotlib tutorialNicolas P. Rougier - Euroscipy 2012 toc{: toc} 这个教程基于可 ...
- LaTeX绘图宏包 Pgfplots package
Pgfplots package The pgfplots package is a powerful tool, based on tikz, dedicated to create scienti ...
- ML 线性回归Linear Regression
线性回归 Linear Regression MOOC机器学习课程学习笔记 1 单变量线性回归Linear Regression with One Variable 1.1 模型表达Model Rep ...
随机推荐
- Bmob实现android云端存储
代码地址如下:http://www.demodashi.com/demo/12547.html 前言 一直很困惑,android到底能不能将本地数据传到一个公共的云端,让云端实现数据库功能,这样的话, ...
- 操作log.py
# 把双数日期的日志,里面给随便写点东西# 1.获取到log目录下的所有文件os.walk()# 2.根据文件名来判断,是否是双数日期,分割字符串,取到日期# 3.12%2==0# 4.打开这个文件 ...
- session的两个小案例
学完了session,写两个小案例加深一下对session的巩固. 1. 用户登陆案例 登陆html页面提交后,将参数带给处理登陆的servlet,该servlet将获得登陆的用户名和密码,并将这些信 ...
- 史上最全的CSS hack方式一览(转)
做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我们会极不情愿的使用这个不太友好的方式来达到大家要求的页面表现.我个人是不太推荐使用hack的,要知道 ...
- Vim使用技巧(1) -- 普通模式技巧 【持续更新】
直观的来一张键盘图先 符号快捷键 . //重复上次修改 ^ //光标快速跳转到当前行开头 $ //光标快速跳转到当前行结尾 f{char} //光标快速跳转到当前行下一个{char}字符,{char} ...
- hasOwnProperty()与in操作符的区别
hasOwnProperty() 判断属性是否是实例化(不包括原型)的属性, 存在会返回true; 否则, 返回false in 无论属性是存在实例本身中, 还是原型对象中, 存在会返回true; ...
- /etc/cron.d添加定时任务脚本后不生效
原因:定时任务脚本中的命令中包含了环境变量,crontab不能读取到环境变量. vim /etc/cron.d/mymon #mymon内容如下: * * * * * root cd $GOPATH/ ...
- Python读取文件数据
1题目要求: 文本文件有这些数据,需要的只有其中的5个属性,如下颜色标记 像以下的数据达到75万组: 1product/productId: B0000UIXZ4 2product/title: Ti ...
- <mark>元素----黄色背景
当需要引用其他人的内容,或者想要重点标注一段文本时可以使用<mark>元素.这样浏览器会给<mark>中的文本添加黄色背景. 效果图如下:原文:HTML5 - 使用<m ...
- APNS的推送机制 3
APNS的推送机制 首先我们看一下苹果官方给出的对iOS推送机制的解释.如下图 Provider就是我们自己程序的后台服务器,APNS是Apple Push Notification Service的 ...