;***********************************************************************; ; Function : gsn_csm_pres_hgt_vector ; ; wks: workstation object ; ; data: data to be contoured ; ; u: u component of vectors ; ; v: u component of vectors ; ; resources: optional resources ; ; ; ; This function behaves like gsn_csm_pres_hgt, only it overlays a ; ; vector plot as well. ; ; ; ; As of NCL V6.2.0, vcMapDirection is set to False by default. ; ; It was discussed that this is the only vector plotting script that ; ; should really have the default changed. ; ;***********************************************************************; undef("gsn_csm_pres_hgt_vector") function gsn_csm_pres_hgt_vector(wks:graphic,data[*][*]:numeric, \ u[*][*]:numeric, v[*][*]:numeric, \ resources:logical) local res2, cnres, vcres, calldraw, callframe, npres, lbar_zone, anno_zone begin res2 = get_resources(resources) ; ; Write data and plot resource information to a file so we can ; reconstruct plot if desired, without all the computational ; code beforehand. ; if(isatt(res2,"gsnDebugWriteFileName")) then gsnp_write_debug_info(data,u,v,"gsn_csm_pres_hgt_vector",res2,3) end if calldraw = get_res_value(res2,"gsnDraw", True) callframe = get_res_value(res2,"gsnFrame",True) maxbb = get_bb_res(res2) anno_zone = get_res_value(res2,"vcRefAnnoZone",3) ypos = get_res_value(res2,"vpYF",0.87) info_para = get_res_value(res2,"cnInfoLabelParallelPosF",0.) info_just = get_res_value(res2,"cnInfoLabelJust","TopLeft") refanno_on= get_res_value_keep(res2,"vcRefAnnoOn",True) map_dir = get_res_value_keep(res2,"vcMapDirection",False) if(refanno_on) lbar_zone = get_res_value(res2,"pmLabelBarZone",4) lbar_orth = get_res_value(res2,"pmLabelBarOrthogonalPosF",0.05) else lbar_zone = get_res_value(res2,"pmLabelBarZone",3) lbar_orth = get_res_value(res2,"pmLabelBarOrthogonalPosF",0.0) end if cnres = get_res_ne(res2,(/"vc","vf"/)) vcres = get_res_eq(res2,(/"vc","vf","tr"/)) ; ; Set some contour resources. ; cnres = True cnres@gsnDraw = False cnres@gsnFrame = False cnres@vpYF = ypos cnres@cnInfoLabelParallelPosF = info_para ; Change locations of info cnres@cnInfoLabelJust = info_just ; label and label bar so cnres@pmLabelBarZone = lbar_zone ; they don't run into vector cnres@pmLabelBarOrthogonalPosF = lbar_orth ; reference anno. ; ; Create contour pressure/height plot. ; contour = gsn_csm_pres_hgt(wks,data,cnres) ; ; Set some vector resources. ; vcres = True vcres@vcRefAnnoZone = anno_zone ; change zones so ref anno and ; labelbar don't run into each other vcres@gsnDraw = False vcres@gsnFrame = False vcres@gsnRightString = "" ; Use gsnRightString and gsnLeftString vcres@gsnLeftString = "" ; from contour plot. vcres@vcMapDirection = map_dir ;---If pressure values are Pascals, convert them to millibars. if(is_valid_coord(u,"y").and.isatt(u&$u!0$,"units").and.\ any(u&$u!0$@units.eq.get_allowed_pres_units_pa())) set_attr(vcres,"vfYArray",tofloat_wunits(u&$u!0$) * 0.01) end if ;---If pressure values are not in descending order, reverse them. if(is_valid_coord(u,"y")) then npres = dimsizes(u&$u!0$) if(u&$u!0$(0).lt.u&$u!0$(npres-1)) vector = gsn_csm_vector(wks,u(::-1,:),v(::-1,:),vcres) else vector = gsn_csm_vector(wks,u,v,vcres) end if else vector = gsn_csm_vector(wks,u,v,vcres) end if ; ; Overlay the vectors on the contour plot. ; overlay(contour,vector) ; Draw all this stuff: vector over contour plot. draw_and_frame(wks,contour,calldraw,callframe,0,maxbb) ; Return contour/vector plot with data objects as attributes. contour@sfdata = contour@data contour@vcdata = vector@data return(contour) end