Re: formatted write for a one dimensioal array

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 16 Jan 2008 11:02:48 -0700

My email sometimes adds extra characters when I copy.
The * should not be present

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

Dennis Shea wrote:
> > 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

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 16 2008 - 11:02:48 MST

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