Re: Efficient way to read ascii blocks

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 06 2010 - 09:49:28 MDT

Hi Gina,

My first suggestion is to read the whole file at once as a big string array, and use one or more of the str_xxxx functions to parse out the blocks as necessary.

If I can see the file, then I can suggest some functions to use.

Thanks,

--Mary

On Oct 6, 2010, at 9:06 AM, Gina Henderson wrote:

> Hi there,
>
> I am trying to figure out an efficient way to read in an ascii file into a 4D array without looping (as I would have done in fortran).
>
> The ascii file contains blocks or grids of the format (/nrow, ncol/), (/89,89/) with a header line. Each block relates to a monthly grid, where there are 456 blocks relating to 38 years of data.
>
> What I am trying to do is read in all blocks and assign to an array of the shape, (/nyear, nmonth, nrow, ncol/), where (/38, 12, 89, 89/).
>
> Is there a way to do this without looping in ncl as I realize that is not very efficient? Before I have used onedtond for these types of problems but am not sure if I can use this as am starting with a 2d array and also have a header line to deal with at the top of each block.
>
> Any suggestions would be greatly appreciated.
> Thanks, Gina.
>
> _______________________________________________
> 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 Wed Oct 6 09:49:44 2010

This archive was generated by hypermail 2.1.8 : Wed Oct 06 2010 - 09:53:35 MDT