undef("set_cn_resources") function set_cn_resources (data[*][*]:numeric, res:logical) begin opts = res ; The ContourParameters resource can either be a scalar that ; represents the contour level spacing, or it can be an array ; of three elements that represent the minimum level, the maximum ; level, and the level spacing. ; mx = max(data) mn = min(data) if(mn.ne.mx.and.opts.and.isatt(opts,"ContourParameters")) then if(dimsizes(opts@ContourParameters) .eq. 1) then ; Only the contour interval is specified. nlev = tointeger((mx-mn)/opts@ContourParameters)+1 levels = nice_mnmxintvl(mn,mx,nlev,True) if(levels(0) .lt. 0.) then ; Set a zero contour. nlev = tointeger(levels(0)/opts@ContourParameters) - 1 levels(0) = nlev*opts@ContourParameters end if nlev = tointeger((levels(1)-levels(0))/opts@ContourParameters)+1 levels(1) = levels(0) + nlev*opts@ContourParameters levels(2) = opts@ContourParameters ; Min level, max level, and level spacing are specified by user. else if(dimsizes(opts@ContourParameters) .eq. 3) then levels = opts@ContourParameters else print("wrf_contour: Warning: illegal setting for ContourParameters attribute") end if end if end if ; Contour levels if(isvar("levels")) then opts@cnLevelSelectionMode = get_res_value_keep(opts, "cnLevelSelectionMode", "ManualLevels") opts@cnMinLevelValF = get_res_value_keep(opts, "cnMinLevelValF", levels(0)) opts@cnMaxLevelValF = get_res_value_keep(opts, "cnMaxLevelValF", levels(1)) opts@cnLevelSpacingF = get_res_value_keep(opts, "cnLevelSpacingF",levels(2)) delete(levels) end if ; Set the default zero line thickness to 2, and the negative contour ; line dash pattern to 1 (0 is solid). opts@gsnContourZeroLineThicknessF = get_res_value_keep(opts, "gsnContourZeroLineThicknessF",2.0) opts@gsnContourNegLineDashPattern = get_res_value_keep(opts, "gsnContourNegLineDashPattern",1) ; Set resources that apply for both filled and line contour plots. opts@cnFillDrawOrder = get_res_value_keep(opts,"cnFillDrawOrder", "PreDraw") opts@cnLineLabelAngleF = get_res_value_keep(opts,"cnLineLabelAngleF", 0.0) opts@cnLineLabelFontHeightF = get_res_value_keep(opts,"cnLineLabelFontHeightF", 0.015) opts@cnInfoLabelFontHeightF = get_res_value_keep(opts,"cnInfoLabelFontHeightF", 0.015) opts@cnLineLabelPerimOn = get_res_value_keep(opts,"cnLineLabelPerimOn", True) opts@cnInfoLabelPerimOn = get_res_value_keep(opts,"cnInfoLabelPerimOn", False) opts@cnLineLabelBackgroundColor = get_res_value_keep(opts,"cnLineLabelBackgroundColor", -1) opts@cnHighLabelBackgroundColor = get_res_value_keep(opts,"cnHighLabelBackgroundColor", -1) opts@cnLowLabelBackgroundColor = get_res_value_keep(opts,"cnLowLabelBackgroundColor", -1) opts@cnLineColor = get_res_value_keep(opts,"cnLineColor", "Black") opts@cnLineLabelFontColor = get_res_value_keep(opts,"cnLineLabelFontColor",opts@cnLineColor) opts@cnLineLabelPerimColor = get_res_value_keep(opts,"cnLineLabelPerimColor",opts@cnLineColor) opts@cnInfoLabelFontColor = get_res_value_keep(opts,"cnInfoLabelFontColor",opts@cnLineColor) opts@cnHighLabelFontColor = get_res_value_keep(opts,"cnHighLabelFontColor",opts@cnLineColor) opts@cnLowLabelFontColor = get_res_value_keep(opts,"cnLowLabelFontColor",opts@cnLineColor) ; Set field Title and levels if available if(.not.isatt(opts,"cnInfoLabelString")) then info_string = " Contours: $CMN$ to $CMX$ by $CIU$" if(isatt(opts,"FieldTitle")) then opts@cnInfoLabelString = opts@FieldTitle + info_string else if(isatt(data,"description")) then opts@cnInfoLabelString = data@description + info_string else opts@cnInfoLabelString = info_string end if end if end if return(opts) end