Re: Read multiple ASCII files

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 03 2011 - 20:55:44 MST

Use the "new" function to create an empty 3-D array to hold all
matrices. Something like this:

   ntimes = 15
   nx = 360
   ny = 180
   dims = (/ ntimes, nx, ny /)
   data = new (dims, float)

Then use readAsciiTable to read in one matrix at a time. See
example 2 on the readAsciiTable page. This function takes care of
headers and footers if you set up the options correctly. Copy each
matrix into the correct time slice of the 3-D array. Do this for
each matrix, maybe in a loop if you can get the file names on the fly:

   do itime = 0, ntimes-1
     opt = ...
     matrix = readAsciiTable (filename(itime), nx, "float", opt)
     data(itime,:,:) = matrix
   end do

Now all data is in one big array, and you can move on to
calculations and making plots. That is the general idea. You will
have to do some debugging. HTH.

--Dave

On 3/3/2011 8:24 PM, Xin Xi wrote:
> Hi there,
> I have 15 ASCII files, same variable at different time levels, each
> file with a few header lines and then a matrix (lat x lon). I want
> to read all the matrix in and make plots. Is there a way to do this?
> I tried the example
> (http://www.ncl.ucar.edu/Applications/addfiles.shtml), but addfiles
> and ListSetType doesnot work in this case. Thanks for helping out.
>
> Xin
> --
> /Xin Xi
> School of Earth and Atmospheric Sciences
> Georgia Institute of Technology
> 311 Ferst Drive, Atlanta, GA 30332-0340/
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Mar 3 20:55:49 2011

This archive was generated by hypermail 2.1.8 : Mon Mar 07 2011 - 15:20:58 MST