[Thread Prev][Thread Next][Index]

Re: [ferret_users] A request for variable construction



Hi Olivier,

The construction

i[i=1:5]

uses the "abstract" axis in the I direction, a pre-defined axis which can be referred to in any direction.  In a new session,

yes? show axis/all
 name       axis              # pts   start                end
 MONTH_IRREG TIME              12mi   16-JAN 12:00         15-DEC 17:49
 MONTH_REG TIME                12mr   16-JAN 06:00         16-DEC 01:20
 SEASONAL_REG TIME              4mr   15-FEB 15:43         15-NOV 14:05
 MONTH_GREGORIAN TIME          12mi   16-JAN 12:00         15-DEC 17:49
 MONTH_NOLEAP TIME             12mi   16-JAN 12:00         16-DEC 12:00
 MONTH_360_DAY TIME            12mr   16-JAN 00:00         16-DEC 00:00
 MONTH_ALL_LEAP TIME           12mi   16-JAN 12:00         16-DEC 12:00
 MONTH_JULIAN TIME             12mi   16-JAN 12:00         15-DEC 18:00
 ABSTRACT                99999999 r   1                    1.E+08
 EZ                         20480 r   1                    20480


It's like any axis; it starts when it's defined to start at index 1, but the syntax is shortened.  i[i=1:5] is equivalent to i[gx=abstract,i=1:5].


One alternative would be to define an axis of any length, making it modulo:

yes? define axis/modulo=100/x=1:100:1 all_i
yes? list i[gx=all_i,i=-10:10]


and as to skipping values, it there's a subtlety here.  Looking at it with an axis that isn't just index values:

yes? use etopo20

yes? list x[gx=rose,i=1:5]
             VARIABLE : X
                        axis ETOPO20X1_1081
             FILENAME : etopo20.cdf
             FILEPATH : /home/users/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 5 points (LONGITUDE)
 20.17E / 1:  20.17
 20.5E  / 2:  20.50
 20.83E / 3:  20.83
 21.17E / 4:  21.17
 21.5E  / 5:  21.50

yes? list i[gx=rose,i=1:5]
             VARIABLE : I
                        axis ETOPO20X1_1081
             FILENAME : etopo20.cdf
             FILEPATH : /home/users/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 5 points (LONGITUDE)
 20.17E / 1:  1.000
 20.5E  / 2:  2.000
 20.83E / 3:  3.000
 21.17E / 4:  4.000
 21.5E  / 5:  5.000

yes? list x[gx=rose,i=1:10:2]
             VARIABLE : X
                        axis (AX007)
             FILENAME : etopo20.cdf
             FILEPATH : /home/users/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 5 points (LONGITUDE)
 20.17E / 1:  20.17
 20.83E / 2:  20.83
 21.5E  / 3:  21.50
 22.17E / 4:  22.17
 22.83E / 5:  22.83

yes? list i[gx=rose,i=1:10:2]
             VARIABLE : I
                        axis (AX006)
             FILENAME : etopo20.cdf
             FILEPATH : /home/users/tmap/ferret/linux/fer_dsets/data/
             SUBSET   : 5 points (LONGITUDE)
 20.17E / 1:  1.000
 20.83E / 2:  2.000
 21.5E  / 3:  3.000
 22.17E / 4:  4.000
 22.83E / 5:  5.000

In the last listing there, apparently the thinking in designing this is that when asking for i, we're getting the index of the _expression_ being listed, that is, every-second-gridpoint of the x axis of rose.  So it's counting the elements listed.  It seems a bit strange to me as well, but that looks like what is happening.


-Ansley


On 8/26/2020 1:51 AM, Olivier Marti wrote:
Hi to all.

In ferret, you can can construct a variable variable from scratch with something like A=I[I=1:5]  :

yes? LIST I[I=1:5]
             VARIABLE : I
                        axis ABSTRACT
             SUBSET   : 5 points (X)
 1   / 1:  1.000
 2   / 2:  2.000
 3   / 3:  3.000
 4   / 4:  4.000
 5   / 5:  5.000

You can limit the range :

yes? LIST I[I=3:5]
             VARIABLE : I
                        axis ABSTRACT
             SUBSET   : 3 points (X)
 3   / 3:  3.000
 4   / 4:  4.000
 5   / 5:  5.000

But you can not extend before zero : 

yes? LIST I[I=0:5]
             VARIABLE : I
                        axis ABSTRACT
             SUBSET   : 5 points (X)
 1   / 1:  1.000
 2   / 2:  2.000
 3   / 3:  3.000
 4   / 4:  4.000
 5   / 5:  5.000

Neither can you skip values : 
yes? LIST I[I=1:6:2]
             VARIABLE : I
                        axis (AX004)
             SUBSET   : 3 points (X)
 1   / 1:  1.000
 3   / 2:  2.000
 5   / 3:  3.000


Of course, we got an obvious and simple solution to construct these variables :
yes? LIST 2*I[I=1:4]-2
             VARIABLE : 2*I[I=1:4]-2
             SUBSET   : 4 points (X)
 1   / 1:  0.000
 2   / 2:  2.000
 3   / 3:  4.000
 4   / 4:  6.000


But we could have simpler and clearer scripts if the _expression_ I[0:6:2] could give directly this result.

Best regards,

Olivier

— 
Olivier Marti  - LSCE Bât 714 p. 1049
MERMAID Team
Normal situation :  +33 1 69 08 77 27 
Corona lockdown  :  +33 6 45 36 43 74


-- 
Ansley Manke
Science Data Integration Group
NOAA Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115

I am currently teleworking and am available Tue-Wed-Thu.

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

Privacy Policy | Disclaimer | Accessibility Statement