Re: formatted output file with string

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 25 2012 - 10:02:48 MDT

If you have 6.1.0-beta, you may want to try:

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

Wei

huangwei@ucar.edu
VETS/CISL
National Center for Atmospheric Research
P.O. Box 3000 (1850 Table Mesa Dr.)
Boulder, CO 80307-3000 USA
(303) 497-8924

On Jun 25, 2012, at 6:46 AM, Dennis Shea wrote:

> The example writes a 'formatted string'
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> ;---Generate some dummy integer, float, and string data
> npts = 100
> i = ispan(1,npts,1)
> j = generate_unique_indices(npts)
> k = generate_unique_indices(npts)
> x = random_uniform(-10,10,npts)
> y = random_uniform(0,1000.,npts)
> str1 = "string_" + sprinti("%03i", j)
> str2 = "string_" + sprinti("%03i", k)
>
> ;---Create an array of strings with formatted fields
> lines = str1 + \
> sprintf("%8.2f",x) + \
> sprinti("%4.0i", i) + \
> sprintf("%8.1f",y) + \
> " " + str2
>
> ;---Write to a file
> asciiwrite("file.txt",lines) ; <----------- write to file
>
>
> On 6/25/12 2:11 AM, ousmane ndiaye wrote:
>> Dear all,
>> I want to save in a file some text and data (float) in a formatted way.
>> I only see this example
>> http://www.ncl.ucar.edu/Applications/o-ascii.shtml but here I can't see
>> way to write formatted string.
>> Ousmane
>>
>>
>>
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 25 10:02:49 2012

This archive was generated by hypermail 2.1.8 : Fri Jun 29 2012 - 15:46:14 MDT