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