<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear Amit, <br class="">You can plot a text file without converting it to a nc file, which could cause errors. Just use the function <font face="Menlo" class="">asciiread</font> and then assign the values correctly before plotting. Below is an example (only relevant commands are reported):<div class=""><br class=""></div><div class=""><font face="Menlo" class="">; read the data (you have to specify number of rows and columns, here are assumed</font></div><div class=""><font face="Menlo" class="">; to be lon | lat | value (pv)</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><div class=""><font face="Menlo" class=""> File = asciiread ("data_pv.txt",(/245220,3/),"double")</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> pv =File(:,2) ; last column</font></div><div class=""><font face="Menlo" class=""> lon=File(:,0) ; first column</font></div><div class=""><font face="Menlo" class=""> lat=File(:,1) ; second column</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> Res=True</font></div><div class=""><font face="Menlo" class=""> Res@sfXArray = lon</font></div><div class=""><font face="Menlo" class=""> Res@sfYArray = lat</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> Res@mpLimitMode = "LatLon"</font></div><div class=""><font face="Menlo" class=""> Res@mpMaxLonF = max(lon) </font></div><div class=""><font face="Menlo" class=""> Res@mpMinLonF = min(lon) </font></div><div class=""><font face="Menlo" class=""> Res@mpMinLatF = min(lat) </font></div><div class=""><font face="Menlo" class=""> Res@mpMaxLatF = max(lat)</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""> plot = gsn_csm_contour_map(wks,pv,Res)</font></div><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">Guido Cioni</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://guidocioni.altervista.org" class="">http://guidocioni.altervista.org</a> </div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 06 Sep 2016, at 10:03, Amit Kumar <<a href="mailto:amitkumar.777@hotmail.com" class="">amitkumar.777@hotmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="divtagdefaultwrapper" style="font-size: 10pt; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: rgb(38, 114, 236); background-color: rgb(255, 255, 255); font-family: Arial, Helvetica, sans-serif;" class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div class="">Hi all,<br class=""><br class="">I'm trying to plot a text file containing three columns lon , lat, value using ncl.<br class=""><br class="">First I converted my text file to nc using CDO. The nc file is like:<br class=""><br class="">##################################################################################<br class=""><br class=""><div class="">Variable: f<br class="">Type: file<br class="">filename: tir1<br class="">path: tir1.nc<br class=""> file global attributes:<br class=""> CDI : Climate Data Interface version ?? (<a href="http://mpimet.mpg.de/cdi" class="">http://mpimet.mpg.de/cdi</a>)<br class=""> Conventions : CF-1.4<br class=""> history : Tue Sep 06 11:56:42 2016: cdo -f nc input,my_gridfile tir1.nc<br class=""> CDO : Climate Data Operators version 1.7.0 (<a href="http://mpimet.mpg.de/cdo" class="">http://mpimet.mpg.de/cdo</a>)<br class=""> dimensions:<br class=""> ncells = 53248<br class=""> time = 1 // unlimited<br class=""> variables:<br class=""> double lon ( ncells )<br class=""> standard_name : longitude<br class=""> units : degrees_east<br class=""><br class=""> double lat ( ncells )<br class=""> standard_name : latitude<br class=""> units : degrees_north<br class=""><br class=""> double time ( time )<br class=""> standard_name : time<br class=""> units : hours since 0-0-0 00:00:00<br class=""> calendar : proleptic_gregorian<br class=""> axis : T<br class=""><br class=""> float var1 ( time, ncells )<br class=""> grid_type : unstructured<br class=""> coordinates : lat lon<br class="">###################################################################################<br class=""><br class=""></div>but I'm getting following errors:<br class=""><br class=""><span style="color: rgb(255, 0, 0);" class="">fatal:ScalarFieldInitialize: Insufficient number of elements in sfDataArray</span><br class=""><span style="color: rgb(255, 0, 0);" class="">fatal:Unable to initialize layer-Can't Create</span><br class=""><span style="color: rgb(255, 0, 0);" class="">fatal:Unable to access object with id:-4</span><br class=""><span style="color: rgb(255, 0, 0);" class="">fatal:PID #-4 can't be found in NhlSetValues</span><br class=""><span style="color: rgb(255, 0, 0);" class="">fatal:Unable to access object with id:-4</span><br class=""><span style="color: rgb(255, 0, 0);" class="">warning:Unable to add DataItem "(null)" to DataList "cnScalarFieldData"</span><br class=""><span style="color: rgb(255, 0, 0);" class="">fatal:CompileDataList:DataList has no valid members</span><br class=""></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">######################################################################################</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><div style="margin-top: 0px; margin-bottom: 0px;" class="">my script is :</div><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div class="">load "/usr/share/ncarg/nclscripts/csm/gsn_code.ncl"<br class="">load "/usr/share/ncarg/nclscripts/csm/gsn_csm.ncl"<br class="">load "/usr/share/ncarg/nclscripts/csm/contributed.ncl"<br class=""><br class=""><br class=""><br class="">begin<br class="">;---read in zonal winds<br class=""> a = addfile("/home/amit/Desktop/tir1.nc","r")<br class=""><br class=""> filename = "/media/amit/E/India_shapefile/State_bound(Satmet).shp"<br class=""><br class=""> ;filename = "/media/amit/E/India_shapefile/Districtbound(Satmet).shp"<br class=""><br class=""><br class=""> var = doubletofloat(a->var1)<br class=""> <br class="">lat = a->lat<br class="">lon = a->lon<br class=""><br class=""><br class=""> wks = gsn_open_wks("png","TIR1") ; send graphics to PNG file<br class=""><br class=""> res = True ; plot mods desired<br class=""> res@cnFillOn = True ; turn on color fill<br class=""> res@cnLinesOn = False<br class=""> res@gsnMaximize = True ; maximize plot in frame<br class=""> res@gsnDraw = False<br class=""> res@gsnFrame = False<br class=""><br class=""> res@mpOutlineOn = False ; Use outlines from shapefile<br class=""> res@mpFillOn = False <br class=""> res@cnFillMode = "RasterFill"<br class=""> res@trGridType = "TriangularMesh"<br class=""> res@cnRasterSmoothingOn = False<span class="Apple-converted-space"> </span><br class=""><br class="">res@cnLevelSelectionMode = "ExplicitLevels" <br class=""> res@cnLevels = (/190,220,240,250,260,265,270,275,280,285,290,300,320,360/) ; ; 14 contour values<br class=""> res@cnFillPalette = (/"Grey","BlueViolet","Blue4","Blue2","Cornflowerblue","darkslategray1","Cyan"\<br class=""> ,"chartreuse","khaki1","Yellow"\ ; 15 contour colors<br class=""> ,"Orange","darkorange4", "hotpink" \<br class=""> ,"Red","Black" /) <br class=""><br class="">res@tiMainString = "TIR1 Plot"<br class=""> res@tiMainFontHeightF = 0.016<span class="Apple-converted-space"> </span><br class=""> res@gsnAddCyclic = False<br class=""> res@lbOrientation = "Vertical"<br class=""><br class=""> res@sfXArray = lon<br class=""> res@sfYArray = lat<br class=""><br class=""><br class="">res@mpMinLonF = 68.0<br class="">res@mpMaxLonF = 98.0<br class="">res@mpMinLatF = 0.0<br class="">res@mpMaxLatF = 38.0<br class=""><br class="">res@pmTickMarkDisplayMode = "Always"<br class=""><br class="">res@tiXAxisString = "Longitude"<br class="">res@tiYAxisString = "Lattitude"<br class=""><br class="">res@tiXAxisFontHeightF = 0.02<br class="">res@tiYAxisFontHeightF = 0.02<span class="Apple-converted-space"> </span><br class=""><br class="">res@gsnStringFontHeightF = 0.005 <br class=""><br class=""> plot = gsn_csm_contour_map(wks,var, res) ; create plot<br class=""><br class="">;---Resource list for shapefile outlines<br class=""> plres = True<br class=""> plres@gsLineColor = "black"<br class=""> plres@gsLineThicknessF = "1.5"<br class=""> dumstr = unique_string("poly")<br class=""> <span class="Apple-converted-space"> </span><br class=""> id = gsn_add_shapefile_polylines(wks,plot,filename,plres)<br class=""><br class=""> draw(plot)<br class=""> frame(wks)<br class=""><br class="">end</div>####################################################################################################################<br class=""><p style="margin-top: 0px; margin-bottom: 0px;" class=""></p><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></div></div><span style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">ncl-talk mailing list</span><br style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:ncl-talk@ucar.edu" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">ncl-talk@ucar.edu</a><br style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">List instructions, subscriber options, unsubscribe:</span><br style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" style="font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></div></blockquote></div><br class=""></div></body></html>