<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'm trying to plot a text file containing three columns lon , lat, value using ncl.<br>
<br>
First I converted my text file to nc using CDO. The nc file is like:<br>
<br>
##################################################################################<br>
<br>
<div>Variable: f<br>
Type: file<br>
filename: tir1<br>
path: tir1.nc<br>
file global attributes:<br>
CDI : Climate Data Interface version ?? (http://mpimet.mpg.de/cdi)<br>
Conventions : CF-1.4<br>
history : Tue Sep 06 11:56:42 2016: cdo -f nc input,my_gridfile tir1.nc<br>
CDO : Climate Data Operators version 1.7.0 (http://mpimet.mpg.de/cdo)<br>
dimensions:<br>
ncells = 53248<br>
time = 1 // unlimited<br>
variables:<br>
double lon ( ncells )<br>
standard_name : longitude<br>
units : degrees_east<br>
<br>
double lat ( ncells )<br>
standard_name : latitude<br>
units : degrees_north<br>
<br>
double time ( time )<br>
standard_name : time<br>
units : hours since 0-0-0 00:00:00<br>
calendar : proleptic_gregorian<br>
axis : T<br>
<br>
float var1 ( time, ncells )<br>
grid_type : unstructured<br>
coordinates : lat lon<br>
###################################################################################<br>
<br>
</div>
but I'm getting following errors:<br>
<br>
<span style="color: rgb(255, 0, 0);">fatal:ScalarFieldInitialize: Insufficient number of elements in sfDataArray</span><br>
<span style="color: rgb(255, 0, 0);">fatal:Unable to initialize layer-Can't Create</span><br>
<span style="color: rgb(255, 0, 0);">fatal:Unable to access object with id:-4</span><br>
<span style="color: rgb(255, 0, 0);">fatal:PID #-4 can't be found in NhlSetValues</span><br>
<span style="color: rgb(255, 0, 0);">fatal:Unable to access object with id:-4</span><br>
<span style="color: rgb(255, 0, 0);">warning:Unable to add DataItem "(null)" to DataList "cnScalarFieldData"</span><br>
<span style="color: rgb(255, 0, 0);">fatal:CompileDataList:DataList has no valid members</span><br>
</div>
<p></p>
<p><br>
</p>
<p><br>
</p>
<p>######################################################################################</p>
<p><br>
</p>
<p>my script is :</p>
<p><br>
</p>
<p></p>
<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>
<br>
<br>
begin<br>
;---read in zonal winds<br>
a = addfile("/home/amit/Desktop/tir1.nc","r")<br>
<br>
filename = "/media/amit/E/India_shapefile/State_bound(Satmet).shp"<br>
<br>
;filename = "/media/amit/E/India_shapefile/Districtbound(Satmet).shp"<br>
<br>
<br>
var = doubletofloat(a->var1)<br>
<br>
lat = a->lat<br>
lon = a->lon<br>
<br>
<br>
wks = gsn_open_wks("png","TIR1") ; send graphics to PNG file<br>
<br>
res = True ; plot mods desired<br>
res@cnFillOn = True ; turn on color fill<br>
res@cnLinesOn = False<br>
res@gsnMaximize = True ; maximize plot in frame<br>
res@gsnDraw = False<br>
res@gsnFrame = False<br>
<br>
res@mpOutlineOn = False ; Use outlines from shapefile<br>
res@mpFillOn = False <br>
res@cnFillMode = "RasterFill"<br>
res@trGridType = "TriangularMesh"<br>
res@cnRasterSmoothingOn = False <br>
<br>
res@cnLevelSelectionMode = "ExplicitLevels" <br>
res@cnLevels = (/190,220,240,250,260,265,270,275,280,285,290,300,320,360/) ; ; 14 contour values<br>
res@cnFillPalette = (/"Grey","BlueViolet","Blue4","Blue2","Cornflowerblue","darkslategray1","Cyan"\<br>
,"chartreuse","khaki1","Yellow"\ ; 15 contour colors<br>
,"Orange","darkorange4", "hotpink" \<br>
,"Red","Black" /) <br>
<br>
res@tiMainString = "TIR1 Plot"<br>
res@tiMainFontHeightF = 0.016 <br>
res@gsnAddCyclic = False<br>
res@lbOrientation = "Vertical"<br>
<br>
res@sfXArray = lon<br>
res@sfYArray = lat<br>
<br>
<br>
res@mpMinLonF = 68.0<br>
res@mpMaxLonF = 98.0<br>
res@mpMinLatF = 0.0<br>
res@mpMaxLatF = 38.0<br>
<br>
res@pmTickMarkDisplayMode = "Always"<br>
<br>
res@tiXAxisString = "Longitude"<br>
res@tiYAxisString = "Lattitude"<br>
<br>
res@tiXAxisFontHeightF = 0.02<br>
res@tiYAxisFontHeightF = 0.02 <br>
<br>
res@gsnStringFontHeightF = 0.005 <br>
<br>
plot = gsn_csm_contour_map(wks,var, res) ; create plot<br>
<br>
;---Resource list for shapefile outlines<br>
plres = True<br>
plres@gsLineColor = "black"<br>
plres@gsLineThicknessF = "1.5"<br>
dumstr = unique_string("poly")<br>
<br>
id = gsn_add_shapefile_polylines(wks,plot,filename,plres)<br>
<br>
draw(plot)<br>
frame(wks)<br>
<br>
end</div>
####################################################################################################################<br>
<p></p>
<p><br>
</p>
</div>
</body>
</html>