# [ncl-talk] vector plot with one axis scaled

Wolfgang Langhans wlanghans at lbl.gov
Thu Oct 16 11:45:00 MDT 2014

```Hi all,

I'm seeking a vector plot with the vertical axis representing height in
meter and the horizontal axis representing distance in nondimensional
units. The original vector field is based on velocities u and w, both
are defined in physical space and have units m/s. The distance r (meter)
is transformed into a non-dimensional distance rs by rs=r/Rn, with
Rn=1000 meters. The axis shall have units of meters (vertical) and
nondimensional (horizontal). I transform the horizontal velocity u by
u=u/Rn to get the horizontal speed in rs-space. Then I assign z and rs
as coordinates to u and w and use gsn_vector to get the vector plot for
the coordinate range 0<z<1000 and 0<rs<1. The angle of the vectors is
fine (e.g., 45 deg for original data being u=2 and w=2). However, I did
not succeed in getting the length of the vectors right. I want ncl to
pick a reference vector that is based on the wind speed of the original
vectors. Of course, ncl now computes the magnitude as sqrt(w^2+u^2)
which in my case is very close to w (since u has been scaled). Only for
a vector field with u=0 can I obtain the correct magnitude and the
correct reference vector.

Is there any way to modify the underlying source code such that ncl can
read in my scaling factor to reverse the applied normalization of u
whenever the magnitude of the vector is computed. This would allow me to
use vcRefMagnitudeF and vcRefLengthF with its normal meaning, i.e.,
RefMagnitudeF being magnitude in m/s? Or maybe there's an even more
simple solution to this?

The simple test script is below.

Thanks!

Wolfgang
_______________________________________________________________

;coordinates
z=fspan(0.,800.,20)         ; height
Rn=1000.

u=new((/dimsizes(z),dimsizes(rs)/),float)
w=new((/dimsizes(z),dimsizes(rs)/),float)
u!0="z"
u!1="rs"
u at z=z
u at r=rs
w!0="z"
w!1="rs"
w at z=z
w at r=rs

;create arbitrary velocity fields
u=10.00
w=0.00

;compute u in rs-space
u=u/Rn

type              = "eps"                      ; create variable to
hold info
wks   = gsn_open_wks (type, "test_vec" )   ; open workstation

setvalues wks
"wkBackgroundColor" : (/1.,1.,1./)
"wkForegroundColor" : (/0.,0.,0./)
end setvalues

vres=True
vres at gsnDraw               = False             ; don't draw yet
vres at gsnFrame              = False             ; don't advance frame yet
vres at pmLabelBarDisplayMode     = "Never"
vres at vcRefAnnoOn = True
vres at vcRefAnnoOrthogonalPosF   = -0.994         ; move ref vector
vres at vcRefAnnoParallelPosF   = 0.994
;  vres at vcRefLengthF              = 0.03
;  vres at vcRefAnnoString1          ="2 m s!S!-1!N!"
;  vres at vcRefMagnitudeF           = 2.0        ; define vector ref mag
;  vres at vcRefLengthF              = 0.01
vres at vcGlyphStyle            = "LineArrow"     ; turn on curley vectors
vres at vcLineArrowColor        = "black"           ; change vector color
vres at vcLineArrowThicknessF   = 1.              ; change vector thickness
vres at vcMinDistanceF=.03
; choose plotting range such that vectors point diagonally in case
u=w for the original data
vres at trXMaxF = 1.0
vres at trYMaxF = Rn ;
vres at trXMinF = min(rs)
vres at trYMinF =  min(z)
vres at vfXArray  = rs
vres at vfYArray  = z

plot = gsn_csm_vector(wks,u,w,vres)

draw(plot)
frame(wks)

_____________________________________________________________________

--
************************************************
Wolfgang Langhans

Postdoctoral Fellow
Earth Sciences Division
Lawrence Berkeley National Laboratory