Re: reading multiple asci files

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 13 Oct 2009 02:29:08 -0600

The following code should append (concatenate)
multiple files. It uses the standard unix 'cat' command.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

    dasc = "./" ; input directory for ascii files
    fasc = "2009*asc" ; a unique identifier for files
  ;;fasc = "*asc"

    DASC = "./" ; output dir
    FASC = "BIG.asc" ; output file name

    system ("/bin/rm -f "+DASC+FASC) ; rm any pre-existing file
    system ("cd "+ dasc+" ; cat "+fasc+" > "+DASC+FASC)

;Then you could read the file via "asciiread"

    nrows = numAsciiRow(DASC+FASC) ; contributed.ncl
    ncols = numAsciiCol(DASC+FASC)
    data = asciiread(DASC+FASC,(/nrows,ncols/),"float")
    print(data)

  ;;system ("/bin/rm "+DASC+FASC) ; rm the created file

Good luck

jwsmith_at_ucar.edu wrote:
> Hello,
>
> I have the following command that reads in an ascii file:
>
> data = asciiread("20090401.asc",(/nrows,ncols/),"float")
>
> How can one read in multiple .asc files using the systemfunc and
> addfiles command with the asciiread stipulations above?
>
>
>
> Jonathan Wynn Smith
>
> Doctoral Student in Howard University
> Program in Atmospheric Sciences (HUPAS)
> 2008 ASP Graduate Student Visitor
> 2006 ASP Summer Colloquium Participant
>
> 408 Thirkield Building
> 2355 6th St. NW
> Washington, DC 20059
>
> E-mail: jw_smith_at_howard.edu or jwsmith9_at_gmail.com
> Cell Phone: 336-601-4563
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
> _______________________________________________
> 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 Tue Oct 13 2009 - 02:29:08 MDT

This archive was generated by hypermail 2.2.0 : Thu Oct 15 2009 - 09:30:48 MDT