; Triangular mesh example, actually taken from example ESMF_regrid_21.ncl. load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin infile = "station-data.0726.zilore.txt" title = "Zilore precip data, 2014 July 26" ; Data is stored in four columns: ; ; station ID lon lat rainfall ; ; Read in each line as a string, and use "str_get_field" to ; read in the fields of interest. lines = asciiread (infile,-1,"string") ; Use "str_get_field" to indicate which fields to read in. Each field ; is separated by spaces. lon = tofloat(str_get_field(lines(1:),2," ")) lat = tofloat(str_get_field(lines(1:),3," ")) dat = tofloat(str_get_field(lines(1:),4," ")) minlat = min(lat) maxlat = max(lat) minlon = min(lon) maxlon = max(lon) ;---Plotting section wks = gsn_open_wks ("x11", "station_data") res = True res@gsnDraw = False ; delay output to add markers res@gsnFrame = False res@tiMainString = title res@tiMainFontHeightF = 0.02 mnmxint = nice_mnmxintvl( min(dat), max(dat), 25, False) ;---Be sure to use same levels for both plots res@cnLevelSelectionMode = "ManualLevels" res@cnMinLevelValF = mnmxint(0) res@cnMaxLevelValF = mnmxint(1) res@cnLevelSpacingF = mnmxint(2) res@cnFillOn = True res@cnLinesOn = False res@cnLineLabelsOn = False border = 0.5 ; degrees res@mpFillOn = False res@mpMinLatF = minlat - border res@mpMaxLatF = maxlat + border res@mpMinLonF = minlon - border res@mpMaxLonF = maxlon + border res@pmTickMarkDisplayMode = "Always" ; new style tick marks res@mpOutlineBoundarySets = "National" ; country outlines res@gsnAddCyclic = False ;---Use the station coordinates as the mesh coordinates. res@sfXArray = lon res@sfYArray = lat ;---Create plot of original data map_orig = gsn_csm_contour_map (wks, dat, res) ;---Add markers showing original lat/lon locations mkres = True mkres@gsMarkerIndex = 17 ; Filled circle mkres@gsMarkerSizeF = 0.03 poly1 = gsn_add_polymarker (wks,map_orig,lon,lat,mkres) ; Output plot to file or window. draw (map_orig) frame (wks) end