Re: question about example gsun08s.ncl

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 19 Jun 2006 14:29:36 -0600 (MDT)

On Mon, 19 Jun 2006 wrote:

> Hi,
> I have two contour plots which I created with natgrids as in the first plot
> of example gsuns.ncl.
> Both plots have the same X value range but have different Y value range.
> For example, say that X values goes from 0 to 5 but Y values goes from 0 to 5
> in plot1 and 0 to 7 in plot2.
> I want to create plot1 so that the values in the Y axis will run from 0 to 7
> as in plot2 only the section between 5 to 7 will be blank.
> Is there a way to do that?
> Thanks, Roni.

Hi Roni,

[After I composed this, I saw that Adam had responded. I'm going to go
ahead and send this so you can see the other way of doing this. This
second way only works if your X and Y values are regularly-spaced.]

There are two ways that you can do this. If your X and Y values are
regularly spaced, then you can set some resource values:

   res = True ; Resource list
   res@sfXCStartV = 0 ; Tell NCL at what values your X and Y
   res@sfXCEndV = 5 ; coordinates start and end.
   res@sfYCStartV = 0
   res@sfYCStartV = 5
   res@trYMaxF = 7 ; Force the Y axis to go out to 7.

If your data values are not regularly-spaced, then you should create a
new data array for your first plot that contains extra values in the Y
dimension to hold the values from 5 to 7, and then fill these values
in with missing values.

In my example below, I'm assuming that your data has coordinate arrays
attached to it. Also, if your Y values are not regularly spaced, you
will need to figure out how you want to space the values from 5 to
7. In my example below, I'm just using regularly spaced values.

So, let's say your X and Y coordinate values are represented by 1D
arrays of equally spaced values from 0 to 5:

    x = (/0,1,2,4,5/) ; ispan(0,5,1)
    y = (/0,1,2,4,5/) ; ispan(0,5,1)

And that "data" is your 2D array, dimensioned 6 x 6, with x and
y as coordinate arrays, and with -999 as a missing value:

    data@_FillValue = -999
    data!0 = "y"
    data!1 = "x"
    data&y = y
    data&x = x

Now, let's assume that you want to increase the number of Y values so
that they go from 0 to 7, and hence you will also need to expand your
data values:

     ynew = (/0,1,2,3,4,5,6,7/) ; ispan(0,7,1)
     nx = dimsizes(x) ; 6
     ny = dimsizes(y) ; 6
     nynew = dimsizes(ynew) ; 8
; Create a new data array and copy over the old values. The "new"
; statement initializes all values to the given missing value,
; so we don't need to explicitly do this.
     data_new = new((/nynew,nx/),typeof(data),data@_FillValue)

     data_new(0:ny-1,:) = (/data/) ; Copy over old values
     data_new(ny:,:) = data@_FillValue ; Not necessary.

The "data_new" array now goes from 0 to 7 in the Y direction, and
has all missing values at the coordinate locations 5-7.

ncl-talk mailing list
Received on Mon Jun 19 2006 - 14:29:36 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 19 2006 - 15:40:00 MDT