Problem with labelbar with box around the outer edges

From: Yi Li <fishallen_at_nyahnyahspammersnyahnyah>
Date: Wed Aug 22 2012 - 03:01:29 MDT

Hi all

I am trying to draw a labelbar with box around the outer edges, just like
the example of XXXXX. However, after I changed "data" into model output SST
and "gsn_csm_contour" into "gsn_csm_contour_map_ce", I got the following
information:

-------------------------------------------------------------------------------------------------------------
warning:lbLabelStrings is not a valid resource in map.PlotManager at this
time
warning:NhlGetValues:Error retrieving lbLabelStrings
fatal:["Execute.c":7556]:Execute: Error occurred at or near line 14 in file
temp.ncl

fatal:["Execute.c":7556]:Execute: Error occurred at or near line 120 in
file temp.ncl
--------------------------------------------------------------------------------------------------------------

The NCL code is
-------------------------------------------------------------------------------------------------
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"

; copied from http://www.ncl.ucar.edu/Applications/Scripts/lb_18.ncl
undef("create_labebar_with_box")
procedure create_labelbar_with_box(wks,plot)
local nboxes, colors, labels, lbres, xbox, ybox, vpx, vpy
begin
;---Get colors and labels for the lablbar
  getvalues plot
    "cnFillColors" : colors
    "lbLabelStrings" : labels
  end getvalues

  nboxes = dimsizes(colors)
  lbres = True ; labelbar only resources
  lbres@vpWidthF = 0.6 ; labelbar width
  lbres@vpHeightF = 0.05 ; labelbar height
  lbres@vpYF = 0.2
  lbres@lbFillColors = colors
  lbres@lbMonoFillPattern = True ; Solid fill pattern
; lbres@lbLabelFontHeightF = 0.02 ; font height. default is small
  lbres@lbBoxLinesOn = False
  lbres@lbAutoManage = False
  lbres@lbJustification = "topleft"
  lbres@lbLeftMarginF = 0.0
  lbres@lbTopMarginF = 0.0
  lbres@lbBottomMarginF = 0.0
  lbres@lbRightMarginF = 0.0
  lbres@lbBoxMinorExtentF = 1.0
  lbres@lbLabelAlignment = "InteriorEdges"
  lbres@lbOrientation = "Horizontal"
  lbres@lbPerimOn = False
  lbid = gsn_create_labelbar(wks,nboxes,labels,lbres)
  draw(lbid)

;---Code for drawing a box around the labelbar.
  lnres = True
  lnres@gsLineThicknessF = 3.0
  getvalues lbid
    "vpXF" : vpx
    "vpYF" : vpy
  end getvalues

;
; Use the actual width/height specified for the labelbar above.
; If you use the height and width of the whole labelbar, this
; will include the labelbar labels.

  draw(lbid)
  xbox = (/vpx,vpx+lbres@vpWidthF,vpx+lbres@vpWidthF,vpx,vpx/)
  ybox = (/vpy,vpy,vpy-lbres@vpHeightF,vpy-lbres@vpHeightF,vpy/)
  gsn_polyline_ndc(wks,xbox,ybox,lnres)
end

begin
    filename = "1_NWP_5d_20120716_20130114_grid_T.nc"
    mon0 = "7"
    year = "2012"
    figformat = "eps"
    colortable = "rainbow"
    f_mask = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/landsea.nc", "r")
    path1 = ""
    path2 = ""
        f_in = addfile(path1+path2+filename, "r")
    data = f_in->sosstsst
    sst = data(y|:, x|:, time_counter|1)
    figname = "sst"+year+(mon0+1)
    wks = gsn_open_wks(figformat, figname)
    gsn_define_colormap(wks, colortable)
    res = True
    res@vpYF = 0.9
    res@cnFillOn = True
    res@cnLinesOn = False
    res@gsnDraw = True
    res@gsnFrame = False
    res@gsnSpreadColors = True
    res@cnLevelSelectionMode = "ManualLevels"
    res@cnMinLevelValF = 0
    res@cnMaxLevelValF = 35
    res@cnLevelSpacingF = .5

    res@mpLimitMode = "LatLon"
    res@sfXArray = lon
    res@sfYArray = lat
    res@mpMinLatF = min(lat)
    res@mpMaxLatF = max(lat)
    res@mpMinLonF = min(lon)
    res@mpMaxLonF = max(lon)
    res@gsnAddCyclic = False
    res@mpLandFillColor = "grey"
    res@lbLabelBarOn = False
    res@cnInfoLabelOn = False
    plot = gsn_csm_contour_map_ce(wks, sst, res)
    create_labelbar_with_box(wks, plot)
    frame(wks)
end
-------------------------------------------------------------------------------------------

So, I guess lbLabelStrings is not a property of gsn_csm_contour_map_ce, but
is there a replacement for it, or how could I modify the procedure
create_labelbar_with_box?

Thank you

Allen

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug 22 03:02:58 2012

This archive was generated by hypermail 2.1.8 : Thu Aug 23 2012 - 16:16:15 MDT