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
  [email protected] = "(C)"                        ; 改变单位
  [email protected] = "(mb)"                       ; 改变单位

  xwks = gsn_open_wks("x11","gsun02n")      ; 打开x11的工作空间.

  plot = gsn_contour(xwks,temp,False)       ; 绘制一个等值线图

;----------- Begin second plot -----------------------------------------

  resources                 = True       ; 资源设置

  [email protected] = False      ; 关闭绘制一种颜色的方案

  [email protected]    = "Temperature (C)"  ; 标题

  plot = gsn_contour(xwks,temp,resources)  ; 绘制等值线图

;----------- Begin third plot -----------------------------------------

  [email protected]          = True        ; 打开等值线图填充
  [email protected] = False       ; 关闭等值线图单线填充
  [email protected]   = True
  [email protected]   = True

  [email protected]    = [email protected]_name
  [email protected]    = [email protected]_name
  [email protected]         = lon
  [email protected]         = lat

  plot = gsn_contour(xwks,temp,resources)   ; 绘制等值线图

;---------- Begin fourth plot ------------------------------------------

  [email protected]     = True     ; 使用solid填充
  [email protected]       = False    ; 使用复杂颜色
  [email protected]        = False    ; 线条标签
  [email protected]         = False    ; 信息标签
  [email protected]             = False    ; 等值线

  [email protected] = "Always" ; 工具栏
  [email protected]             = False    ; 关闭周长

  [email protected]    = [email protected]_name
  [email protected]tiMainFont      = 26
  [email protected]     = 26
  [email protected]     = 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

  [email protected]    = [email protected]_name

  plot = gsn_contour(xwks,pres,resources) ; 绘制一个等值线图

  print(temp(2:5,7:9))             ;输出temp变量

  print(temp!0)                    ; 输出temp的一维名称
  print(temp!1)                    ; 输出temp的二维名称
  print([email protected]_name)            ; 输出属性long_name和units
  print([email protected])
  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
时间: 2024-12-19 18:44:28

Example 2 - contour plots的相关文章

Matplotlib Tutorial(译)

Matplotlib Tutorial(译) 翻译自:Matplotlib tutorialNicolas P. Rougier - Euroscipy 2012 toc{: toc} 这个教程基于可以从scipy lecture note得到的 Mike Müller的教程. 源代码可从这里获得.图像在figures文件夹内,所有的脚本位于scripts文件夹. 所有的代码和材料以Creative Commons Attribution 3.0 United States License (C

LaTeX绘图宏包 Pgfplots package

Pgfplots package The pgfplots package is a powerful tool, based on tikz, dedicated to create scientific graphs. Contents 1 Introduction 2 The document preamble 3 2D plots 3.1 Plotting mathematical expressions 3.2 Plotting from data 3.3 Scatter plots

《R in Nutshell》 读书笔记(连载)

R in Nutshell 前言 例子(nutshell包) 本书中的例子包括在nutshell的R包中,使用数据,需加载nutshell包 install.packages("nutshell") 第一部分:基础 第一章 批处理(Batch Mode) R provides a way to run a large set of commands in sequence and save the results to a file. 以batch mode运行R的一种方式是:使用系统

su命令2

震数据处理软件-SU 之使用方法 第一章帮助工具 1.          suhelp    显示可执行的程序和Shell脚本.2.          suname   列出SU中各项命令的名字和简短描述,以及编码的地址.3.          sudoc    得到编码的DOC列表,列出SU中各条目的在线文档.4.          sufind    在自述文档中得到信息,使用给定的字符串查找SU命令.5.          Demo演示程序:l          SU软件包中有一套Shel

Matlab中所有自定义的函数

Functions By Category | Alphabetical List Language Fundamentals Entering Commands ans Most recent answer clc Clear Command Window diary Save Command Window text to file format Set display format for output home Send cursor home iskeyword Determine wh

机器学习笔记- from Andrew Ng的教学视频

最近算是一段空闲期,不想荒废,记得之前有收藏一个机器学习的链接Andrew Ng的网易公开课,其中的overfiting部分做组会报告时涉及到了,这几天有时间决定把这部课程学完,好歹算是有个粗浅的认识. 本来想去网上查一查机器学习的书籍,发现李航的<统计学习方法>和PRML(Pattern Recognition And Machine Learning)很受人推崇,有空再看吧. 然后在图书馆碰到了天佑,给我推荐了coursera这个网站,上面有Andrew Ng针对网络版的机器学习教程,挺好

Python之那些好玩的图画

前言: matplotlib 是Python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图.本文将以例子的形式分析matplot中支持的,分析中常用的几种图.其中包括填充图.散点图(scatter plots).. 条形图(bar plots).等高线图(contour plots). 点阵图和3D图,下面来一起看看详细的介绍: 一.填充图 参考代码 简要分析 这里主要是用到了fill_between函数.这个函数很好理解,就是传入x轴的数组和需要填充的两

matlab 等值线函数 contour

matlab 等值线函数 contour contour是等高线绘制函数我并没怎么用过这个函数,只是参照help将上面的英文翻译一下,如果有错误,请大家提出来.contour(Z)根据矩阵Z画出等高线,Z是以x,y为平面的高度.Z必须是一个至少二维的矩阵.等高线的数量和水平线的值将根据Z值的最小值和最大值自动选择.x,y轴的范围是[1:n]和[1:m],[m,n]=size(Z)contour(Z,n)用n条水平线来绘制Z的等高线.contour(Z,v)是以向量v中的数据来绘制矩阵Z的等高线.

Generate contour plot in GNU Octave

Step 1: generating the grid points for the 2D contour plot: [xx, yy] = meshgrid(x_start:dx:x_end, y_start:dy:y_end); Step 2: Calculate the data values at those grid points: where x, y, z are three arrays holding all the source data. zz = griddata(x,