[ncl-talk] vector plot with one axis scaled

David Brown dbrown at ucar.edu
Tue Oct 28 18:28:52 MDT 2014


Hi Wolfgang,

Sorry for the delay in answering. I am not sure I actually understand
what you are going for, but I can say that NCL's vector plot has no
provisions for differentially scaling the u and v components. However,
I'm thinking you can achieve what you want more simply by *not*
scaling the u value as sent to gsn_csm_vector. You can disassociate
the vector angle and magnitude from the coordinate system it is
located within by setting the resource "vcMapDirection" to False. Then
regardless of the coordinate system, if the U and V components are
equal the angle will be 45 degrees, and the vector reference arrow
will have the right value.

Let us know if this is not what you mean. I am attaching a lightly
modified version of your script.
 -dave


On Thu, Oct 16, 2014 at 11:45 AM, Wolfgang Langhans <wlanghans at lbl.gov> wrote:
> 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
> _______________________________________________________________
>
> 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"
>
> ;coordinates
> z=fspan(0.,800.,20)         ; height
> r=fspan(0.,4000.,200)       ; radius
> Rn=1000.
> rs=r/Rn                   ; nondimensional radius
>
> 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
> 1 Cyclotron Road 74R316C
> Berkeley, CA 94720-8268
>
> email:  wlanghans at lbl.gov
> phone:  (510) 486-7175
> fax:    (510) 486-7775
> room:   84-118K
> web:    http://esd.lbl.gov/about/staff/wolfganglanghans/
> ************************************************
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.ncl
Type: application/octet-stream
Size: 1997 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141028/610eff68/attachment.obj 


More information about the ncl-talk mailing list