<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hey,</div><div class="">I assume you already gave a look at the specific page on the NCL online guide.</div><div class=""><br class=""></div><div class="">First, what does it mean that you “cannot use cd_calendar”? Does it return error? What kind of error?&nbsp;</div><div class=""><br class=""></div><div class="">Second, given the other error that you are reporting, I believe that you are trying to make a contour plot out of the NETCDF file. If your goal is to make a contour plot out of the data contained in the ASCII file I would suggest you to do that directly, given that NCL has this capability. tTrying to convert everything into a NETCDF file before could be tricky.&nbsp;</div><div class=""><br class=""></div><div class="">Now, let’s get to the file. Have you tried to look into that before plotting?&nbsp;</div><div class=""><br class=""></div><div class="">[1] Look at the time variable:&nbsp;</div><div class=""><br class=""></div><div class="">[snippet…]</div><div class=""><div class="">Time coordinate : &nbsp;804 steps</div><div class="">&nbsp; &nbsp; &nbsp;RefTime = &nbsp;1950-01-01 00:00:00 &nbsp;Units = months &nbsp;Calendar = standard</div><div class="">&nbsp; YYYY-MM-DD hh:mm:ss &nbsp;YYYY-MM-DD hh:mm:ss &nbsp;YYYY-MM-DD hh:mm:ss &nbsp;YYYY-MM-DD hh:mm:ss</div><div class="">&nbsp;18200-02-01 00:00:00 18200-03-01 00:00:00 18200-04-01 00:00:00 18200-05-01 00:00:00</div><div class="">&nbsp;18200-06-01 00:00:00 18200-07-01 00:00:00 18200-08-01 00:00:00 18200-09-01 00:00:00</div><div class="">&nbsp;18200-10-01 00:00:00 18200-11-01 00:00:00 18200-12-01 00:00:00 18201-01-01 00:00:00</div><div class="">&nbsp;18208-06-01 00:00:00 18208-07-01 00:00:00 18208-08-01 00:00:00 18208-09-01 00:00:00</div></div><div class="">[…]</div><div class=""><br class=""></div><div class="">How is NCL supposed to interpret that? If you read from the ASCII file directly 195001 NCL will interpret as a number. You need to convert that into a time variable using YYYY and MM separate data. Look at the NCL documentation (<a href="http://www.ncl.ucar.edu/Document/Functions/date.shtml" class="">http://www.ncl.ucar.edu/Document/Functions/date.shtml</a>).&nbsp;</div><div class=""><br class=""></div><div class="">[2] Look at the lat and lon variables. They are NOT ordered in the ASCII file, so they will not be ordered in NETCDF file as well.&nbsp;</div><div class=""><br class=""></div><div class=""><div class="">&nbsp;lat = 9.68, 8.35, 8.75, 8.98, 8.12, 8.58, 7.72, 7.47, 7.33, 7.17, 6.9, 6.82,</div><div class="">&nbsp; &nbsp; 6.97, 6.98, 6.98, 6.03, 6.12, 8.03 ;</div></div><div class=""><br class=""></div><div class="">NCL can not handle non-monotonic coordinate array, so you would need to reorder every row in the ASCII file before even plotting or converting to a NETCDF file.&nbsp;</div><div class=""><br class=""></div><div class="">Good luck</div><br class=""><div><blockquote type="cite" class=""><div class="">Il giorno 12 mar 2017, alle ore 02:58, Priyanka Silva &lt;<a href="mailto:priyankakeraminiya6@gmail.com" class="">priyankakeraminiya6@gmail.com</a>&gt; ha scritto:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><p class="MsoNormal">Dear Sir/Madam,</p><p class="MsoNormal"><br class=""></p><p class="MsoNormal">I'm a beginner of the NCL. I wanted to convert ASCII file&nbsp;
to netcdf file. I created netcdf file but I cannot use it. The ASCII file has Monthly precipitation data of 18 stations (from 195001 to 201612). It has time, latitude , longitude and
precipitation data. Missing value for precipitation is -999.9. The ASCII file is attached. When I use my netcdf file I cannot use "cd_calendar" and also I get the following error messages.</p><p class="MsoNormal"><br class=""></p><p class="MsoNormal"><br class=""></p><p class="MsoNormal">warning:ScalarFieldSetValues: irregular coordinate array sfYArray non-monotonic:<br class="">&nbsp;defaulting sfYArray<br class="">warning:ContourPlotSetValues: cnLevelSpacingF value exceeds or equals data range<br class="">: defaulting<br class=""><br class=""></p><p class="MsoNormal"><br class=""></p><p class="MsoNormal">Thank you for any help.</p><p class="MsoNormal"><br class=""></p><p class="MsoNormal">Best regards,</p><p class="MsoNormal">Priyanka.</p><p class="MsoNormal"><br class=""></p><p class="MsoNormal"><br class=""></p><p class="MsoNormal"><br class=""></p><p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"<br class=""><br class="">begin<br class="">;---------------------------------------------------------------------------<br class="">ncol = 4<br class="">nrow = numAsciiRow ("Mon_precip.txt")<br class=""><br class="">ntime =804<br class="">nlat = 804<br class="">nlon = 804<br class=""><br class="">data = asciiread ("Mon_precip.txt",(/nrow,ncol/), "float")<br class=""><br class="">data@FillValue = -999.9<br class="">printVarSummary(data)<br class=""><br class="">time = data(:ntime-1,0)<br class="">mtime = dimsizes(time)<br class="">lat = data (::nlat,1)<br class="">mlat = dimsizes(lat)<br class="">lon = data (::nlon,2)<br class="">mlon = dimsizes(lon)<br class=""><br class="">precip = data (:,3)<br class=""><br class="">precip@units = "mm/month"<br class="">lat@long_name = "latitude"<br class="">lat@units&nbsp;&nbsp;&nbsp;&nbsp; = "degrees_north"<br class="">lon@long_name = "longitude"<br class="">lon@units&nbsp;&nbsp;&nbsp;&nbsp; = "degrees_east"<br class="">time@units&nbsp;&nbsp; = "months since 1950-01"<br class="">time@calendar = "standard"<br class=""><br class="">printVarSummary(time)<br class="">printVarSummary(lat)<br class="">printVarSummary(lon)<br class="">printVarSummary(precip)<br class=""><br class="">;---------------------------------------------------------------------------<br class="">pre = onedtond(precip,(/mtime,mlat,mlon/))<br class="">printVarSummary(pre)<br class="">;------------------------------------------------------------------------<br class="">&nbsp; ; Assign named dimension<br class="">;----------------------------------------------------------------------<br class="">lat!0 = "lat"<br class="">lon!0 = "lon"<br class="">time!0 = "time"<br class=""><br class="">pre!0 = "time"<br class="">pre!1 = "lat"<br class="">pre!2 = "lon"<br class="">;-----------------------------------------------------------------------<br class="">&nbsp; ; Assign coordinate variables<br class="">;-----------------------------------------------------------------------<br class="">time&amp;time = time<br class="">lat&amp;lat =&nbsp; lat<br class="">lon&amp;lon =&nbsp; lon<br class=""><br class="">pre&amp;time = time<br class="">pre&amp;lat&nbsp; = lat<br class="">pre&amp;lon&nbsp; = lon<br class="">;---------------------------------------------------------------------<br class="">&nbsp; ; write netcdf<br class="">;--------------------------------------------------------------------<br class="">system("rm -rf precip_monSL.nc")<br class="">fout = addfile("precip_monSL.nc","c")<br class="">fout-&gt;precip = pre<br class="">;--------------------------------------------------------------------<br class="">&nbsp;&nbsp;&nbsp;&nbsp; ;create global attributes of the file<br class="">;------------------------------------------------------------------<br class="">fAtt&nbsp; = True<br class="">fAtt@title = "Monthly average precipitation in Sri Lanka(195001-201612)"<br class="">fileattdef( fout, fAtt ) ; copy file attributes<br class="">;-----------------------------------------------------------------------------------------------------</p><p class="MsoNormal">end<br class=""></p><p class="MsoNormal"><br class=""></p><p class="MsoNormal"><br class=""></p></div>
<span id="cid:DAFCC54B-8D6B-4A5E-B06B-543866AF10ED@fritz.box">&lt;Mon_precip.txt&gt;</span>_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></body></html>