<div dir="ltr"><p class="MsoNormal">Dear Sir/Madam,</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">I'm a beginner of the NCL. I wanted to convert ASCII file
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></p><p class="MsoNormal"><br></p><p class="MsoNormal">warning:ScalarFieldSetValues: irregular coordinate array sfYArray non-monotonic:<br> defaulting sfYArray<br>warning:ContourPlotSetValues: cnLevelSpacingF value exceeds or equals data range<br>: defaulting<br><br></p>
<p class="MsoNormal"><br></p><p class="MsoNormal">Thank you for any help.</p>
<p class="MsoNormal"><br></p><p class="MsoNormal">Best regards,</p>
<p class="MsoNormal">Priyanka.</p><p class="MsoNormal"><br></p><p class="MsoNormal"><br></p><p class="MsoNormal"><br></p><p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"<br><br>begin<br>;---------------------------------------------------------------------------<br>ncol = 4<br>nrow = numAsciiRow ("Mon_precip.txt")<br><br>ntime =804<br>nlat = 804<br>nlon = 804<br><br>data = asciiread ("Mon_precip.txt",(/nrow,ncol/), "float")<br><br>data@FillValue = -999.9<br>printVarSummary(data)<br><br>time = data(:ntime-1,0)<br>mtime = dimsizes(time)<br>lat = data (::nlat,1)<br>mlat = dimsizes(lat)<br>lon = data (::nlon,2)<br>mlon = dimsizes(lon)<br><br>precip = data (:,3)<br><br>precip@units = "mm/month"<br>lat@long_name = "latitude"<br>lat@units = "degrees_north"<br>lon@long_name = "longitude"<br>lon@units = "degrees_east"<br>time@units = "months since 1950-01"<br>time@calendar = "standard"<br><br>printVarSummary(time)<br>printVarSummary(lat)<br>printVarSummary(lon)<br>printVarSummary(precip)<br><br>;---------------------------------------------------------------------------<br>pre = onedtond(precip,(/mtime,mlat,mlon/))<br>printVarSummary(pre)<br>;------------------------------------------------------------------------<br> ; Assign named dimension<br>;----------------------------------------------------------------------<br>lat!0 = "lat"<br>lon!0 = "lon"<br>time!0 = "time"<br><br>pre!0 = "time"<br>pre!1 = "lat"<br>pre!2 = "lon"<br>;-----------------------------------------------------------------------<br> ; Assign coordinate variables<br>;-----------------------------------------------------------------------<br>time&time = time<br>lat&lat = lat<br>lon&lon = lon<br><br>pre&time = time<br>pre&lat = lat<br>pre&lon = lon<br>;---------------------------------------------------------------------<br> ; write netcdf<br>;--------------------------------------------------------------------<br>system("rm -rf precip_monSL.nc")<br>fout = addfile("precip_monSL.nc","c")<br>fout->precip = pre<br>;--------------------------------------------------------------------<br> ;create global attributes of the file<br>;------------------------------------------------------------------<br>fAtt = True<br>fAtt@title = "Monthly average precipitation in Sri Lanka(195001-201612)"<br>fileattdef( fout, fAtt ) ; copy file attributes<br>;-----------------------------------------------------------------------------------------------------</p><p class="MsoNormal">end<br></p><p class="MsoNormal"><br></p><p class="MsoNormal"><br></p></div>