load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin ;*******1. read in the ascii data********* nrow=37 ncol=47 Ts=asciiread("Ts_matrix.txt",(/nrow,ncol/),"integer") ;******1.1 exame the readin data ********** ts_line=new(nrow,string) do i=0,nrow-1 ts_line(i)=str_concat(sprinti ("%1i,", Ts(i,:))) end do asciiwrite("ts_line.txt",ts_line) ;******2. give the cordination************ lat =fspan(28.875,37.875,37) lat!0 ="lat" lat&lat =lat lat@units = "degrees_north" lat@long_name = "Latitude" lon=fspan(110.875,122.375,47) lon!0 ="lon" lon&lon =lon lon@units ="degrees_east" lon@long_name ="Longtitude" Ts!0 ="lat" Ts&lat =lat Ts!1 ="lon" Ts&lon =lon ;******3.plot the data********************* wks= gsn_open_wks("png","Ts_results") res = True res@gsnAddCyclic = False res@gsnMaximize = False ;res@gsnFrame = False res@vpYF = 0.90 ; Move plot up a little to make room for table res@mpMaxLatF = max(lat) res@mpMinLatF = min(lat) res@mpMinLonF = min(lon) res@mpMaxLonF = max(lon) res@mpFillOn =True res@mpLandFillColor ="gray" res@mpOceanFillColor ="SkyBlue" res@mpInlandWaterFillColor ="blue" res@mpOutlineOn =True res@mpOutlineBoundarySets ="Geophysical" res@mpDataBaseVersion="MediumRes" res@mpDataSetName="Earth..4" res@mpOutlineSpecifiers = "China:states" ;set cn res@cnFillOn =True res@cnFillMode ="RasterFill" res@cnLevelSelectionMode ="ExplicitLevels" res@cnLevels =(/0.5,1.5,2.5,3.5/); Use a value that's between the two values in the data. data includs (0,1,2,3,4,) res@cnFillColors =(/"white","green","brown1","magenta1","grey"/) res@cnLinesOn =False ;set the label ;res@lbLabelPosition ="center" res@lbLabelAlignment = "InteriorEdges" ; res@lbLabelStrings =(/"A","B","C","D"/) res@lbLabelFont =25 ; times-roman res@lbLabelFontHeightF =0.01 ; height in NDC res@lbFillColors =(/"white","green","brown1","magenta1","grey"/) res@lbBoxLinesOn = False res@pmLabelBarWidthF =0.3 res@pmLabelBarHeightF =0.1 ;simply set the tick mark res@pmTickMarkDisplayMode = "Always" ;set the grid line ;using the tm setting the grid line,it is in line with the tick mark.suggested res@tmXMajorGrid =True res@tmXMajorGridLineDashPattern =11 res@tmXMajorGridLineColor ="grey" res@tmXMajorGridThicknessF =1.0 ; 1.0 is the default res@tmYMajorGrid =True res@tmYMajorGridLineDashPattern =11 res@tmYMajorGridLineColor ="grey" res@tmYMajorGridThicknessF =1.0 ; 1.0 is default ; set the title res@tiMainString ="Ts evaluation" res@tiMainFontHeightF =0.015 res@tiMainOffsetYF =0.01 res@tiMainPosition ="Center" res@gsnFrame = False plot=gsn_csm_contour_map(wks,Ts,res) getvalues plot "vpXF" : vpx ; NDC location of left Y axis "vpWidthF" : vpw ; vpx + vpw = NDC location of right Y axis end getvalues ;---Get bounding box of plot, so we can position the table correctly bb = NhlGetBB(plot) bot = bb(1) ; bottom edge of plot (below the labelbar) ;set the table ncr =(/2,5/) y_dist = 0.01 ; distance to move away from bottom of plt table_height = 0.15 y1 = bot-y_dist-table_height y2 = bot-y_dist x1 = vpx x2 = vpx+vpw ; same width as plot. x = (/x1,x2/) y = (/y1,y2/) text =(/ (/"BIAS","FAR","POD","POFD","HSS"/),\ (/"0","0","0","0","0"/)/) restbl =True restbl@txFontHeightF =0.02 restbl@gsFillColor ="transparent" gsn_table(wks,ncr,x,y,text,restbl) frame(wks) ;****************************************** end