[Thread Prev][Thread Next][Index]

Re: [ferret_users] Ferret Array/variable class detection



Thanks a lot mam.

this will solve my problem.

-Akshay



On Mon, Dec 9, 2013 at 10:52 PM, Ansley Manke <ansley.b.manke@xxxxxxxx> wrote:
Yes -

  `var,return=dtype`

will return FLOAT or CHAR.  Putting it into a symbol would likely give you the most flexibility to make use of it.


On 12/8/2013 8:54 PM, Akshay Hegde wrote:

Hi Developers,

Is there any function to check an array class ?

for example character classes defined by the POSIX standard

[[:alpha:]] --------> alphabetic characters

[[:alnum:]] -------> alphanumeric characters

[[:digit:]] ------> Numeric characters


[akshay@aix tmp]$ f
     NOAA/PMEL TMAP
     FERRET v6.85 
     Linux 2.6.18-371.1.2.el5 64-bit - 11/12/13
      9-Dec-13 09:58    

! Numbers
yes? let numerics = {1,2,3,4,5}

! Alpha
yes? let strings = {"1","2","3","4","5"}

yes? list numerics,strings
             X: 0.5 to 5.5
 Column  1: NUMERICS is {1,2,3,4,5}
 Column  2: STRINGS is {"1","2","3","4","5"}
       NUMERICS  STRINGS
1   / 1:   1.000 "1"
2   / 2:   2.000 "2"
3   / 3:   3.000 "3"
4   / 4:   4.000 "4"
5   / 5:   5.000 "5"

yes? list/file=tester.nc/format=cdf/clobber numerics,strings
 LISTing to file tester.nc

yes? can var/all

yes? use tester.nc

yes? sh d
     currently SET data sets:
    1> ./tester.nc  (default)
 name     title                             I         J         K         L         M         N
 NUMERICS {1,2,3,4,5}                      1:5       ...       ...       ...       ...       ...
 STRINGS  {"1","2","3","4","5"}            1:5       ...       ...       ...       ...       ...
 
yes? list numerics,strings
             DATA SET: ./tester.nc
             X: 0.5 to 5.5
 Column  1: NUMERICS is {1,2,3,4,5}
 Column  2: STRINGS is {"1","2","3","4","5"}
       NUMERICS  STRINGS
1   / 1:   1.000 "1"
2   / 2:   2.000 "2"
3   / 3:   3.000 "3"
4   / 4:   4.000 "4"
5   / 5:   5.000 "5"

yes? list ..varnames
             VARIABLE : ..VARNAMES
             FILENAME : tester.nc
             SUBSET   : 2 points (X)
 1   / 1:"NUMERICS"
 2   / 2:"STRINGS"


Here I want to create one array say let mask that should contain 0 if ..varnames is numeric class and 1 if its string class (alphanumeric)

I am interested to know how ferret checks internally whether an array is of string class or numeric class ? while displaying this error message "string/numeric data type mix-up"

yes? let myvar = ..varnames
yes? list myvar
             VARIABLE : ..VARNAMES
             FILENAME : tester.nc
             SUBSET   : 2 points (X)
 1   / 1:"NUMERICS"
 2   / 2:"STRINGS"

I need to create mask, so that if I list myvar and mask, I should get following result

Expected result :

 list myvar,myvar
             DATA SET: ./tester.nc
 Column  1: MYVAR is ..VARNAMES
 Column  2: mask is some expre
             MYVAR     mask
1   / 1: "NUMERICS" 0
2   / 2: "STRINGS"   1

 
Thanks and Regards,
Akshay Hegde
CSIR-National Institute of Oceanography,
Dona Paula, Panjim, Goa -403004








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

Privacy Policy | Disclaimer | Accessibility Statement