Re: Export data in txt file

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 01 2014 - 10:11:17 MDT

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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Apr 1 10:11:32 2014

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