# Re: Vector Plots

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 5 Jul 2006 09:20:13 -0600 (MDT)

On Tue, 4 Jul 2006, Karen A. Kosiba wrote:

> Hello,
>
> I am making a vector plot that is not overlayed on a map. In the "y-direction",
> my vectors are cut off at y =start and y=end. Is there any way to vertically
> expand my grid so that the first and last rows of data are properly represented?
>
>
> Sincerely,
> Karen

Hi Karen,

Unfortunately, I don't think there's any way to tell NCL not to clip
vectors at the boundaries. This may be something we need to look
into, but meanwhile, I'll try to suggest a work-around.

I'm not sure what you mean by "vertically expand my grid", but I'm
going to take a guess that you mean how to add extra space above and
below your plot so the vectors don't get clipped.

If this is what you mean, then there are three possible ways you can
do this, depending on whether or not you have a Y coordinate array
attached to your data, and whether or not your Y coordinate values are
equally spaced.

1) The first solution is if your data does not have a Y coordinate
array attached. You can simply use the trYMinF and trYMaxF
resources to set the min and max values of your Y axis so that you can
see your full vectors. For example, if your Y values go from 1 to 10,
then you can set trYMinF and trYMaxF to values like 0 and 11 to ensure
you get some "white" space at the top and bottom of your plot:

res@trYMinF = 0.
res@trYMaxF = 11.

2) If your data does have a Y coordinate array attached to it, but the
Y coordinate values are all equally spaced, then you can bypass the
use of your coordinate array, and hence be able to use the trYMinF and
trYMax resources. To bypass the use of your coordinate array (and
coordinate array "y"), set the following resources:

ny = dimsizes(data(:,0))
res@sfYCStartV = data&y(0)
res@sfYCEndV = data&y(ny-1)

You can now set trYMinF and trYMaxF as described in #1.

3) If your data has a Y coordinate array that contains unequally-spaced
values, then you can't use trYMinF and trYMaxF because NCL won't
extrapolate values outside of values that are irregularly spaced.

You will need to add these values yourself by expanding your data
array to contain two new Y values, one at the beginning and one at
the end. To do this, you will need to use this (untested) code:

nx = dimsizes(data(0,:)) ; Size of X dimension
ny = dimsizes(data(:,0)) ; Size of Y dimension
ny2 = ny + 2 ; Add two for the two end points.

;
; Create new Y coordinate array. Note that you will need to decide what
; you want the values of your two new end points to be.
;
ynew = new( ny2, typeof(data&y) )
ynew(1:ny) = data&y ; Copy over values.
ynew(0) = some value that is < min(data&y)
ynew(ny2-1) = some value that is > max(data&y)

datanew = new((/ny2,nx/),typeof(data))

datanew!0 = data!0 ; Name coordinate arrays
datanew!1 = data!1 ; of new variable.

datanew&data!0\$ = ynew ; Assign new Y coordinate array.
datanew&data!1\$ = data&\$data!1\$ ; Assign same X coordinate array.

datanew(1:ny,:) = (/data/) ; Rest of values at datanew(0,:) and
; datanew(ny+1,:) will be missing.
;
; Next part is for copying over all attribute values, if desired.
;
attnames = getvarnames(data)
if(.not.any(ismissing(attnames))) then
do i=0,dimsizes(attnames)-1
datanew@\$attnames(i)\$ = data@\$attnames(i)\$
end do
end if

Now, you can use "datanew" for plotting instead of "data", and you should
get some margins around the top and bottom of your plot.

Good luck,

--Mary

> ********************************
> Karen A. Kosiba
> PhD Candidate
> Purdue University, Dept. of EAS
> http://www.purdue.edu/eas/severe/
> ********************************
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 05 2006 - 09:20:13 MDT

This archive was generated by hypermail 2.2.0 : Wed Jul 05 2006 - 09:40:06 MDT