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的更多相关文章

  1. 机器学习笔记(一)- from Andrew Ng的教学视频

    最近算是一段空闲期,不想荒废,记得之前有收藏一个机器学习的链接Andrew Ng的网易公开课,其中的overfiting部分做组会报告时涉及到了,这几天有时间决定把这部课程学完,好歹算是有个粗浅的认识 ...

  2. Matlab绘图基础——绘制等高线图

    % 等高线矩阵的获取 C = contourc(peaks(20),3);              % 获取3个等级的等高线矩阵 % 等高线图形的绘制 contour(peaks(20),10);c ...

  3. 学习笔记之Introduction to Data Visualization with Python | DataCamp

    Introduction to Data Visualization with Python | DataCamp https://www.datacamp.com/courses/introduct ...

  4. python绘制三维图

    作者:桂. 时间:2017-04-27  23:24:55 链接:http://www.cnblogs.com/xingshansi/p/6777945.html 本文仅仅梳理最基本的绘图方法. 一. ...

  5. 44-python-三维画图

    https://www.cnblogs.com/xingshansi/p/6777945.html python绘制三维图   作者:桂. 时间:2017-04-27  23:24:55 链接:htt ...

  6. R2—《R in Nutshell》 读书笔记(连载)

    R in Nutshell 前言 例子(nutshell包) 本书中的例子包括在nutshell的R包中,使用数据,需加载nutshell包 install.packages("nutshe ...

  7. Matplotlib Tutorial(译)

    Matplotlib Tutorial(译) 翻译自:Matplotlib tutorialNicolas P. Rougier - Euroscipy 2012 toc{: toc} 这个教程基于可 ...

  8. LaTeX绘图宏包 Pgfplots package

    Pgfplots package The pgfplots package is a powerful tool, based on tikz, dedicated to create scienti ...

  9. ML 线性回归Linear Regression

    线性回归 Linear Regression MOOC机器学习课程学习笔记 1 单变量线性回归Linear Regression with One Variable 1.1 模型表达Model Rep ...

随机推荐

  1. 基于bootstrsp的jquery富文本编辑器的手冊说明

    重点:当在页面插入文本编辑器后.无法用js/jq的方式去将某些值写入到文本编辑器.如:$("textarea").val("111");$("text ...

  2. Python Windows文件操作

    获得目录和文件名 os.getenv()获取环境变量 os.putenv()设置环境变量 os.getcwd() 获得当前目录 os.chdir(‘要设置的当前目录’) os.listdir() 返回 ...

  3. android电话状态的监听

    电话状态的监听: /*** * 继承PhoneStateListener类,我们能够又一次其内部的各种监听方法 然后通过手机状态改变时,系统自己主动触发这些方法来实现我们想要的功能 */ class ...

  4. OpenGL/GLSL数据传递小记(2.x)(转)

    本篇记录一下关于OpenGL程序中绑定各种GLSL变量的一些注意问题(有些是近期编写代码感受强烈的).以供参考.——ZwqXin.com 本文来源于 ZwqXin (http://www.zwqxin ...

  5. lua学习笔记(十三)

    math库     定义在math中     所有三角函数都使用弧度     指数和对数函数     取整函数     伪随机数math.random         调用时没有参数返回0~1之间的随 ...

  6. 实现Nullable 可空类型

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace demo ...

  7. llinux获取系统时间

    linux中获取当前时间.统计程序运行时间,可以使用gettimeofday()得到毫秒级的时间统计,利用rdtsc指令获取纳秒级时间统计. gettimeofday() 它是一个linux C库函数 ...

  8. IntelliJ IDEA 2014 付费版 免费版比较

    http://www.jetbrains.com/idea/features/editions_comparison_matrix.html Freemarker, Velocity IDE Feat ...

  9. ubuntu安装分区

    ♠ 文件系统 windows下常见的文件系统有FAT, FAT32, NTFS 在linux里可使用的文件系统: Ext2: 早期的格式,不支持日志. Ext3: 是ext2改良版,增加了日志功能, ...

  10. IOS设置图片背景

    在UIViewController里面这样设置: self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageN ...