[ncl-talk] some question when ploting wind barb?

dyjbean at gmail.com dyjbean at gmail.com
Thu Sep 1 04:00:10 MDT 2016


hi,
 when i plotted wind barb, i  consulted the barb_6.ncl , the following is the figure:
    
there are 48 times every day including missing value, i extract some times from on day for testing,but i cannot get rid of the two vertical lines,
according to the barb_6.ncl example, there is no vertical line.

the following is my script:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

begin
ymin = 150.            ; min height to be plotted
  ymax = 3030.            ; max height to be plotted
  ncol = 3                ; number of columns of data (Each ascii file has the same number of columns)
  wbcrit = 100.            ; minimum distance in meters between wind barbs 

  fils = systemfunc("ls test*.txt")
  nfiles = dimsizes(fils)
  print(nfiles)
  
  wks = gsn_open_wks("png","barb_test_jsy")     ; send graphics to PNG file
  gsn_define_colormap(wks,"WhBlGrYeRe")
  do gg = 0,nfiles-1
     t = asciiread(fils(gg) ,(/-1/), "float")
     nlvl = dimsizes(t)/ncol           ; figure out number of levels in the ascii file
     delete(t)
     TestData = asciiread(fils(gg) ,(/nlvl,ncol/), "float")
     z    = TestData (:,0)  ; 1200
     wspd = TestData (:,2)
     wdir = TestData (:,1)
     wspd at _FillValue = -999.0
     wdir at _FillValue = -999.0
     delete(TestData)

     ;printMinMax(wspd, 0)
     ;printMinMax(wdir, 0)

     rad = 4.0*atan(1.0)/180.
     u = -wspd*sin(rad*wdir)
     v = -wspd*cos(rad*wdir)
     u at _FillValue = -999.0
     v at _FillValue = -999.0
     printMinMax(u, 0)
     printMinMax(v, 0)
        
     if (gg.eq.0) then
        res = True
        res at gsnDraw = False
        res at gsnFrame = False
        res at vpWidthF = 0.7
        res at vpHeightF = 0.5
        res at vpXF = 0.15
        res at vpYF = 0.9
        res at trYMinF = ymin
        res at trYMaxF = ymax
        res at tmXBMode = "Explicit"
        res at tmXBValues = ispan(0,nfiles-1,1)
        ; res at tmXBValues = ispan(0,47,1);ispan(0,nfiles-1,1)
        ; res at tmXBLabels = (/"00Z","0:30Z","01Z","01:30Z","02Z","02:30Z","03Z","03:30Z","04Z","04:30Z","05Z","05:30Z","06Z",\
        ;               "06:30Z","07Z","07:30Z","08Z","08:30Z","09Z","09:30Z","10Z","10:30Z","11Z","11:30Z","12Z","12:30Z","13Z",\
        ;               "13:30Z","14Z","14:30Z","15Z","15:30Z","16Z","16:30Z","17Z","17:30Z","18Z","18:30Z","19Z","19:30Z","20Z",\
        ;               "20:30Z","21Z","21:30Z","22Z","22:30Z","23Z","23:30Z"/)
        res at tmXBLabels = (/"00Z","0:30Z","01Z","01:30Z","02Z","02:30Z","03Z","03:30Z", \
                           "04Z","04:30Z","05Z","05:30Z","06Z", "06:30Z","07Z","07:30Z"/)
        res at tmXBLabelFontHeightF = 0.008

        res at tiYAxisString = "height (m)"
        res at tiXAxisString = "time"
        res at tiMainString = "Wind Profile"
        xc = (/-0.5,nfiles-0.5,nfiles-0.5,-0.5,-0.5/)
        yc = (/ymin,ymin,ymax,ymax,ymin/)
     
        plot = gsn_csm_xy(wks,xc,yc,res)                          ; draw blank xy plot by outlining min/max of X/Y axes
        contours = ispan(1,14,1)*1.                               ; set contours used to define barb color 
        colors = (/10,20,30,40,45,50,55,60,65,70,75,80,85,90,95/)    ; set colors
     end if
     
     wmsetp ("wdf", 1)                 ; meteorological dir
     wmsetp("wbs",0.025)
     wmsetp ("blw",2.0)    ; increase line thickness of wind barbs
     ;drawNDCGrid(wks)
     do hh = 0,dimsizes(z)-1
        print(u(hh)+" "+v(hh))
        if(.not.ismissing(wspd(hh))) then
          wmsetp("col", GetFillColorIndex(contours,colors,wspd(hh)))
          iFlag = True 
        else
          continue
        end if


        if (z(hh).lt.ymax) then
           if (hh.eq.0) then                                   ; always draw the first wind barb 
              wmbarb(wks, gg*1., z(hh), u(hh), v(hh)) 
              iFlag = True                                     ; iFlag = True denotes that a barb has been drawn
           else
              if (z(hh)-zsave.ge.wbcrit) then                  ; if the current height is beyond wbcrit from
                if ((u(hh).ne.wspd at _FillValue).and.(v(hh).ne.wspd at _FillValue)) then
                 wmbarb(wks, gg*1., z(hh), u(hh), v(hh))       ; previous barb height, draw barb
                 iFlag = True
                else
                 iFlag = False
                end if

              else
                 if (.not.iFlag) then                          ; if the previous barb has not been drawn,
                    if (z(hh)-zsave.ge.wbcrit) then            ; and if the last drawn barb was more than wbcrit away,
                        if ((u(hh).ne.wspd at _FillValue).and.(v(hh).ne.wspd at _FillValue)) then
                         wmbarb(wks, gg*1., z(hh), u(hh), v(hh)) ; draw a barb
                         iFlag = True
                        else
                         iFlag = False
                        end if
                    else
                       iFlag = False                           ; set iFlag to False, denoting the barb wasn't drawn
                    end if
                 else   
                    iFlag = False
                 end if
              end if
           end if
        else  
           iFlag = False
        end if
        if (iFlag) then
           zsave = z(hh)                                        ; save the height of the drawn wind barb
        end if
     end do
     delete([/z,wspd,wdir,u,v/])
  end do

;--------------------------------------------------------------------------
;    Draw Labelbar
;-------------------------------------------------------------------------- 
  lbres                      = True
  lbres at lbPerimOn            = False               ; no label bar box
  lbres at lbOrientation        = "Horizontal"        ; orientation
  lbres at vpWidthF             = 0.5                 ; size
  lbres at vpHeightF            = 0.075
  lbres at lbLabelFontHeightF   = 0.015               ; label font height
  lbres at lbLabelAlignment     = "InteriorEdges"     ; where to label
  lbres at lbMonoFillPattern    = True                ; fill sold
  lbres at lbFillColors         = colors
  gsn_labelbar_ndc (wks,dimsizes(contours)+1,sprintf("%3.0f",contours),0.25,0.30,lbres)
  
  draw(plot)                      ; draw the plot
  frame(wks)                        ; advance the frame


end
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

i don't know how to get rid of this two lines on figure. i changed number in  xc = (/-0.5,nfiles-0.5,nfiles-0.5,-0.5,-0.5/) , but it cannot take effect.

the attachment is my test data intercepted from a daily file for this checkout.

any help will be appreciated!

thanks

dyjbean at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 56712 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test01.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test02.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test03.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test04.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test05.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0004.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test06.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0005.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test07.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0006.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test08.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0007.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test09.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0008.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test10.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0009.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test11.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0010.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test12.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0011.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test13.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0012.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test14.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0013.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test15.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0014.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test16.txt
Type: application/octet-stream
Size: 925 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160901/86eb1ee8/attachment-0015.obj 


More information about the ncl-talk mailing list