[ncl-talk] problem about Plotting r,theta data

wen wenguanhuan at 163.com
Mon Apr 24 02:46:00 MDT 2017





hi all,
   I am ploting r-theta data. Theta is from 0 to 355 at an interval of 5. However, the there is blank at the angular of 355-0. Do anybody know why. My script is attached bellow. 
;***********************************************
; radar_1.ncl
;
; Concepts illustrated:
;   - Plotting radar (r,theta) data
;   - Adding shading or color fill to areas on a contour plot with missing data
;   - Drawing raster contours
;   - Drawing cell-filled contours
;   - Using triangular meshes to create contours
;***********************************************
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
pi       =  4.0*atan(1.)
  deg2rad  =  pi/180.
  rad2deg  =  45./atan(1.)


   
  a = 6371.
 
  r = ispan(0,500,10) 
  theta  = ispan(0,355,5)


  y = conform_dims((/dimsizes(r),dimsizes(theta)/),r,0)*cos(conform_dims((/dimsizes(r),dimsizes(theta)/),theta,1)*deg2rad)
  x = conform_dims((/dimsizes(r),dimsizes(theta)/),r,0)*sin(conform_dims((/dimsizes(r),dimsizes(theta)/),theta,1)*deg2rad)


;  x = r*sin(theta*deg2rad)
  
 
 
;print(lat+" "+lon )
 
 tcnum = systemfunc("cut -d ' ' -f 1 land_tcnum_time.dat")
ltime = systemfunc("cut -d ' ' -f 2 land_tcnum_time.dat")


 i = 3


 tcdir = "land_gd_tc/"
 tcfile = tcnum(i)+".dat"
 tmp = asciiread(tcdir+tcfile,-1,"integer")
 ntime = dimsizes(tmp)/6
 data = onedtond(tmp,(/ntime,6/))
 
 index = ind(ltime(i).eq.data(:,0))
 lat0 = data(index,2)*0.01
 lon0 = data(index,3)*0.01
 
 a0 = a*cos(lat0*deg2rad)
  
 
  lat = y/(a*deg2rad)+lat0
  lon = x/(a0*deg2rad)+lon0
 
 
 fd = "/gza/g3/wengh/TC/TRMM/"+tcnum(i)+"/"
 fn = systemfunc("ls "+fd+"3B42."+str_get_cols(ltime(i),0,7)+"."+str_get_cols(ltime(i),8,9)+"*.HDF")
 f = addfile(fn,"r") 
 pre = f->precipitation
 
 latgrid = fspan(-49.875,49.875,400)
 longrid = fspan(-179.875,179.875,1440)
 
 pre!0 = "lon"
 pre!1 = "lat"
 
 pre&lon = longrid
 pre&lat = latgrid
 


pr = new((/dimsizes(r),dimsizes(theta)/),typeof(pre))


do i=0,dimsizes(r)-1
 do j=0,dimsizes(theta)-1
  nlat = ind_nearest_coord(lat(i,j),latgrid,0)
  nlon = ind_nearest_coord(lon(i,j),longrid,0)
  pr(i,j) = (/pre(nlon,nlat)/)
 end do
end do
 
 
;print(pr(0,0)+" "+x(0,0)+" "+y(0,0))


;exit
 


graphicname = get_script_prefix_name()  
wks = gsn_open_wks("eps" ,graphicname)  
;gsn_define_colormap(wks,"gui_default")
gsn_define_colormap(wks,"precip2_15lev")
;gsn_define_colormap(wks,"radar")
;gsn_define_colormap(wks,"precip2_17lev")
colors = ispan(4,17,1)
;colors(0) = 2




  cnres                   = True
;  cnres at gsnMaximize       = True


  cnres at sfXArray          = x 
  cnres at sfYArray          = y
  cnres at cnFillOn          = True
  cnres at cnLinesOn         = False
;  cnres at cnFillMode        = "RasterFill"      ; this mode is fastest
  cnres at trGridType        = "TriangularMesh"
  cnres at lbLabelAutoStride = True
;  contour = gsn_csm_contour(wks,pr,cnres)


; The CellFill mode is slower but draws more outlying data
; and lets you fill in the missing value arrays, giving a good
; sense of the circular extent of the plot.


  cnres at cnFillMode            =  "CellFill"
  cnres at cnMissingValFillColor = NhlNewColor(wks,.7,.7,.7)
  cnres at cnLevelSelectionMode = "ExplicitLevels"     ; set manual contour levels
  cnres at cnLevels       = ispan(1,13,1)               ; set min contour level
  cnres at cnFillColors   = colors




  contour = gsn_csm_contour(wks,pr,cnres)
end




--

Best regards,
Guanhuan Wen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170424/ea3812c7/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ??1.png
Type: image/png
Size: 255529 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170424/ea3812c7/attachment.png 


More information about the ncl-talk mailing list