[ncl-talk] Creating netCDF file from ascii file
Dennis Shea
shea at ucar.edu
Fri Mar 3 08:57:54 MST 2017
Users can not just take some WWW sample and expect it to work. Users *must*
look at the information they have available and make the appropriate
changes. Your sample has lev, lat, lon. The ascii file has none of this
information. How is NCL supposed to know what these are? You must eliminate
these.
If you are new to NCL, please *carefully* read:
http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/
These tutorials are very helpful.
===
Attached is an example script with your data. It created the simple netCDF
file. You will have to add additional code (long_name, units, additional
variables). The code has some links. Please read to the pages indicated.
===
The golden rules of data processing are (1) Look at you data; (2) Know your
data
On Fri, Mar 3, 2017 at 7:49 AM, Najib Yusuf <najibgal at yahoo.com> wrote:
> Dear ncl users,
>
> I have some ascii files from observation data (see attached please), I
> want to convert these file to netCDF file for easy comparison with model
> data. I am writing the codes but came across some errors as can be seen
> below, please help to put me through to correct the error and complete my
> script. Thank you
>
> [model-user at model-vm ~]$ ncl
> Copyright (C) 1995-2015 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 6.3.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> ncl 0> time = ("julian day")
> ncl 1> ntim = dimsizes("time")
> ncl 2> lev = ("350")
> ncl 3> klev = dimsizes("lev")
> ncl 4> lat = ("8.32")
> ncl 5> nlat = dimsizes ("lat")
> ncl 6> lon = ("4.34")
> ncl 7> nlon = dimsizes ("lon")
> ncl 8> diri = "/home/model-user/"
> ncl 9> fili = "Thirteen.nc"
> ncl 10> system("/bin/rm -f " + diri + fili)
> ncl 11> fout = addfile (diri + fili, "c")
> ncl 12> setfileoption(fout,"DefineMode",True)
> ncl 13> fAtt = True
> ncl 14> fAtt at title = "netCDF creation"
> ncl 15> fAtt at source_file = "original-file.nc"
> ncl 16> fAtt at Conventions = "None"
> ncl 17> fAtt at creation_date = systemfunc ("date")
> ncl 18> fileattdef(fout, fAtt)
> ncl 19> dimNames = (/"time", "lat", "lon", "lev"/)
> ncl 20> dimSizes = (/-1, nlat, nlon, klev/)
> ncl 21> dimUnlim =(/True, False, False, False/)
> ncl 22> filedimdef(fout,dimNames,dimSizes,dimUnlim)
> ncl 23> filevardef(fout, "time", typeof(time),getvardims(time))
> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 23
>
> ncl 24> filevardef(fout,"time", typeof(time),getvardims(time))
> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 24
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170303/7936c5b5/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AOT_txt2nc.ncl
Type: text/x-ncl
Size: 2482 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170303/7936c5b5/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: AOT_550_2013.nc
Type: application/x-netcdf
Size: 2700 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170303/7936c5b5/attachment.nc
More information about the ncl-talk
mailing list