<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:10pt;color:#2672EC;background-color:#FFFFFF;font-family:Arial,Helvetica,sans-serif;">
<p></p>
<div>Hi All,<br>
<br>
I tried the below script but got following error:<br>
<br>
<span style="color: rgb(255, 0, 0);">fatal:Cannot create triangular mesh: supply additional resources or build with Triangle package</span><br>
<span style="color: rgb(255, 0, 0);">fatal:ContourPlotDraw: draw error</span><br>
<span style="color: rgb(255, 0, 0);">fatal:ContourPlotDraw: draw error</span><br>
<span style="color: rgb(255, 0, 0);">fatal:ContourPlotDraw: draw error</span><br>
<span style="color: rgb(255, 0, 0);">fatal:PlotManagerDraw: error in plot draw</span><br>
<span style="color: rgb(255, 0, 0);">fatal:_NhlPlotManagerDraw: Draw error</span><br>
</div>
<br>
###################################################################################################<br>
script i used is:<br>
<br>
<div>load "/usr/share/ncarg/nclscripts/csm/gsn_code.ncl"<br>
load "/usr/share/ncarg/nclscripts/csm/gsn_csm.ncl"<br>
load "/usr/share/ncarg/nclscripts/csm/contributed.ncl"<br>
<br>
begin <br>
<br>
File = asciiread("tir1.txt",(/53248,3/),"double")<br>
<br>
pv =File(:,2) ; last column<br>
lon=File(:,0) ; first column<br>
lat=File(:,1) ; second column<br>
<br>
wks = gsn_open_wks("png","tir1") <br>
res=True<br>
<br>
res@gsnDraw = True<br>
res@gsnFrame = True<br>
res@gsnAddCyclic = False<br>
res@gsnStringFontHeightF = 0.015<br>
res@cnFillOn = True ; turn on color fill<br>
res@cnFillMode = "RasterFill"<br>
res@trGridType = "TriangularMesh"<br>
res@cnRasterSmoothingOn = False <br>
res@gsnMaximize = True ; maximize plot in frame<br>
res@mpOutlineOn = True ; Use outlines from shapefile<br>
res@mpFillOn = False<br>
res@cnLinesOn = False ; turn off contour lines<br>
res@cnLineLabelsOn = False ; turn off line labels<br>
res@cnLevelSelectionMode = "ExplicitLevels"<br>
res@cnLevels = (/180,190,200,210,220,230,240,250,260,270,280,290,300,310/) ; 14 contour values<br>
res@cnFillPalette = (/"Grey100","BlueViolet","Blue4","Blue2","Cornflowerblue","darkslategray1","Cyan"\<br>
,"chartreuse","darkgreen","Yellow"\ ; 15 contour colors<br>
,"Orange","darkorange4", "palevioletred1","orangered" \<br>
,"Red3" /) <br>
<br>
res@lbLabelBarOn = True<br>
res@lbOrientation = "Vertical"<br>
res@sfXArray = lon<br>
res@sfYArray = lat<br>
res@mpLimitMode = "LatLon"<br>
res@mpMaxLonF = max(lon) <br>
res@mpMinLonF = min(lon) <br>
res@mpMinLatF = min(lat) <br>
res@mpMaxLatF = max(lat)<br>
res@pmTickMarkDisplayMode = "Always"<br>
<br>
<br>
plot = gsn_csm_contour_map(wks,pv,res)<br>
<br>
end</div>
<br>
<p></p>
regards<br>
Amit<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Guido Cioni <guidocioni@gmail.com><br>
<b>Sent:</b> Tuesday, September 6, 2016 5:13 PM<br>
<b>To:</b> Amit Kumar<br>
<b>Cc:</b> ncl-talk@ucar.edu<br>
<b>Subject:</b> Re: [ncl-talk] Issue with ploting of irregular txt/nc file</font>
<div> </div>
</div>
<div>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 class="" face="Menlo">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 class="" face="Menlo">; read the data (you have to specify number of rows and columns, here are assumed</font></div>
<div class=""><font class="" face="Menlo">; to be lon | lat | value (pv)</font></div>
<div class=""><font class="" face="Menlo"><br class="">
</font></div>
<div class="">
<div class=""><font class="" face="Menlo"> File = asciiread ("data_pv.txt",(/245220,3/),"double")</font></div>
<div class=""><font class="" face="Menlo"><br class="">
</font></div>
<div class=""><font class="" face="Menlo"> pv =File(:,2) ; last column</font></div>
<div class=""><font class="" face="Menlo"> lon=File(:,0) ; first column</font></div>
<div class=""><font class="" face="Menlo"> lat=File(:,1) ; second column</font></div>
<div class=""><font class="" face="Menlo"><br class="">
</font></div>
<div class=""><font class="" face="Menlo"> Res=True</font></div>
<div class=""><font class="" face="Menlo"> Res@sfXArray = lon</font></div>
<div class=""><font class="" face="Menlo"> Res@sfYArray = lat</font></div>
<div class=""><font class="" face="Menlo"><br class="">
</font></div>
<div class=""><font class="" face="Menlo"> Res@mpLimitMode = "LatLon"</font></div>
<div class=""><font class="" face="Menlo"> Res@mpMaxLonF = max(lon) </font></div>
<div class=""><font class="" face="Menlo"> Res@mpMinLonF = min(lon) </font></div>
<div class=""><font class="" face="Menlo"> Res@mpMinLatF = min(lat) </font></div>
<div class=""><font class="" face="Menlo"> Res@mpMaxLatF = max(lat)</font></div>
<div class=""><font class="" face="Menlo"><br class="">
</font></div>
<div class=""><font class="" face="Menlo"> plot = gsn_csm_contour_map(wks,pv,Res)</font></div>
<div class="">
<div class="" 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">
<br class="Apple-interchange-newline">
Guido Cioni</div>
<div class="" 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">
<a id="LPlnk393719" 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" class="" style="font-size:10pt; font-style: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; color:rgb(38,114,236); background-color:rgb(255,255,255); font-family:Arial,Helvetica,sans-serif">
<p class="" style="margin-top:0px; margin-bottom:0px"></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 class="" style="color:rgb(255,0,0)">fatal:ScalarFieldInitialize: Insufficient number of elements in sfDataArray</span><br class="">
<span class="" style="color:rgb(255,0,0)">fatal:Unable to initialize layer-Can't Create</span><br class="">
<span class="" style="color:rgb(255,0,0)">fatal:Unable to access object with id:-4</span><br class="">
<span class="" style="color:rgb(255,0,0)">fatal:PID #-4 can't be found in NhlSetValues</span><br class="">
<span class="" style="color:rgb(255,0,0)">fatal:Unable to access object with id:-4</span><br class="">
<span class="" style="color:rgb(255,0,0)">warning:Unable to add DataItem "(null)" to DataList "cnScalarFieldData"</span><br class="">
<span class="" style="color:rgb(255,0,0)">fatal:CompileDataList:DataList has no valid members</span><br class="">
</div>
<p class="" style="margin-top:0px; margin-bottom:0px"></p>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px">######################################################################################</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<div class="" style="margin-top:0px; margin-bottom:0px">my script is :</div>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
<p class="" style="margin-top:0px; margin-bottom:0px"></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 class="" style="margin-top:0px; margin-bottom:0px"></p>
<div class="" style="margin-top:0px; margin-bottom:0px"><br class="">
</div>
</div>
<span class="" style="font-family:Helvetica; font-size:13px; font-style: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; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Helvetica; font-size:13px; font-style: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">
<span class="" style="font-family:Helvetica; font-size:13px; font-style: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; float:none; display:inline!important">ncl-talk
mailing list</span><br class="" style="font-family:Helvetica; font-size:13px; font-style: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">
<a href="mailto:ncl-talk@ucar.edu" class="" style="font-family:Helvetica; font-size:13px; font-style: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">ncl-talk@ucar.edu</a><br class="" style="font-family:Helvetica; font-size:13px; font-style: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">
<span class="" style="font-family:Helvetica; font-size:13px; font-style: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; float:none; display:inline!important">List
instructions, subscriber options, unsubscribe:</span><br class="" style="font-family:Helvetica; font-size:13px; font-style: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">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" class="" style="font-family:Helvetica; font-size:13px; font-style: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">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>