老师课件第五章第二章NCL变量及基本语法_第1页
老师课件第五章第二章NCL变量及基本语法_第2页
老师课件第五章第二章NCL变量及基本语法_第3页
老师课件第五章第二章NCL变量及基本语法_第4页
老师课件第五章第二章NCL变量及基本语法_第5页
已阅读5页,还剩295页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

NCL变量及基本语法第三章数据处理nclnclarrow-Important也许NCL6.0.0NCLV6.0.0和V6.1.x的不同之 6.0.0and 6.1.0and colortable有32gsnSpreadColors为lbLabelAutoStride最多256Namedcolors必须首先被transparent

默认字体默认colortable有256gsnSpreadColors为lbLabelAutoStride为默认函数代码Namedcolorsdonothavetobeaddedtocolormap目主要面向初学者但对于中高级学者会有一些 NCLGraphicsNCL可绘制的图形类TheLine-by-lineCustomizingNCLCommonmistakesandDebuggingCreatingimagesforWeband/orPyNGL/PyNIOPythonNCL可绘制的图形类barcharts,skew-T,windroses,taylorNCL可绘制的图形类Specialized ScatterScatterandlineplotBasedonaofJoelNorris(Scripps)usingdummydataMJOgraphicCourtesyMJOgraphicCourtesyofDennisNCL可绘制的图形类SpecializedLine,fill,andLine,fill,andpattern Contours(line和filled)叠加在地图BrettD.EstradaBrettD.EstradaUfukTuruncoglu,ITUTurkeyClimateChangeScenariosLambertConformalUfukTuruncoglu,ITUTurkeyClimateChangeScenariosEvansEvansplot由JasonEvansofUNSW16mapprojections(816mapprojections(8 Transparencyandimageoverlay–newin ImranNadeem,ImranNadeem,BOKUSpecializedSpecializedSpecializedMultipleoverlays(contoursandoverCCSM4dataCCSM4dataIcethicknessTopomap(linecontours)UVwindsPrimitives(markers,lines,text,SpecializedFilledpolygonswithGraphicbyGraphicbyJonathanVigh,Specialized–SkewT,WRF,windroses,panels,SpecialTemtesand

WindSkewMoreSpecialTemtesand Pie BlankBlank Bar WRFWRFplot TaylordiagramCourtesyofDennisSheaTaylordiagramCourtesyofDennisSheaandAdamPhillips, ShapefileisapopulargeospatialvectordataformatforGISNumerous(and )shapefilescanbefoundbygooglingontheweb. ThethreeThethreetypesofshapefilessupportedbyNCL:Point–locationsofpopulationdataLine–rivers,roads,trailsPolygon–counties,lakesGlobalGlobalAdministrativeAreasdatabase()offersconsistentadministrativeboundariesatmanylevels.Thelevel0database(nations)isgoodtouseforglobalormesoscaleresults,level1isthefirstlevelofsub-nationaladministration(typicallystates/provincesandterritories)whilelevel2offersthesecondlevelofadministrationandispotentiallyusefulforhigh-resolutionplots. TheseTheseshapefilesweredownloadedScriptsareTheThe"AlaskaEssentialFishHabitatSpecies"shapefilewasdownloadedPanelplotsPanelplots–multipleplotsonapageOLROLRfile Multiplecolormaps–newfeaturein FirstFirsttwomapdatabasesbuilt-in;high-resolutionavailableassimpleFromJohnFromJohnErtl,CourtesyCourtesyAdamPhillips,NCARJohnJohnFasullo,NCLGraphicsTheLine-by-lineCustomizingNCLCommonmistakesandDebuggingCreatingimagesforWeband/orPyNGL/PyNIOPython五步绘制NCL图加载定义colormap可选Step1:加载“gsn”Twoways nggraphicsin使用 Step1:加载gsn_csm可识别的CESM规必须存在“degrees_eastor“degrees_north”的“units”informationcontourlineinformationcontourline“basic“metadataaware”接口 tickmarkstickmarksout&lat/lonlabels自动Step1:加载“gsn”load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y= ;101wks=gsn_open_wks("ps","test"); =True ;修改默认绘图设置res@xyLineColor="Blue" ;linecolorres@tiMainString="Thisisatitle" ize=Trueplot=gsn_csm_y(wks,y,res) Step1.5:加数据load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"yy= ;101wks=gsn_open_wks("ps","test"); =True ;plotoptionsres@xyLineColor="Blue" ;linecolorres@tiMainString="Thisisatitle" ize=Trueplot=gsn_csm_y(wks,y,res) ;noXvaluesStep2:“Workstation指绘图PDFPNG有一个默认的colormap(V6.1.0中有改变

Step2:wks=gsn_open_wks(“x11”,“test”);X11windowwks=gsn_open_wks(“ps”,“test”);“test.ps”wks=gsn_open_wks(“png”,“wrf”);“wrf.png”wks=gsn_open_wks(“pdf”,“slp”);“slp.pdf”wks=gsn_open_wks(“eps”,“cn”) ;“cn.eps”““gsn_open_wks是个函数wks”是个变量名你可以为Step2:load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y= ;101wks=gsn_open_wks("ps","test"); =True ;plotoptionsres@xyLineColor="Blue" ;linecolorres@tiMainString="Thisisatitle" ize=Trueplot=gsn_csm_y(wks,y,res) ;noXvaluesStep3:定义一个colormap(可选 文档里(后面讲)选选其他color或自己创 自己创建colortable1生成(RGB三个颜色的数值,范围均是0~255数值越大,2将数值存入xxxx.rgbxxxx”即为该colortable#rg16032 0自己创建colortable3将xxxx.rgb$NCARG_ROOT/lib/ncarg/colormaps/路径下。4测试wks=gsnopengsndefinegsndrawcolormap(wks)此外,也可利用HSVHueSaturation,Value)进行颜色挑选Step3:定义一个colormap(可选load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y= ;101wks=gsn_open_wks("ps","test"); =True ;plotoptionsres@xyLineColor="Blue" ;linecolorres@tiMainString="Thisisatitle" ize=Trueplot=gsn_csm_y(wks,y,res) ;noXvaluesStep4:修改绘图选项(可选ResourcesNCL绘图中的 部分.有超过1,400利用resources修改图有11graphicalobjectscontours,labelbars,legends,maps,primitives,streamlines,textstrings,tickmarks,titles,vectors,XYplots XYXYandtheirlabelbaranditslabelbaranditsmain“xy”-XY“vc”-Vector“tm”-单词首字母大写

“cn”-Contour“ti”-“lb”- 有些以“F结尾,用以表明浮点型resource“gsn”–可被 res=True ;可以任意命名“res”res@mpMinLatF=30;小数点不是必须res@tiMainString=“Thisisatitle”res@tmXBLabelFontHeightF=0.01LineLabelsOn=Trueres@xyLineColors=(/5,7,11/)res@xyLineColors=(/“red”,“green”,“blue”/)res@lgLineThicknesses=(/1.0,2.0,3/)xyLineColor,cnLineColor,gsLineColor,mpGridLineColor,Step4:修改绘图选项(可选load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y= ;101wks=gsn_open_wks("ps","test");=;plotres@xyLineColor= ;lineres@tiMainString="Thisisatitle" ize=Trueplot=gsn_csm_y(wks,y,res) ;noXvaluesStep5:调用相应的绘图 =plot=gsn_csm_contour(wks,data,res)plot=map=gsn_csm_vector_map(wks,u,v,res)phgt=gsn_csm_pres_hgt(wks,data,res) 他们都是函数.等式左端的变量名可任意 Step5:调用相应的绘图load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y= ;101wks=gsn_open_wks("ps","test"); =True ;plotoptionsres@xyLineColor="Blue" ;linecolorres@tiMainString="Thisisatitle" ize=Trueplotplot= ;noXNCLGraphicsTheLine-by-lineCustomizingNCLCommonmistakesandDebuggingCreatingimagesforWeband/orPyNGL/PyNIOPythonLine-by-lineXYplot一条曲XYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFExampleXYplot,“xy1b.ncl”,“xy1c.ncl”等展示的是同一个例子,但逐渐增加的resources以逐步修load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y= ;101wks=gsn_open_wks("ps","xy1a");res plot=gsn_csm_y(wks,y,res) ;noXvaluesExample(colorindex值–xyLineColor–设置线条颜load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y=wks= ;;SetanXYplot=True;将要做些绘图修改res@xyLineColor= ;线条颜色(老方法plot=Index0Index0IndexIndex1当前colorcolorindex2当前colorload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y=

Sidetopic:missingy@_FillValuey@_FillValue=-;Assignmissing = =y@_FillValue =y@_FillValuewks=gsn_open_wks(“ps”,;SetanXYplot =True;We ntosetoptionsres@xyLineColor=2 ;Linecolorplot=gsn_csm_y(wks,y,res)y(10:20)=y@_FillValue =y@_FillValuey(65:85)=Example–xyLineThicknessF–修改线条的粗load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"”;CreatesomeX;Yx=ispan(-y=wks= ;;SetsomeXYplot== 3plotplot=SamplesofnamedcolorsYYaxisXXaxisExample需要的resources–trYMinFtrYMaxFtrXMinFtrXMaxF设定最小、最大值(transformationresources)这些resources同样可应用于contour,vector和streamlineplots..x=ispan(-50,50,1)y=sin(0.0628*x)wks= = = ;5xas

=min(y);Setaxes===x=ispan(-50,50,1)y=sin(0.0628*x)wks= = =“Blue”res@xyLineThicknessF=5 ;5xasthick

-5;Setaxes =-=Example设置TitletiXAxisStringandtiYAxisString将会覆盖“long_name”attributes..x=ispan(-50,50,1)y=sin(0.0628*x)wks= = =“Blue” =2 ;0isdefault(solid)res@xyLineThicknessF=3 ;3xasthickres@trYMinF=min(y)res@trYMaxF=max(y)res@trXMinF=min(x)res@trXMaxF=

设定坐标轴数值范围

="Thisisamain="X="Y有有17中虚线类DashPatternresource中,比如cnLineDashPattern(contourlines),mpGridLineDashPattern(mapgrid等等Example需要的resourcestmXBModetmXBValuestmXBLabels设置底边坐标 注意tickmarkresources所有4个坐标轴自的tickmarks设定,比如:tmYLMode(Yleft),tmYRMode(Yright),tmXBMode(Xbottom),tmXTMode(Xtop)..x=ispan(-50,50,1)y=sin(0.0628*x)wks= = ;Setsomeplot

==

;defaultisforeground;0isdefaultres@xyLineThicknessF= ;3xas

=-==-=

;MinimumYaxis umYaxis;MinimumXaxis umXaxis

="Thisisamain="X="Y =“Explicit” ;指定底边坐标轴的res@tmXBValues=(/-50,-25,0,25,50/);res@tmXBLabels=(/"A","B","C","D","E"/);.plot=gsn_csm_xy(wks,x,y,res)颠颠倒Yaxis,关闭一些tickmarksLine-by-lineXYplot–oneXYplot多条曲PositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFExampleASCIIY(#curves)x(#X可以和Y维同维数,也可以仅是一维的数组,其大小需和Y的最右边维的大小一致(#暂时不用load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl";;Dataonfileisdimensioned#points;by#curves(4),soweneedtoreorder; y!0="npts"y!1=y2=y(ncurves|:,npts|:);把y转变4xwks=gsn_open_wks("ps","xy2a");plot=gsn_csm_yres= plot=gsn_csm_y(500行(500行4列

y= y(0,0)=0y(0,0)=0y(0,1)=y(0,2)=y(0,3)=y(1,0)=y(1,1)=y(1,2)=y(1,3)=y(2,0)=..y(499,0)=Y(499,1)=Y(499,2)=Y(499,3)=0.113023200.113400.1130.254092200.254400.2540.4512200.451400.4510.703955200.704400.7041.01186201.012401.0121.3743201.374401.3741.79057201.791401.7912.25983202.26402.262.78115202.781402.7813.35351203.354403.3543.97575203.976403.9764.64663204.647404.6475.36482205.365405.365..28.1424228.142428.142.1063214.106414.106线线条默用不同类型的虚res@xyMonoDashPattern=从xy2c.ncl至xy2h.ncl是 不断增加了resource包括legendres@xyLineColor=xy2c.nclxy2c.ncl线条颜色改为res@xyLineThicknesses=(/2,3,4,5/)xy2d.nclxy2d.ncl为线条设定不同的颜色和粗 =(/"red","brown","green","blue"/)res@xyMarkLineModes=(/"lines","MarkLines","lines","markers"/)res@xyMarkers=(/0, 16,0,15/)res@xyMarkerColors=(/0,16,0,xy2e.nclxy2e.ncl仅用线条,仅用标识,用标识和线 =xy2f.nclxy2f.ncl添加一个"line="+xy2g.ncl改res@pmLegendOrthogonalPosF0.28 =res@pmLegendWidthF=res@pmLegendHeightF=0.10

;.移xy2h.nclxy2h.ncl移动事先定事先定义 Advanced将XY改变坐标轴(logirregularLine-by-lineXYplot–oneXYplot–multipleUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFSpecialtopic:图 比调整,用viewport“vp”resources:vpWidthF和单单( “viewLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“gsn Contourplotover

andunstructureddataWRFSpecialtopic:“frameframeorpage)可通过resource“gsnFrameandprocedure“frame”来完load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y1=wks=gsn_open_wks(“ps”,res=plot=gsn_csm_y(wks,y1,res)plot=gsn_csm_y(wks,y2,res)

load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y1=y2=cos(0.0628*ispan(0,100,1))+2.wks=gsn_open_wks(“ps”,“xy”) =Trueres@gsnFrame 不翻plot=gsn_csm_y(wks,y1,res)plot= 现在翻load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"y1=y2=cos(0.0628*ispan(0,100,1))+2.wks=gsn_open_wks(“ps”,“xy_frame”) =res@gsnFrame ;不翻res@vpWidthF=res@vpHeightF= = ;靠近页的左边plot= =0.57;超 =0.57;超过Line-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame” izeresource的Contourplotover

andunstructureddataWRFSpecialtopic:在页中最大化图 ize=比会保留但图形的位置和大小会改 ize= ize= ize= ize= ClickBasicgraphicalPositioningPositioningLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFExample简单的contournetCDF数据有_FillValue属性,bygsn_csm暂时不改变load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"tftf=Ttf- ;PrintT’swks=res 暂不设置plotplot=1188valuesNumberofDimensions:2Dimensionsand [lat|33]x[lon|lat: _FillValue:- 标Example“unitslat和lon坐标cnFillOn打开填色设lbOrientation改变labelbarload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"tf=T=tf- ;GetfirsttimeT&lon@unitsT&lon@units“degrees_east”;加上单T&lat@units==res@lbOrientation=res@lbOrientation“Vertical”移动Example改变Colormap为“rainbow”colorcolorload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"tf=addfile("Tstorm.cdf","r")T=tf->t(0,:,:)T&lon@units=“degrees_east”;添加单T&lat@units=wks= ;改变color = = ; =“Vertical”;移plot=gsn_csm_contour(wks,T,res)300<=300<=values<values>=248248<=values<values<Line-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn

andunstructureddataWRFExample数据必须有lat/lon坐标数组“units须是“degrees_east”,“degrees_north”load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"tf=T=tf- ;TwillhavemetadataT有坐标数组和属性printVarSummary(T&lon);T&lonunitswks= ;res 暂不改变plot=运行运行该标本时会得到一些“spline”warnings和一个suggestion:“YoumaywanttosetgsnAddCyclictoFalsetoavoidawarning”1920valuesNumberofDimensions:2 [lat|40]x[lon|lat:[-lat:[-环性lon:[-timetime1 unitsDegreesres@gsnAddCyclic=“printVarSummary(T&lon)输出结Type:integer48valuesNumberofDimensions:1Dimensionsandsizes: [lon|48]unitsunits Example手动(manually)设置Contour还需用另3resources:cnMinLevelValF,cnMaxLevelValF,cnLevelSpacingFload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"(“ExplicitLevels”另一种模式,用 tf=addfile("meccatemp.cdf","r")T=tf->t(0,:,:)wks=gsn_open_wks("ps","contour2b") =True =LevelSelectionMode="ManualLevels" =195 ;LevelSelectionMode="ManualLevels" =195 ;最小值 =328 ;最大值 =2.25 ;间距Example改变Colorload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"tf=addfile("meccatemp.cdf","r")T=tf->t(0,:,:)wks= ===;Min=;Max=; = ;打开颜plot=gsn_csm_contour_map(wks,T,res)Example关闭等值线和labelbarbox的线仅适用colormap中的一部分的颜gsnSpreadColorStartgsnSpreadColorEnd指定colormap中的颜色段cnLinesOn打开或关contourlbBoxLinesOn-打开或关labelbarboxgsnSpreadColorStart=2gsnSpreadColorEnd=-1gsnSpreadColorStart=..tf=addfile("meccatemp.cdf","r")T=tf->t(0,:,:)wks=gsn_open_wks("ps","contour2d") = =FalseLevelSelectionMode="ManualLevels"=;最小=;最大=;间res@res@gsnSpreadColorStart ;起始于colorindex ;打开等值线= ;关闭等值线线= ;关闭lbarbox线plotplot=..Sidetopic:tfSidetopic: =wks= = =FalseLevelSelectionMode="ManualLevels"=;Min=;Max=;

;= ;关闭线= ;关闭lbarboxplot=ContouringexercisesandClickContourplotContoursovermapexercises(set1)Contoursovermapexercises(setLookfor“contour”categories:Contours:nomapContourlabelsAdvanced 控制每一条等值线的colorand/orLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

WRFSpecialtopiconcontouring1D坐标数组(递增或递减的−2Dlon/lat数组(曲线的,WRFfiles, lite使用sfXArraysfYArrayres@sfXArray=res@sfYArray=

WRFdata也用这方 非规则coordinates(1DX,Y,Z数组res@sfXArray=res@gsnAddCyclicres@gsnAddCyclicFalseExample:2Dlat/lonDimensionsandsizes: [lat|Dimensionsandsizes: [lat|384]x[lon|320]NumberOfAttributes:7time: units long_name: gridboxmeanicethicknesscoordinates:ijtime_FillValue:1e+30time_rep: 文件有two-dimensionallat/lon变floatfloatTLON(lat,lonlong_name: gridcenterlongitudeunits: floatTLAT(lat,lonlong_name: gridcenterlatitudeunits: load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"f=addfile("iceh_mavg.0014- =f->hi(0,:,:)

;Ice;注意没有坐标数wks=gsn_open_wks(”ps","ice") ;ice.ps = f->TLON;2Dlat/lon数组必须f->TLAT;“hi=;=;指定最南纬plot=gsn_csm_contour_map_polar(wks,hi,res)Example:1Dx,y,z数据是ARPEGE1DlatlonVariable:SUTOPRSU(filevariable)Type:floatNumberofVariable:SUTOPRSU(filevariable)Type:floatNumberofDimensions:Dimensionsandsizes: [time_counter|240]x[jpjb|1]x[jpib|6232]time_counter:[ 0..239]NumberOfAttributes:4short_name:PRECITOTALEgridtype: long_name: TotalPrecipitationunits: Variable:Variable:bt42_lat(filevariable)Type:doubleNumberofDimensions:Dimensionsand [jpjf|1]x[jpif|Variable:bt42_lon(filevariable)Type:doubleNumberofDimensions:Dimensionsand [jpjf|1]x[jpif|loadg=f=wks=gsn_open_wks("x11","arpege") =g->bt42_lon(0,:);1D=g-

== = LevelSelectionMode="ExplicitLevels" =fspan(0,30,201) 关闭box LambertEqualArea";地图contour=gsn_csm_contour_map(wks,f->SUTOPRSU(0,0,:),res)RastersmoothedRastersmoothedFillMode=RasterSmoothingOn=这个Raster效果好RasterRasterExamplesofcontouringnon-rectilinearClickon“non-uniformgrids/randomAdaptivegridsORCAgridsTriangularmes Line-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRF绘图样CindyBruyèreAbby 是“black-box”;过的customization,加载必须的

loadloadhgt=wrf_user_getvar(f,”HGT”,0)wks=gsn_open_wks(“ps”,”hgt”);蓝色的resources表明特别的蓝色的resources表明特别的WRF-NCLresourcesFillOn=;有一些特别的wrf_xxxxresources ="GEOGRIDFIELDS”res@ContourParameters=(/250.,3500.,100./)contour=wrf_contour(f,wks,hgt,res)pltres=Truempres=True

wrf_map_overlays会查看文档以决定地图投影方 =slp=wrf_user_getvar(f,“slp”,0)t2=wrf_user_getvar(f,“T2”,0)u10slp=wrf_user_getvar(f,“slp”,0)t2=wrf_user_getvar(f,“T2”,0)u10=wrf_user_getvar(f,“U10”,0)v10=wrf_user_getvar(f,V10“,0)

WRF-NCL线条/填色的等值线wksgsn_open_wks(“ps” ;Line;Line = =LineThicknessF= =;Filled =True =; =Trueov@NumVectors=47 =;Overlayeverythingonampres=Truepltres=TrueSampleSampleWRF版.有Line-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFExample−gsnPolar,gsnLeftString,load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"a=u=a-v=a-

;;读第一个时;.和第15 = ;Northernwks = ;Northern ="Zonal;Leftres@gsnRightString="meters/second";Rightres@gsnCenterString=" ;Notusedlot=lot=notusedheretickmarkresources在这里不起作用这些经res@vcRefMagnitudeFres@vcRefMagnitudeF=; 0.09;res@vcMinDistanceF=0.02;res@res@vcGlyphStyle= ;打开curlyres@res@vcLineArrowThicknessF= ;3=res@vcMonoVectorLineColor= =VectorplotClickon“vectorplotMorenclnclresv2@vcMapDirectionLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFFunctions有gsn_add_polygongsn_add_polyline,gsn_add_polymarker,gsn_add_text记号线条和多边形的resources以“gs(gsMarkerColor,gsLineThicknessF,gsFillColor,gsEdgesOn,etc.)文本的resources以“tx(txFontHeightFtxJusttxFont,txFontColor,etc.)Example–mpDataBaseVersion,mpLimitMode,mpMinLatF,mpMaxLatF,mpMinLonF,mpMaxLonF,mpFillOnload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"wksgsn_open_wks("ps","poly3c"打开 = res@mpDataBaseVersion="MediumRes";中等分辨率 =“Earth..4” ;有其他国家的分类res@mpOutlineBoundarySets="AllBoundaries" =

=-=-==

放大澳大利 ="Australianstatesandmap=gsn_csm_map(wks,res) ;DrawmapExample将mapcodeload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"functionAustralia_map(wks,mode:string)localresres ;建立resourceif(mode.eq."create")thenres@gsnFrame=Falseres@gsnDraw=Falseendif = =False res@mpDataBaseVersion="MediumRes"; ="Earth..4" res@mpOutlineBoundarySets="AllBoundaries"

==- =-== ="Australianstatesandmap=gsn_csm_map(wks,res);Createdrawdefaultmap;--Maincodewks=gsn_open_wks("ps","poly3d")map=Australia_map(wks,"draw")Example (略)wks=gsn_open_wks("ps","poly3e");Openmap=Australia_map(wks,"create");生成有5个;生成有5个lat/lon的数lat=(/-12.46,-31.95,-23.70,-37.81,-lon=(/130.84,115.86,133.88,144.96, =Truemres@gsMarkerSizeF ;放大记mres@gsMarkerColor=;将记号添加至地图dum=;绘制地图和记号Example(略)wks=gsn_open_wks("ps","poly3f");Open;Createthemapsowecanaddlines,strings,andmarkers.map=Australia_map(wks,"create");Createarrayswithcitiesandlat/loncities=(/"Darwin","Perth","AliceSprings","Melbourne","Sydney"/) =(/-12.46,-31.95, =(/130.84, ;Attach;Attachmarkersto =True;Makeit;Filleddum1=;Attachtextto =True =;Defaultis;defaultisdum2= ;Drawingthemapdrawsthemarkers.PrimitivesClickPrimitivesexercises(set1)Primitivesexercises(set2)Primitivesexercises(setMoreLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFExampleSpecialtopicpanelingplots(在一页中绘制多个plots)Plots必须是同样的大小可以设置公用的labelbar–gsnDraw,如果绘制不同大小请使用vpXFvpYF,vpWidthF,vpHeightFresourcesload"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"load"$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"f=addfile("wrfout_d01_2003-07-15_00:00:00.nc",p=f-p=p*0.01p@units="hPa"

气压,;转换为;res@res@gsnDraw=res@gsnFrame=;Don'tdraw;Don'tadvancewks=gsn_open_wks("ps","panel1a") =Trueplot1=plot1=gsn_csm_contour(wks,p(0,:,:),res)plot2=gsn_csm_contour(wks,p(3,:,:),res)plot3=gsn_csm_contour(wks,p(5,:,:),res)plot4=gsn_csm_contour(wks,p(7,:,:),res);Createapanelofplotswith2rowsand2columns...f=addfile("wrfout_d01_2003-07-15_00:00:00.nc", =f- =p*0.01p@units="hPa"

;Read;Convertto;Updateunitswks=gsn_open_wks("ps","panel1b") = ;Plotoptions

==

;Don'tdraw;Don'tadvance =True

;绘; =new(4,graphic) 组表示plots(0)=gsn_csm_contour(wks,p(0,:,:),res)plots(1)=gsn_csm_contour(wks,p(3,:,:),res)plots(2)=gsn_csm_contour(wks,p(5,:,:),res)plots(3)=gsn_csm_contour(wks,p(7,:,:),res);2rows,2columns22x2What’sWhat’s“wrong”withthese.. = ;PlotoptionsLevelSelectionMode=LevelSelectionMode==-=;=2plots(0)=gsn_csm_contour(wks,p(0,:,:),res)plots(1)=gsn_csm_contour(wks,p(3,:,:),res)plots(2)=gsn_csm_contour(wks,p(5,:,:),res)plots(3)=gsn_csm_contour(wks,p(7,:,:),res)...

= ;Plotoptions

===

;Don'tdraw;Don'tadvance;TurnonLevelSelectionMode=

=-=

;Setcontourlevels;thesameforeach=设panel=设panel=panel改labelbar宽度 ="Perturbationpressure False关闭各个plot的plots=new(4,graphic)doi=0,3res@tiMainString="bottom-topindex"+i enddo;Createapanelofplotswith2rowsand2panelres@panelres@txString=22x311行3pres@pres@gsnPanelFigureStrings="b_tindex"+3x2添加屏幕输出关于paneledplotsdebug可以强制plotsPanelingClickon“panelingMoreLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRF

;Overlay矢量和等值线至地图 =“” =“”关闭右边关闭左边=;;Resourcelist用以共享. =True = =;don't;don'tadvance = =f- =f-speed=speed=;;最后绘制地图时,也会同时绘制等;和矢量;;==;=- ;将ref移至plot;vectorref;lengthofvec = ="CurlyVector";curlyvectorsvcres@vcRefMagnitudeF=20 移打开颜;spanfullcolor;不绘制线res@gsnSpreadColors=True =False= =contours=gsn_csm_contour( vectors=gsn_csm_vector(wks,u,v,vcres)不同之不同之处contours=gsn_csm_contour( vectors=gsn_csm_vector(wks,u,v,vcres)contours=gsn_csm_contour(wks,speed(::4,::4),cnres)vectors=gsn_csm_vector(wks,u(::4,::4),v(::4,::4),vcres)OverlayCanalsogotothe“functions”linkonExamplespageandsearchfor“overlay”.LotsofexamplesusethisLine-by-lineXYplot–oneXYplot–multiplePositioningplotsonaUseof“frame”Useof“gsn Contourplotover

andunstructureddataWRFres@tiMainString=“Happy~F35~r~F~Valentine’sDay”res@tiXAxisString=“m~S~2”FunctioncodeNCLGraphicsTheLine-by-lineCustomizingNCLCommonmistakesandDebuggingCreatingimagesforWeband/orPyNGL/PyNIOPython回 时使用X11window;然后在用moveNCLGraphicsTheLine-by-line设置NCL环CommonmistakesandDebuggingCreatingimagesforWeband/orPyNGL/PyNIOPython改变“functioncode”为~默认是冒号改变默认的color “.hluresfile::!Color : :Functioncode默认 :!Setsizeofx11

::NCLGraphicsTheLine-by-lineCustomizingNCLDebuggingCreatingimagesforWeband/orPyNGL/PyNIOPython(“xyLineColour”isnotaresourceinXyPlotatthis拼写错误“TheunitsattributeoftheYcoordinatearrayisnotsettooneoftheallowableunitsvalues(i.e.'degrees_north').Yourlatitudelabelsmaynotbecorrect.”正在使用的colormap中没有灰色(使用以增加灰色或者or设置为含有灰色的colormaps).“_NhlCreateSplineCoordApprox:AttempttocreatesplineapproximationforYaxisfailed:consideradjustingtrYTensionFvalue”NCLGraphicsTheLine-by-lineCustomizingNCLCommonmistakesandCreatingimagesforWeband/orPyNGL/PyNIOPython对于NCL否则,使用“batch”模式.即,写 ncl .以下地址 print(min(xandprint(max(x));最大/

NCLGraphicsTheLine-by-lineCustomizingNCLCommonmistakesandDebuggingPyNGL/PyNIOPython使用“png”输出并加大图形的大小 =wtype@wkWidth=2500;Defaultis1000wtype@wkHeight=2500wks=..如果“pngPSPDF“convert”ImageMagickMacportinstallLinuxyuminstallimagemagickapt-getinstallconvert–geometry2000x2000-density300-trimxy.ps“-density300IntroductiontoNCL首先输出“ps(或“pdf”)使用“delete(wks)”以强制关闭PS..filename=

=filename+=filename+

;PS(orPDF)file;PNGfilewks=res=..plotgsn_csm_xxxx(wks,data,res) ;重要!options=“–geometry2000x2000-density300-trimsystem(“convert”+options+psf+“”+NCLGraphicsTheLine-by-lineCustomizingNCLCommonmistakesandDebuggingCreatingimagesforWeband/orWheretoDownloadyourowndatasets(highlymended)orusesampleWritesimplescriptstoreaddataandplotSeescriptsBrowse“Examples”onNCLReviewgraphicalexamplesusedinTrytheStartwritingyourownNCLForverybasicinformation,readFAQonNCLRefertoindexinbackofbookforwebIntroductiontoNCLExercises,datafiles,scriptsusedinMaryHaleyWhatnew(graphical)thingsyoucandoinReadinexistingimagesandoverlayNCLgraphicsontopUsenamedcolorswithoutaddingthemtoyourcolormapUsemorethanonecolormap(colortable)perUsemorethan256colorsperres@xyLineColor=res@xyLineColor=YouYoucanusecolorswithbutthatcolormustbeinyourcolortable.Closestmatchisused,whichistheassociatedwithindex8inthe650650namedUseapredefinedcolorloadwks=gsn_open_wks("ps","color1”)Pickacolortablefromthe

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论