;---------------------------------------------------------------------- ; This is a basic NCL template for creating contours over maps. ; ; Use "contour_template.ncl" if you don't need to put the ; contours over a map. ;---------------------------------------------------------------------- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" begin ;---Read data a = addfile("file.nc","r") x = a->x lat = a->lat ; Only necessary if "x" doesn't lon = a->lon ; contain 1D coordinate arrays. ;---Open workstation and change color map wks = gsn_open_wks("x11","contour_map") ; "ps", "pdf", "png" gsn_define_colormap(wks,"amwg") ;---Set some resources res = True res@gsnMaximize = True ; maximize plot in frame ;---These are sample resources you might want to set res@cnFillOn = True ; turn on contour fill res@cnLinesOn = False ; turn off contour lines res@cnLineLabelsOn = False ; turn off line labels ;---Use if you have a high-res grid that could be slow to plot. ; res@cnFillMode = "RasterFill" ;---This can also speed things up ; res@trGridType = "TriangularMesh ;---These two resources are not needed in V6.1.0 res@gsnSpreadColors = True ; span full color map res@lbLabelAutoStride = True ; nice spacing for labelbar labels ;---Uncomment if you want to change the contour levels ; mnmxint = nice_mnmxintvl( min(x), max(x), 18, False) ; res@cnLevelSelectionMode = "ManualLevels" ; res@cnMinLevelValF = mnmxint(0) ; res@cnMaxLevelValF = mnmxint(1) ; res@cnLevelSpacingF = mnmxint(2) res@tiMainString = "This is a main title" ;---Set to False if plotting regional data or setting sfXArray/sfYArray res@gsnAddCyclic = True res@sfXArray = lon ; Only necessary if x doesn't res@sfYArray = lat ; contain 1D coordinate arrays ; ; Zoom in on map if desired. There are other ways to zoom in on ; map if you have a different projection, like lambert conformal. ; res@mpMinLatF = min(lat) res@mpMaxLatF = max(lat) res@mpMinLonF = min(lon) res@mpMaxLonF = max(lon) res@mpCenterLonF = (res@mpMinLonF + res@mpMaxLonF) / 2. plot = gsn_csm_contour_map(wks,x,res) end