为什么80%的码农都做不了架构师?>>>
;***这两行指令必须加载,类似于c语言中的库函数
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"begin ;开始标志
a = addfile("/home/yuanm/surface.nc","r") ;文件读取
; 绘图类型(依次为,窗口显示,pdf,ps,ncgm格式)type = "x11"
; type = "pdf"
; type = "ps"
; type = "ncgm"wks = gsn_open_wks(type,"ECMWF_surface") ;创建工作空间
; 时间维数(如该例子中,只有00,08,16,24四个时间段)times = a->time ; 箭头表示数据a中的时间向量ntimes = dimsizes(times) ; 时间维数
;循环结构do it = 0,(ntimes-1),1msl1 = a->msl(it,:,:) ; mean sea level pressuret2m1 = a->t2m(it,:,:) ; temperature at 2mu101 = a->u10(it,:,:) ; 10 metre U wind componentv101 = a->v10(it,:,:) ; 10 metre V wind componentmsl = short2flt(msl1) ;数据类型转换msl = smth9(msl,0.50,0.25,False) ;平滑t2m = short2flt(t2m1)t2m = smth9(t2m,0.50,0.25,False)t2m = t2m-273.15u10 = short2flt(u101)v10 = short2flt(v101)msl = msl/100.msl@units="hPa";绘图参数控制res = Trueres@gsnDraw = False ;为调整绘制顺序,让该图暂时不画出来res@gsnFrame = False
; res@gsnMaximize = True ; Maximize plot in frame
; Add map resources
; res@mpGridAndLimbOn = True ; Turn off lat/lon lines
; res@mpGridLineColor = "gray"res@mpGeophysicalLineColor = "gray"res@pmTickMarkDisplayMode = "Conditional" ; Turn on map tickmarksres@mpMaxLonF = 180. ;经度最大值res@mpMinLonF = 100. res@mpMaxLatF = 50. res@mpMinLatF = -10. res@mpFillOn = False
; 温度场绘图res2 = Trueres2 = resres2@cnFillOn = Trueres2@cnLinesOn = Falseres2@cnInfoLabelOn = Falseres2@cnLevelSelectionMode = "ManualLevels"res2@cnMinLevelValF = 0.0res2@cnMaxLevelValF = 40.0res2@cnLevelSpacingF = 2.0res2@gsnLeftString =" "res2@gsnRightString = " "map1 = gsn_csm_contour_map(wks,t2m,res2)draw(map1)delete(res2)
; Set some contouring resources.res1 = Trueres1 = resres1@cnFillOn = Falseres1@cnLineLabelsOn = True
; res1@cnLineLabelFontAspectF = 0.6res1@cnLineLabelFontColor = "blue"res1@cnLineLabelPerimOn = Falseres1@cnLineLabelPlacementMode = "Constant"
; res1@cnLineLabelConstantSpacingF = 1.0res1@cnLineLabelInterval = 1.0
; res1@cnLineDashSegLenF = 0.20res1@cnInfoLabelOn = False
; res1@cnLevelSelectionMode = "ExplicitLevels"
; res1@cnLevels = (/5800.,5840.,5850.,5860.,5870.,5880.,5890.,5900./)res1@cnLevelSpacingF = 2.0
; res1@cnHighLabelsOn = True
; res1@cnHighLabelString = "H"res1@cnHighLabelBackgroundColor = -1res1@cnHighLabelFontColor = "blue"
; res1@cnHighLabelFontAspectF = 5.0
; res1@cnLowLabelsOn = True
; res1@cnLowLabelString = "L"res1@cnLowLabelBackgroundColor = -1res1@cnLowLabelFontColor = "red"res1@cnLowLabelFontAspectF = 2.0res1@cnLineColor = "Blue"res1@gsnContourLineThicknessesScale = 3.0res1@gsnLeftString = ""res1@gsnRightString = ""map = gsn_csm_contour_map(wks,msl, res1)draw(map)delete(res1);create vector plotres3 = Trueres3 = resres3@vcRefMagnitudeF= 20.0res3@vcRefLengthF= 0.05res3@vcMinDistanceF= 0.03res3@vcGlyphStyle= "CurlyVector"res3@vcRefAnnoOn = True ;do not draw reference vector annotationres3@vcRefAnnoOrthogonalPosF = -0.15 ; vertical positionres3@vcRefAnnoParallelPosF = 0.98res3@vcLineArrowThicknessF = 2.0res3@gsnDraw = Falseres3@gsnFrame = Falseres3@gsnLeftString = " "res3@gsnRightString = " "map2= gsn_csm_vector_map(wks,u10,v10,res3)draw(map2)delete(res3)frame(wks)
end do
end
注:
grib资料与ncl资料大同小异,都是先提取变量,然后做数据处理。
变量查看指令:ncl_filedump "资料名“(如"surface.nal")
然后根据所查看到的变量信息提取变量。