;---------------------------------------------------------------------- ; Plot gridded data : Negin ;---------------------------------------------------------------------- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ; must be set at start of each file load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" ; must be set at start of each file begin ; begin file ;---------------------------------------------------------------------- ; read in file ;---------------------------------------------------------------------- x = readAsciiTable("negin.txt" , 3 , "float",0) ; read table with 3 columns (0 is no options) ;printVarSummary(x) ; prints summary of variable just imported ;print(x) ; prints file in full ;---------------------------------------------------------------------- ; grid data if you have all the data ;---------------------------------------------------------------------- lon = x(:,0) lat = x(:,1) value = x(:,2) ;---------------------------------------------------------------------- ; plot data ;---------------------------------------------------------------------- wks = gsn_open_wks ("pdf","scatter" ) ; open workstation x11 or pdf res = True ; set map resources to valid res@gsnFrame = False ; don't print plot straight away res@gsnMaximize = True res@tiMainString = "Locations of data" ; main label res@cnFillOn = True ; turn on color res@cnLinesOn = False ; turn off contour lines res@cnLineLabelsOn = False ; turn off contour line labels res@trGridType = "TriangularMesh" ;"TriangularMesh" res@sfXArray = lon ; lon coords res@sfYArray = lat ; lat coords res@mpMinLatF = min(lat) - 5 ; set map bounds lat min (remove -5 to zoom in) res@mpMaxLatF = max(lat) + 5 ; set map bounds lat max (remove -5 to zoom in) res@mpMinLonF = min(lon) - 5 ; set map bounds lon min (remove -5 to zoom in) res@mpMaxLonF = max(lon) + 5 ; set map bounds lon max (remove -5 to zoom in) res@mpDataBaseVersion = "Ncarg4_1" ; set database of maps res@mpDataSetName = "Earth..4" ; set resolution of map to be used res@mpOutlineBoundarySets= "National" ; set boundary outlines res@mpGeophysicalLineColor = "black" ; set boundary colour plot = gsn_csm_contour_map_ce(wks,value,res) ; contour the variable draw(plot) ;draw plot frame(wks) ;print to page end ; end file