[ncl-talk] The resourses only works on the first plot(overlay); How to set the linearrows on a line and set the Y axis as the speed value

Mary Haley haley at ucar.edu
Wed Sep 7 22:03:10 MDT 2016


I'm not sure why the two sets of vectors are not showing up the same, but
my guess is that they have different default reference vectors with
different magnitudes.

To debug this, as usual, I suggest first commenting out the
vcRefMagnitudeF, vcRefLengthF, etc, type of resources, and draw each plot
individually before you overlay them, so you can see what NCL chooses for
the default magnitude and reference length. You will need to make sure
vcRefAnnoOn is not set to False, and that gsnDraw and gsnFrame are not set
to False.

As for the second question, it looks like you almost already have the
vectors in a line, correct?  The default NCL behavior is to center the
vector, but you can specify that you want either the head or the tail of
the vector to be at the x,y coordinate location.

See example vector_7.ncl at:

http://www.ncl.ucar.edu/Applications/vector.shtml#ex7

which illustrates how to change this behavior using the vcPositionMode.

As another possibility, you might try using wmvect instead of trying to do
a vector plot. See example weather_sym_8.ncl at:

http://www.ncl.ucar.edu/Applications/weather_sym.shtml

I recommend this as a last resort, however, because using gsn_csm_vector
will give you more customization over the vectors.

--Mary


On Sun, Sep 4, 2016 at 7:17 PM, grace <313695096 at qq.com> wrote:

> Hi:
>   All,I am trying to compare the wind data of wrfout with observations of
> one station,like the picture below,
> Here is my strategy:
> First, I extracted the data and put them into two different arrys,draw two
> differert xy plot with same manual timelabels on X axis,but arrowline with
> different color.
> Then I overlay them.
> But the picture I drawed is like this:
> No matter how reset the resourses ,the vc_res only works on the first
> plot(plot A),How can I slove the problem?
> One more question,How can I set the linearrows on a line and set the Y
> axis as the speed value that corresponding the wind speed of the wind
> vector?Just like the first picture in this email.
> Any information will be appreciated.
>
> This 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/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
> 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/wrf/WRFUserARW.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
> ;
> ; The WRF ARW input file.
> ; This needs to have a ".nc" appended, so just do it.
>   a = addfile("/backup/hl/wrfout201508/wrfout_d03_2015-08-01_12:00:00.nc","r")
>
>
>     ij = wrf_user_ll_to_ij(a, 108.966667,34.433333,True)
>
>     print("lon location is: " +ij(0))
>
>     print("lat location is: " + ij(1))
>
> ; First get the variables we will need
> u10_2=new((/31,24/),float,"No_FillValue")
> v10_2=new((/31,24/),float,"No_FillValue")
>
>
>  filename1=systemfunc("ls /backup/hl/wrfout201508/wrfout_d03_2015-08*.nc")
>          fin1=addfiles(filename1,"r")
>          do i=0,30
>
>                  u10_1=fin1[i]->U10(0:23,ij(1)-1, ij(0)-1)
>                  v10_1=fin1[i]->V10(0:23,ij(1)-1, ij(0)-1)
>                  u10_2 (i,:)= u10_1
>                  v10_2 (i,:)= v10_1
>         end do
>                           u10=ndtooned(u10_2)
>                           v10=ndtooned(v10_2)
>
>                           u10_d=u10(0:724)
>                           v10_d=v10(0:724)
>                           printVarSummary(u10_d(0))
>                           printVarSummary(v10_d(0))
>
> ;;;;;;;;;;;;;;;get obs data;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>   ascii_filename = "/public/home/huanglei/txt_obs/obs.txt"
>   seismic = asciiread(ascii_filename,(/725,6/),"float")
>   seismic at _FillValue = -999
>      wdir = seismic(:,4)
>      wspd = seismic(:,5)
>      tmp = (270.0-wdir)*0.01745329
>      u_o = wspd*cos(tmp)
>      v_o = wspd*sin(tmp)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;data for plot1;;;;;;;;;;;;;;;;a is model data ; b
> is obs data;;;;;;;;;;;;;;;;;;;;;;;
>  u10_new1a=new((/25,220/),float)
>  u10_new1a=0
>  u10_new1a(8,:)=u10_d(0:219)
>  v10_new1a=new((/25,220/),float)
>  v10_new1a=0
>  v10_new1a(8,:)=v10_d(0:219)
>
>  u10_new1b=new((/25,220/),float)
>  u10_new1b=0
>  u10_new1b(8,:)=u_o(0:219)
>  v10_new1b=new((/25,220/),float)
>  v10_new1b=0
>  v10_new1b(8,:)=v_o(0:219)
>
>
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;;;;;;;;;;;;;;;;
> wks  = gsn_open_wks("pdf","gsn_vector_panel")          ; open a Graphic
> wkStation
>   res  = True                                      ; plot mods desired
>   res at gsnFrame  = False
>   res at gsnDraw   = False                          ; don't draw
>
>   res at vcGlyphStyle     = "LineArrow"             ; turn on LineArrow
>   res at gsnMaximize = True
>   res at vpHeightF   = 0.15
>   res at vpWidthF    = 0.8
>
>   res at pmLegendWidthF         = 0.10                  ; Change width and
>   res at pmLegendHeightF        = 0.10                  ; height of legend.
>   res at tmYLOn             = False        ; Don't draw labels for left
>   res at tmYLLabelsOn       = False        ;  Y axes
>   res at tmYROn             = False        ; Don't draw labels for right
>   res at tmYRLabelsOn       = False        ;  Y axes
>   res at tmXBLabelFontHeightF = 0.01
>   res at vcRefAnnoOrthogonalPosF = -0.258             ; move ref vector up
>   res at vcRefMagnitudeF         = 1.0            ; define vector ref mag
>   res at vcRefLengthF            = 0.01            ; define length of vec ref
>   res at vcRefAnnoParallelPosF     = 0.999
>   res at vcRefAnnoFontHeightF =0.005
>   res at vcRefAnnoString2   =" "
>   res at vpHeightF   = 0.15
>   res at vpWidthF   = 0.8
>
>  ;res at tmYLLabelFontColor = line_col1    ;
>
> ;;;;;;;;;;;;;;;;;;;;add text TEST / OBS;;;;;;;
>     res_text               = True
>     res_text at txFontHeightF = 0.01
>
>     m1 = "TEST"
>     m2 = "OBS"
>
>  ;;;;;;;;;;;;;;;;;resources for plot(0);;;;;;;;;;;;;;
>
>   res0a=res
>   res0a at tmXBMode ="Explicit"
>   res0a at tmXBValues  =(/5,29,53,77,101,125,149,173,197/)
>   res0a at tmXBLabels = (/"5/2","5/3"," 5/4","5/5",
> "5/6","5/7","5/8","5/9","5/10"/)
>
>   res0a at vcMonoLineArrowColor = True
>   res0a at vcLineArrowColor = "black"
>   plotA = gsn_csm_vector(wks, u10_new1a, v10_new1a,res0a)
>
>   res0b=res
>   res0b at tmXBMode ="Explicit"
>   res0b at tmXBValues  =(/5,29,53,77,101,125,149,173,197/)
>   res0b at tmXBLabels = (/"5/2","5/3"," 5/4","5/5",
> "5/6","5/7","5/8","5/9","5/10"/)
>
>   res0b at vcMonoLineArrowColor = True
>   res0b at vcLineArrowColor = "red"
>    res0b at vcRefAnnoOrthogonalPosF = -0.258             ; move ref vector up
>   res0b at vcRefMagnitudeF         = 1.0            ; define vector ref mag
>   res0b at vcRefLengthF            = 0.01            ; define length of vec
> ref
>   res0b at vcRefAnnoParallelPosF     = 0.999
>   res0b at vcRefAnnoFontHeightF =0.005
>   res0b at vcRefAnnoString2   =" "
>
>   plotB = gsn_csm_vector(wks, u10_new1b, u10_new1b,res0b)
>
>    overlay(plotA,plotB)                      ; result will be plotA
>    plot = plotA                           ; now assign plotA to array
>
>  gsn_text(wks,plot(0),m1,190,10,res_text)
>  gsn_text(wks,plot(0),m2,190,35,res_text)
>
>  draw(plot)
> ;frame(wks)
> end
>
>
>
> _______________________________________________
> 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/20160907/d13b1612/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 9915746C at D1828918.9FC7CC57
Type: application/octet-stream
Size: 115159 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160907/d13b1612/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: E94CEA3B at D1828918.9FC7CC57.jpg
Type: image/jpeg
Size: 221164 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160907/d13b1612/attachment-0001.jpg 


More information about the ncl-talk mailing list