[Thread Prev][Thread Next][Index]

Re: Getting number of variables



Hi Both,
This has already been solved, but dealing with the default abstract
axes is something people do a lot, so I think it's worth adding one more
item.   If you do a "LOAD var" to read in the data, then the RETURN keyword
and other grave-accent expressions will give the correct length:
    
   yes? FILE/VAR="a, b",  varfile.dat
   yes? LOAD a
   yes? LET ndat = `a, RETURN=isize` ! returns the total # of points

Ansley

Jaison Kurian wrote:
Hi Sudheer,
              It not that diffcult task to know the number of data lines 
in text files, provided your ascii input files have some similarity 
 
        1. either all of them should have same number of header lines
            that we need to skip using /SKIP qualifier.
        2. or none of the file does have any header lines..the data
            values should start from the very first line of the ascii 
            file.

  The total number fo lines you can get onto a variable as follows

        yes? let flines = `{spawn:"cat example.dat | wc -l"}`
         !-> DEFINE VARIABLE flines =      10
        yes?

  suppose you don't have any header lines then

        yes? define axis/x=1:`flines`:1 xfile
        yes? define axis/x=xfile        gfile
        yes? file/grid=gfile/var=var1   example.dat


   Hope this helps

   with regards 

   Jaison 


On Mon, 6 Dec 2004, Sudheer Joseph wrote:

  
Dear Jaison,
                              I agree that it is good to define the axis 
properly and read the variable in to it , But I am doing a batch job where 
in, there is a list of data going to ferret and getting data of 
corresponding locations form a netcdf file and do some calculation involving 
both. here it is hard to define the axis since it varies its size with every 
file and it depends on the number of common point s in both datasets.

thanks,
Sudheer


***************************************
Dr. Sudheer Joseph
Indian National Centre for Ocean Information Services
Gajularamaram B.O., IDA Jeedeemetla S.O.
Via Pragathi Nagar, Kukatpally, Hyderabad
Pin:5000 55
Tel:+91-40-23044600(R)
Tel:+91-40-9440832534(Mobile)
Tel:+91-40-25503595(O)
Fax:+91-40-25503596(O)
E-mail:sjo@rediffmail.com;
callsjo@yahoo.com;
sjo@incois.gov.in.
Web- http://oppamthadathil.tripod.com
***************************************



    
From: Jaison Kurian <jaison@caos.iisc.ernet.in>
To: ferret_users@noaa.gov
CC: Sudheer Joseph <sjo_cma@hotmail.com>
Subject: Re: Getting number of variables
Date: Tue, 7 Dec 2004 01:26:15 +0530 (IST)

Hi Sudheer,
             I always prefer to read the data from ASCII file to a
properly defined grid instead of depending on the default way. If
you are doing it in this way then you can use the variable just like
one in a good NetCDF file. IF you are interested please have a look at
Ferret manual : Ch2 Sec5.1.  Reading ASCII files , and
Ref Sec4.2.  DEFINE AXIS.

 Here is an example. If you have any doubts please let me know.

 Hope this helps

 With Regards

 Jaison

!-------------example.dat--------------
29.50
28.95
-999.99
27.30
28.60
29.40
-999.99
29.50
28.60
28.30
!-----------example.jnl---------------
! Let us read the data in example.dat to a proper grid/axis.
!   we have 10 data values, so define an axis with 10 points.
!   define a grid only with this axis, and read the data onto this
!   grid.

    DEFINE AXIS/x=1:10:1  xfile
    DEFINE GRID/x=xfile   gfile

    FILE/grid=gfile/var=var1 num_of_points.dat
    set var/bad=-999.99 var1    ! set only the missing value..OR
    ! set var/bad=-999.99/title=""Temperature"/units="^oC" var1
    list var1

    let vardev      = var1 - var1[i=@AVE]
    let vardevsq    = vardev^2
    let sumsqvardev = vardevsq[i=@sum]

! now ..to get the number of valid data points use @NGD..simple one
! please note that here `var1,return=isize` - var1[x=@nbd] will also
! return accurate value(8).

    let good_pts    = var1[i=@NGD]
    list good_pts

    let myoutput = sumsqvardev/good_pts
    list myoutput

!-----------------end of example.jnl--------------------------

On Mon, 6 Dec 2004, Sudheer Joseph wrote:

      
Dear Users
                        I would like to get  variance calculted by 
        
defining
      
file/var=var1  vardat.dat
! The axis under consideration is irregular
let vardev=var1-var1[x=@ave]
let vardevsq= vardev^2
let sumsqvardev=vardevsq[x=@sum]
and then to devide it by the number of points i wanted to get the actual
number of points
I tried using the `var1,return=size` - var1[x=@nbd] but is not working 
        
since
      
the size of axis is not limited
it gives a return of 20000+ value which is the default ferret axis size
I would like to get the actual number of variables to devide the sum of
suired deviations.
I realise that there is a function @var existing in ferret but wanted to 
        
use
      
the manual calculation for some cross checking
can any one help
thanks,
sudheer


***************************************
Dr. Sudheer Joseph
Indian National Centre for Ocean Information Services
Gajularamaram B.O., IDA Jeedeemetla S.O.
Via Pragathi Nagar, Kukatpally, Hyderabad
Pin:5000 55
Tel:+91-40-23044600(R)
Tel:+91-40-9440832534(Mobile)
Tel:+91-40-25503595(O)
Fax:+91-40-25503596(O)
E-mail:sjo@rediffmail.com;
callsjo@yahoo.com;
sjo@incois.gov.in.
Web- http://oppamthadathil.tripod.com
***************************************

_________________________________________________________________
All the news that matters. Just the way you like it.
http://www.msn.co.in/News/ Only at MSN News!

        
--
___________________________________________________

    Jaison Kurian
    Centre for Atmospheric and Oceanic Sciences
    Indian Institute of Science
    B A N G A L O R E   560 012
    Ph: +91-80-3942505
        +91-80-3600450
    Fax:+91-80-3600865
___________________________________________________

      
_________________________________________________________________
Pep up your screen! Kickstart your day! 
http://www.msn.co.in/Cinema/screensaver/ Get these vibrant screensavers!

    

  

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement