load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl" begin ; ; Open a netCDF file containing storm data. ; tfile = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/Tstorm.cdf","r") ; ; Get the temperature arrays for the first 6 time steps. ; nplots = 6 temp = tfile->t(0:nplots-1,:,:) ; ; Save the lat and lon arrays to a variable. ; lat = tfile->t&lat lon = tfile->t&lon lat@name = "latitude" ; Name the lat variable. lon@name = "longitude" ; Name the lon variable. wks = gsn_open_wks("x11","panel") ; Open an X11 workstation. ; ; Define a color map. ; cmap = (/(/1.00,1.00,1.00/),(/0.00,0.00,0.00/),(/1.00,.000,.000/),\ (/.950,.010,.000/),(/.870,.050,.000/),(/.800,.090,.000/),\ (/.700,.090,.000/),(/.700,.120,.000/),(/.700,.180,.000/),\ (/.700,.260,.000/),(/.700,.285,.000/),(/.680,.330,.000/),\ (/.570,.420,.000/),(/.560,.530,.000/),(/.550,.550,.000/),\ (/.130,.570,.000/),(/.060,.680,.000/),(/.000,.690,.000/),\ (/.000,.700,.100/),(/.000,.600,.300/),(/.000,.500,.500/),\ (/.000,.400,.700/),(/.000,.300,.700/),(/.000,.200,.700/),\ (/.000,.100,.700/),(/.000,.000,.700/),(/.100,.100,.700/),\ (/.200,.200,.700/),(/.300,.300,.700/),(/.420,.400,.700/),\ (/.560,.500,.700/),(/.610,.600,.700/),(/.700,.700,.700/)/) gsn_define_colormap(wks,cmap) ; ; The next set of resources will apply to all four plots. ; resources = True resources@gsnDraw = False ; Don't draw plot or advance the resources@gsnFrame = False ; frame after plot is created. ; ; Loop through four of the timesteps and create each plot. Title each ; plot according to which timestep it is. ; plot = new(nplots,graphic) do i=0,nplots-1 resources@tiMainString = "Temperature at time = " + i plot(i) = gsn_contour(wks,temp(i,:,:),resources) end do gsn_panel(wks,plot(0:3),(/2,2/),False) ; Draw 2 rows/2 columns of plots. ; ; This section will set resources for drawing contour plots ; over a map. ; delete(resources@tiMainString) ; Don't set a main title. resources@sfXArray = lon ; Portion of map on which to overlay resources@sfYArray = lat ; contour plot. resources@cnInfoLabelOn = False ; Turn off info label. resources@cnLineLabelsOn = False ; Turn off contour line labels. resources@cnLinesOn = False ; Turn off contour lines. resources@cnFillOn = True ; Turn on contour fill. resources@cnLevelSelectionMode = "ManualLevels" ; Select contour levels. resources@cnMinLevelValF = 245. resources@cnMaxLevelValF = 302.5 resources@cnLevelSpacingF = 2.5 resources@mpLimitMode = "LatLon" ; Limit portion of map that is viewed. resources@mpMinLatF = min(lat) resources@mpMaxLatF = max(lat) resources@mpMinLonF = min(lon) resources@mpMaxLonF = max(lon) resources@mpPerimOn = True ; Turn on map perimeter. resources@mpGridAndLimbOn = False ; Turn off map grid. do i=0,nplots-1 plot(i) = gsn_contour_map(wks,temp(i,:,:),resources) end do panelres = True panelres@gsnFrame = False ; Don't advance the frame. panelres@gsnPanelBottom = 0.1 ; More white space at bottom for labelbar. ; Default is 0. gsn_panel(wks,plot,(/3,2/),panelres) ; Draw 3 rows and 2 columns of plots. ; ; Draw two titles at the top. ; textres = True textres@txFontHeightF = 0.025 ; Size of title. gsn_text_ndc(wks,":F26:Temperature (K) at every six hours",0.5,.97,textres) textres@txFontHeightF = 0.02 ; Make second title slightly smaller. gsn_text_ndc(wks,":F26:January 1996",0.5,.935,textres) ; ; Retrieve level and colors for use in labelbar. ; getvalues plot@contour "cnLevels" : levels "cnFillColors" : colors end getvalues ; ; Only label every other line in the labelbar. ; lev_labels = new(dimsizes(levels),string) do i = 0,dimsizes(levels)-1,2 lev_labels(i) = levels(i) if(i.lt.dimsizes(levels)-1) lev_labels(i+1) = "" end if end do lbres = True lbres@lbFillColors = colors ; Set the colors to use. lbres@lbLabelAlignment = "InteriorEdges" ; Only label interior lines. lbres@lbLabelFont = "helvetica-bold" ; Change label font. lbres@lbLabelFontHeightF = 0.07 ; Change label font height. lbres@lbMonoFillPattern = True ; Fill each box solid. lbres@lbOrientation = "horizontal" ; Horizontal labelbar. lbres@lbPerimOn = False ; Turn off perimeter. lbres@vpHeightF = 0.2 ; Height of labelbar. lbres@vpWidthF = 0.9 ; Width of labelbar. gsn_labelbar_ndc(wks,dimsizes(colors),lev_labels,0.05,0.2,lbres) frame(wks) ; Advance the frame. end