ascval = ascval+sprintf("%8.2f ",lat(j)) ascval = ascval+sprintf("%8.2f ",lon(i))It should work after this. Thanks for pointing this out.
Hi Arindam, Thanks for your reply I used your code but it give some error massage in line ascval = ascval+sprintf("%8.2f %8.2f ",lat(j),lon(i)) Error massage: fatal:syntax error: function sprintf expects 2 arguments, got 3 fatal:Syntax Error in block, block not executed Thanks Debasish -----Original Message----- From: Arindam Chakraborty [mailto:arindam@met.fsu.edu] Sent: Sunday, June 03, 2007 2:45 PM To: Debasish Pai Mazumder Cc: ncl-talk@ucar.edu Subject: Re: netcdf to ascii conversion hi Debasish, there may be an easy way out for this in NCL, but the following should also work: ... ... ; var is the variable name, ; lon is the longitude dimension name, ; lat is the latitude dimension name. lon = var&lon lat = var&lat ; the following assumes the order of dimensions in the variables as (time,lat,lon) dimsz = dimsizes(var) nt = dimsz(0) ny = dimsz(1) nx = dimsz(2) fout = "ascfile.dat" ; output ascii file name system("echo > "+fout) ; create an empty file. Existing file will be overwritten. do j = 0, ny-1 do i = 0, nx-1 ascval = "" ascval = ascval+sprintf("%8.2f %8.2f ",lat(j),lon(i)) do k = 0, nt-1 ascval = ascval+sprintf("%6.1f ",var(k,j,i)) end do system("echo "+ascval+" >> "+fout) end do end do ... ... Hope this helps, arindam Debasish Pai Mazumder wrote:Hi all, I have a netcdf file for air temperature. The dimension of air temperature is given below, Air_temp(time,lat,lon) where time=124, lat=16, lon=59 I am trying to convert this fie in to ascii file. I used the code provided by Dennis Shea in website http://www.ncl.ucar.edu/Support/talk_archives/2006/0113.html and the program gave me different ascii files for lat, lon and temperature but all those values in ascii file are written in a one column. I also used write_matrix option but I guess it only works for two dimensional data. I am trying to make a ascii file with different rows and columns like lat lon time=0 time=1... time=123 41.5 25 260 262.6 267.8 41.5 27.5 261.2 262.3 264.5 . . . 41.5 160 254.6 262.9 270.5 43 25 260.2 264.4 267.8 43 27.5 .................. .......................... ......................... Is there any way to get ascii file with the given format from netcdf file in NCL Thanks Debasish---------------------------------------------------------------------------- -----Debasish Pai Mazumder Graduate Research Assistant Geophysical Institute,University of Alaska Fairbanks, 903 Koyukuk Drive Fairbanks, AK 99775 USA Phone : +1 907 474 7618 Email : debasish@gi.alaska.edu <mailto:debasish@gi.alaska.edu> ------------------------------------------------------------------------ _______________________________________________ ncl-talk mailing list ncl-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- ---------------------------- ARINDAM CHAKRABORTY Department of Meteorology Florida State University Tallahassee, FL-32306, USA Tel: +001-850-6443524 (Off) +001-850-5758550 (Res) Fax: +001-850-6449642 ____________________________
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Jun 03 2007 - 20:08:20 MDT
This archive was generated by hypermail 2.2.0 : Tue Jun 05 2007 - 16:18:21 MDT