[Thread Prev][Thread Next][Index]

Re: [ferret_users] Define a 2d variable



Hi Jonathan,
The easiest way to make a second variable is to have it inherit the grid from the first.  Do you already have your small 3x2 region defined on a grid in Ferret?

For instance, say we take a subset of an existing variable on a grid
yes? use etopo60
yes? let little_data = rose[i=45:47,j=133:134]

yes? list little_data
             VARIABLE : ROSE[I=45:47,J=133:134]
             FILENAME : etopo60.cdf
             FILEPATH : /home/porter/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 3 by 2 points (LONGITUDE-LATITUDE)
                64.5E  65.5E  66.5E
                45     46     47
 43.5N / 134:  195.0  184.9  175.4
 42.5N / 133:  294.5  253.8  209.2

!  Now make a list of the values you're going to divide by. We'll use
!  RESHAPE to put them on the same grid as the first variable.

yes? let divide_by  = {1,2,3,4,5,6}
yes? let divide_by_this = RESHAPE(divide_by, little_data)

yes? list divide_by_this
             VARIABLE : RESHAPE(DIVIDE_BY, LITTLE_DATA)
             FILENAME : etopo60.cdf
             FILEPATH : /home/porter/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 3 by 2 points (LONGITUDE-LATITUDE)
                64.5E  65.5E  66.5E
                45     46     47
 43.5N / 134:  4.000  5.000  6.000
 42.5N / 133:  1.000  2.000  3.000


!  Now you can divide the two:

yes? list little_data/divide_by_this
             VARIABLE : LITTLE_DATA/DIVIDE_BY_THIS
             FILENAME : etopo60.cdf
             FILEPATH : /home/porter/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 3 by 2 points (LONGITUDE-LATITUDE)
                64.5E  65.5E  66.5E
                45     46     47
 43.5N / 134:   48.7   37.0   29.2
 42.5N / 133:  294.5  126.9   69.7

If you need to define grids, then take a look at DEFINE AXIS, and DEFINE VARIABLE, and get back to us if you have more questions.

Ansley

Jonathan Winter wrote:
I have a small region, 3x2 points, that I would like to divide by a 3x2
grid of values that I manually set.  My question is how to create the
grid of values to divide by?  This can either be building the 3x2 array
from scratch or copying the original 3x2 array (using the "LET" command)
and reassigning the values.  In MATLAB it would look like this:

my_vals = [1 2; 3 4; 5 6]
my_div = [2 1; 3 2; 1 2]

my_vals./my_div

Thanks in advance for the help,

jonathan

  

  

[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement