Re: formatted write for a one dimensioal array

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 16 Jan 2008 10:52:33 -0700

> I see write_matrix works for a two dimensional array, is it possible
to write out a 1d array?

[1] asciiwrite can be used for 1D arrays
          
http://www.ncl.ucar.edu/Document/Functions/Built-in/asciiwrite.shtml

      By default, asciiwrite does not allow user format control, NCL
decides.
      However, you can use "sprintf"

         http://www.ncl.ucar.edu/Document/Functions/Built-in/sprintf.shtml

      So if x[*] then something like

         asciiwrite ( "foo.txt",* sprintf(*"%9.3f", x) )

[2] If still want to use write_matrix you can use "onedtond" to create a
     2D array with a degenerate dimension size of one.

        http://www.ncl.ucar.edu/Document/Functions/Built-in/onedtond.shtml

     x2d = onedtond( x, (/dimsizes(x),1/) )
  

   opt = True
   opt_at_fout = "FOO.txt"
   *write_matrix* (x2d, fmtx, opt)

   or, directly without the explicit temporary x2d

   write_matrix ( onedtond(x, /dimsizes(x),1/)) , fmtx, opt)

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 16 2008 - 10:52:33 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 17 2008 - 12:33:19 MST