Re: Export data in txt file

From: Ioannis Koletsis <koletsis_at_nyahnyahspammersnyahnyah>
Date: Thu Apr 03 2014 - 03:16:52 MDT

Dear Rick,

thanks a lot!!!

This is exactly what I need.

Now, the output file contains information about hourly precipitation for
each grid point (lat, lon).

 

Thank you again.

 

Best regards

Ioannis

 

From: ncl-talk-bounces@ucar.edu [mailto:ncl-talk-bounces@ucar.edu] On Behalf
Of Rick Brownrigg
Sent: Tuesday, April 01, 2014 7:11 PM
To: Ioannis Koletsis
Cc: ncl-talk@ucar.edu
Subject: Re: Export data in txt file

 

Hi,

 

I can see why you are getting the result you are, but I'm having difficulty
determining what you are trying to do. Is the intent to write the #, lon
and lat fields to the string variable "data", and then for each file, append
a column from rain_tot_tend? If so, then I would think what you'd need to
do is create "data" and write the #,lat,lon columns *only* on FirstTime
through the outer loop over numFILES, but each through that loop, append
rain_tot_tend to "data(npt)" ; the innermost loop is not necessary and is
causing problems. Something more like:

 

FirstTime=True

  do ifil = 0,numFILES-1 ; BIG FILES LOOP

  a = addfile(FILES(ifil)+".nc","r")

...skipped lines....

     if (FirstTime) then

         fname = "TEST.txt"

         data = new(npts,"string")

     end if

 

     npt =-1

    

     do nl =0, nlat-1 ; do-loop lat

       do ml = 0, mlon-1 ; do-loop lon

          npt = npt+1

              if (FirstTime) then

                  data(npt) = sprinti("%05i ",(npt+1))

                  data(npt) = data(npt) + sprintf("%7.3f ", lat(nl,ml))

                  data(npt) = data(npt) + sprintf("%7.3f ", lon(nl,ml))

              end if

             data(npt) = data(npt) + sprintf("%7.3f ", rain_tot_tend(nl,ml))

      end do ; do-loop lat

   end do ; do-loop lon

 

  FirstTime = False

 

  end do ; outer loop over numFILES

 

  asciiwrite(fname, data)

 

On Apr 1, 2014, at 5:13 AM, "Ioannis Koletsis" <koletsis@noa.gr> wrote:

Dear ncl users,

I would like to create a txt file with the following format.

number | lat | lon| rain1 |rain2 |rain3 | ....etc

I used the attached script (prec_create_txt.ncl) and the given attached
output file (TEST.txt) gives me the desired format but with the last data
value (record of rain 3) is repeated for whole the data columns.

 

I believe that the error in the script located at the do loops but I am
really confused..

 

Have you got any idea???

 

Any help would be greatly appreciated..

 

Thanks in advance

 

Ioannis

 

<prec_create_txt.ncl><TEST.txt>_____________________________________________
__
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
 <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

 

  _____

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2014.0.4355 / Virus Database: 3722/7284 - Release Date: 04/01/14

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 3 03:17:09 2014

This archive was generated by hypermail 2.1.8 : Thu Apr 03 2014 - 13:36:27 MDT