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

Mary Haley haley at ucar.edu
Fri Sep 2 11:15:47 MDT 2016


I think you simply need to set these two resources:

        res at trXMaxF = nfiles-0.5

        res at trXMinF = -0.5

Those two lines you see are the "xc" and "yc" being plotted, and they don't
match the axis because NCL chose a different X min/max for the X axis.

By setting those two resources, you are forcing the X axis to have the same
min/max as the "xc" array.

--Mary



On Thu, Sep 1, 2016 at 4:00 AM, dyjbean at gmail.com <dyjbean at gmail.com> wrote:

>
> hi,
>  when i plotted wind barb, i  consulted the barb_6.ncl
> <http://www.ncl.ucar.edu/Applications/Scripts/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@
> _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@
> _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
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160902/ebb23708/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InsertPic_A20C.png
Type: image/png
Size: 56712 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160902/ebb23708/attachment.png 


More information about the ncl-talk mailing list