[Thread Prev][Thread Next][Index]

Re: [ferret_users] How to index a new variable?

hi -
You can't easily put individual items into an array in Ferret. Ferret's design is to operate on variables on their whole grids or portions of grids. You can combine the existing transformations and functions in an _expression_, and so do many kinds of calculations. Another option to do a custom function, is to write your own external function. 


On 8/25/2011 10:21 AM, PaulaOCN Nunes wrote:
Thanks Ansley for the trick with the transformation, surely it is faster, but index new variables will help on my own algorithm development.
Searching mail archives, an user taught the below example of index with the loop, it did all right to read the data indexed, but wasn't successful to save it indexed to a new variable.
Sorry if my mistake, but I couldn't find also on the Users Guide,  still use fortran/matlab to do so, isn't this possible with ferret?

Thanks again for the help,
Paula Lamosa Nunes

Date: Tue, 23 Aug 2011 15:06:37 -0700
From: ansley.b.manke@xxxxxxxx
Subject: Re: [ferret_users] How to index a new variable?
To: oceanografa@xxxxxxxxxxx
CC: oar.pmel.ferret_users@xxxxxxxx

Rather than trying to write loops, look for Ferret transformations or functions that let you define a new variable that captures the operation you want to use.

define axis/x=1:10:1 xax
let array = x[gx=xax]
let array_1 = array[x=@ddb]

If you read the first chapter of the Users Guide, you'll start to see how best to use the program.  Then the next few chapters give details about different aspects of using Ferret.


On 8/23/2011 1:24 PM, PaulaOCN Nunes wrote:


I want to calculate the resolution on satellite images and need to index new variables, but I can't go through...
To learn the syntax, I tried with a simple vector (from 1 to 10), and then made a loop to create a new vector, as follows:

define axis/x=1:10:1 xax
let array = x[gx=xax]
repeat/i=2:10:1 (\
let array_1  IF I[GX=array] EQ `i` THEN (array[i=`i`]-array[i=`i-1`]); list array, array_1)
list array, array_1

             X: 0.5 to 10.5
 Column  1: ARRAY is X[GX=XAX]
 Column  2: ARRAY_1 is IF I[GX=ARRAY] EQ 10 THEN (ARRAY[I=10]-ARRAY[I=9])
           ARRAY  ARRAY_1
1    /  1:   1.00    ....
2    /  2:   2.00    ....
3    /  3:   3.00    ....
4    /  4:   4.00    ....
5    /  5:   5.00    ....
6    /  6:   6.00    ....
7    /  7:   7.00    ....
8    /  8:   8.00    ....
9    /  9:   9.00    ....
10   / 10:  10.00   1.000

The problem is that the new variable only gets the last value of the loop. Please, would someone help?

Paula Lamosa Nunes


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement