Re: Header lines in ascii input files

From: Dennis Shea (shea AT XXXXXX)
Date: Wed Feb 19 2003 - 12:16:05 MST

  • Next message: Christian Pagé: "dumping resources values"

    A slight variation of Mary's response:

    PART A: In this instance Mary's suggestion
               x = asciiread("file.txt",(/7,5/),"float")
            would be best. The following is more cumbersome
            but would yield the same result.

    ncl 1> x1 = asciiread("file.txt" , -1, "float")
    ncl 2> x2 = onedtond(x, (/7,5/))

    PART B: However, the following file ("FILE.txt") can also be read using
            the above approach.

    This header line contains no numbers
    but this 2nd line has 3 numbers: 10, 30, 50. and a blank line.

       4.35 4.39 0.27 -3.35 -6.90
       4.36 4.66 3.77 -1.66 4.06
       9.73 -5.84 0.89 8.46 10.39
       4.91 4.59 -3.09 7.55 4.56
       1.77 3.68 5.08 0.14 -5.63
      -0.63 -14.12 -2.51 1.76 -1.43
      -4.29 0.07 5.85 0.87 8.65
      
    ncl 0> x1 = asciiread("FILE.txt" , -1, "float")
    ncl 1> print (x1)

    Variable: x1
    Type: float
    Total Size: 160 bytes
                40 values
    Number of Dimensions: 1
    Dimensions and sizes: [40]
    Coordinates:
    (0) 2
    (1) 3
    (2) 10
    (3) 30
    (4) 50
    (5) 4.35
    (6) 4.39
    (7) 0.27
    (8) -3.35
    (9) -6.9
    [snip]

    ncl 2> x2 = onedtond(x1(5:), (/7,5/)) ; must know starting index
    ncl 3> print (x2)

    Variable: x2
    Type: float
    Total Size: 140 bytes
                35 values
    Number of Dimensions: 2
    Dimensions and sizes: [7] x [5]
    Coordinates:
    (0,0) 4.35
    (0,1) 4.39
    (0,2) 0.27
    [snip]

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Wed Feb 19 2003 - 12:05:59 MST