load "hsv2rgb.ncl" begin ; ; Open NetCDF file containing Geo-Potential height forecast ; information. ; filedir = ncargpath("data") filename = filedir + "/cdf/contour.cdf" cfile = addfile(filename,"r") ; ; Set the color map. ; ncolors = 13 hue = fspan(0.,300.,ncolors) ; Set hue range. sat = fspan(1.0,1.0,ncolors) ; Set saturation range. val = fspan(0.8,0.8,ncolors) ; Set value range. cmap = new((/ncolors+2,3/),float) ; Define (ncolors+2) x 3 float ; array to hold the color map. cmap(0,:) = (/1.,1.,1./) ; Set the background to white. cmap(1,:) = (/0.,0.,0./) ; Set the foreground to black. cmap(2:ncolors+1,:) = hsv2rgb(hue,sat,val) ; Generate smooth range of ; RGB values. ; ; Create an X workstation. ; wid = create "wks" xWorkstationClass defaultapp "wkColorMap" : cmap end create field = create "field" scalarFieldClass defaultapp "sfDataArray" : cfile->Z(0,3,:,:) "sfMissingValueV" : cfile->Z@_FillValue ; Set missing value. end create xpos = (/0.12, 0.57, 0.12, 0.57/) ; X and Y positions of ypos = (/0.95, 0.95, 0.53, 0.53/) ; the four contour plots. ; ; Create a contour object. ; cnid = create "contour" contourPlotClass wid "vpWidthF" : 0.35 "vpHeightF" : 0.35 "vpXF" : xpos(0) "vpYF" : ypos(0) "cnScalarFieldData" : field "cnLevelSelectionMode" : "ManualLevels" ; Manually select our "cnMinLevelValF" : 5400.0 ; own contour levels by "cnMaxLevelValF" : 5950.0 ; specifying min, max, "cnLevelSpacingF" : 50.0 ; and spacing. "cnFillOn" : True ; Turn on fill. "cnLineLabelsOn" : False ; Turn off line labels. "cnInfoLabelOn" : False ; Turn off info label. "cnLowLabelsOn" : False ; Turn off low label. "cnHighLabelsOn" : False ; Turn off high label. end create draw(cnid) ; Draw contour plot. ; ; Loop through three more time steps and create and draw ; contour plots at each one. ; do i=1,3 setvalues field "sfDataArray" : cfile->Z(i,3,:,:) ; Select new time step. end setvalues setvalues cnid "vpXF" : xpos(i) ; Change X and Y positions "vpYF" : ypos(i) ; of the new contour plot. end setvalues draw(cnid) ; Draw the new contour plot. end do ; ; Retrieve the contour levels and the colors used for filling the ; contours so we can use this information in a labelbar. ; getvalues cnid "cnLevels" : levels "cnFillColors" : colors end getvalues ; ; Create a labelbar. ; lbid = create "labelbar" labelBarClass wid "vpXF" : 0.25 ; Specify position of labelbar "vpYF" : 0.13 ; in the viewport. "vpWidthF" : 0.50 "vpHeightF" : 0.10 "lbPerimOn" : False ; Turn off perimeter. "lbBoxCount" : dimsizes(levels)+1 ; # of labelbar boxes. "lbOrientation" : "Horizontal" ; Default is vertical. "lbLabelAlignment" : "InteriorEdges" ; Default is "BoxCenters". "lbLabelStrings" : levels ; Labels for boxes. "lbFillColors" : colors ; Colors for boxes. "lbMonoFillPattern" : True ; Fill them all solid. end create draw(lbid) ; Draw the labelbar. frame(wid) ; Advance the frame. end