[Thread Prev][Thread Next][Index]

Re: [ferret_users] transformation to find axis max length



Hi,
One way to do this for an ascii dataset is to use a linux command to get the length of the file. That's shown here,

http://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2001/msg00311.html

But to do the job with Ferret, commands, for any variable there are RETURN= commands that give you information about the variable and its grid. (http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/variables-xpressions/EMBEDDED-XPRESSIONS#_VPINDEXENTRY_576)  They work like this:
load var  ! Necessary for a variable in an ascii dataset, not a netcdf dataset
let npts = `var,RETURN=isize`

Note that this wouldn't work if you had just used the default abstract axis to open an ascii dataset.  If you had said this,
yes? file file.dat
yes? show data
     currently SET data sets:
    1> ./file.dat  (default)
 name     title                             I         J      K      L      M      N
 V1       V1                               1:20480   ...    ...    ...    ...    ...

yes? load v1
yes? let npts = `v1,return=isize`
 !-> DEFINE VARIABLE npts = 20480
you'd always get the length of the abstract axis, 20408 points.

But instead, if you define an axis and a grid and use that to read the dataset, then you can get the variable's size. Define an axis that's always going to be longer than the length of the ascii dataset, and use that to initialize the file, then you can get the size, whatever it is in that dataset:
yes? define axis/x=1:10000:1 inaxis
yes? define grid/x=inaxis ingrid   
yes? file/grid=ingrid/var=time file.dat

yes? load time
yes? let npts= `time,return=isize`
 !-> DEFINE VARIABLE npts = 5200
...

On 12/8/2012 11:14 PM, Akshay Hegde wrote:
Hi experts...

I was just looking for some transformation to find the maximum length of i axis..


when I do show data it looks like this..

     currently SET data sets:
    1> ./file.dat  (default)
 name     title                                   I         J         K         L         M         N
 TIME     TIME                             1:8380    ...       ...       ...       ...       ...


here while defining t axis every time I need to modify I value.. that is [i=1:8380]

DEFINE axis/T/T0=1-jan-2010/UNIT=days tx=time[i=1:8380]

Is there any transformation to find axis max length ?

Thanks in advance,

Akshay



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

Privacy Policy | Disclaimer | Accessibility Statement