; ; The following lines make sure that, if these function names are in ; use, then they'll be removed. ; ; Next to each call to undef is a description of the function or ; procedure ; undef("settitles") ; sets titles of plots undef("fcontour") ; creates a filled contour plot undef("fvector") ; creates a plot with filled vectors undef("xyplot") ; creates an xyplot undef("stream") ; creates a streamline plot undef("map") ; creates a map plot undef("SetUp1d") ; sets up 1D data for the xyplot object undef("SetUp2d") ; sets up 2D data for the contour plot undef("SetUpV2d") ; sets up 2D data for the vector plot undef("HandleResourceAtts") ; sets resources based on attributes ; of input variable undef("setaspect") ; sets the aspect ratio of plots undef("Spread") ; spreads color indexes evenly undef("open_cgm") ; opens a new cgm workstation undef("open_X11") ; opens a new X11 workstation undef("open_PS") ; opens a new Postscript workstation undef("load_default_db") ; loads a default resource file undef("getdataspec") ; retrieve data specific object from ; xyplot undef("setsize") ; sets size information undef("change_contour_data") ; changes existing data for contour undef("replace_contour_data") ; replaces existing data for contour undef("change_vector_data") ; changes existing data for vector undef("replace_vector_data") ; replaces existing data for a vector undef("change_stream_data") ; changes streamline data undef("replace_stream_data") ; replaces streamline data undef("replace_xyplot_data") ; replaces xyplot data undef("add_xyplot_data") ; adds additional data to xyplots ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure: setsize ; plot : any number of plots ; x : x NDC value to set ; y : y NDC value to set ; width : width NDC value to set ; height : height NDC value to set ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure setsize(plot[*]:graphic,x[1]:float,y[1]:float,width[1]:float,height[1]:float) begin setvalues plot "vpXF" : x "vpYF" : y "vpWidthF" : width "vpHeightF" : height end setvalues end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure: setaspect ; plot : any number of plot ; ratio : ratio of height/width to set plot ; ; Sets the aspect ratio of a plot. The plot will be inscribed in its former ; bounding box ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure setaspect(plot[1]:graphic,ratio[1]:numeric) begin getvalues plot "vpXF" : vpx "vpYF" : vpy "vpWidthF" : vpw "vpHeightF" : vph end getvalues if(ratio .gt. 1) setvalues plot "vpXF" : vpx + (vpw / ratio)/2.0 "vpYF" : vpy "vpWidthF" : vpw / ratio "vpHeightF" : vph end setvalues else setvalues plot "vpXF" : vpx "vpYF" : vpy - (vph*ratio)/2.0 "vpWidthF" : vpw "vpHeightF" : vph * ratio end setvalues end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function: load_default_db ; name : string name of the application ; ; this procedure essentially loads the file "./.res" ; this file contains resource value pairs to be used when ; any HLU object is created. it is not necessary to call ; this function but it can be useful for customizing ; scripts ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function load_default_db(name[1]:string) begin demo = create name appClass defaultapp "appUsrDir" : "./" "appDefaultParent" : True end create return(demo) end ; ; Function : open_cgm ; name : name of output cgm file ; ; this function opens an NCGM output file called ".ncgm" ; function open_cgm(name[1]:string, filename[1]:string) begin cgm = create name ncgmWorkstationClass defaultapp "wkMetaName" : filename + ".ncgm" end create return(cgm) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function : open_X11 ; ; this function opens an X11 output window ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function open_X11(name[1]:string) begin window = create name xWorkstationClass defaultapp "wkPause" : False end create return(window) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function : open_PS ; name : post script file name ; ; this function open a postscript file named ".ps" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function open_PS(name[1]:string,filename[1]:string) begin cgm = create name psWorkstationClass defaultapp "wkPSName" : filename + ".ps" end create return(cgm) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure HandleResourceAtts ; pl: a single plot ; data: a variable containing only attributes whose names are ; resources ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure HandleResourceAtts(pl[1]:graphic,data) begin attnames = getvaratts(data) ; ; getvaratts returns a missing value if there are no attributes ; so the following makes sure there are attributes ; if(.not.all(ismissing(attnames))) ; ; makes sure that "_FillValue" isn't set as a resource ; res = attnames(ind(attnames.ne."_FillValue")) do i = 0,dimsizes(res) -1 setvalues pl res(i) : data@$res(i)$ end setvalues end do end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Function map ; opt: a logical variable if true all the attributes of this variable ; are assumed to be resoures for the contour ; ; Creates and returns a map plot object ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function map(opt[1]:logical,wk[1]:graphic,mapname[1]:string) local mp begin mp = create mapname mapPlotClass wk "vpUseSegments" : True end create ; ; If opt is true its attributes need to be set ; to resources of the contour plot. HandleResourceAtts ; does this ; if(opt) HandleResourceAtts(mp,opt) end if return(mp) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Procedure: settitles ; pl : plot whose titles will be modified ; data : data variable used in plot ; ; This procedure sets the main title to the variable's "long_name" attribute, ; the y-axis title to the "long_name" attribute of the 0th dimension's ; coordinate variable and the x-axis title to the "long_name" attribute of the ; 1st dimensions coordinate variable. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure settitles(pl:graphic,data[*][*]) begin ; ; check to see if long_name is an attribute then turn on the main title ; with the "tiMainOn" resource and assign the long_name attribute to the ; "tiMainString" resource. if long_name doesn't exit then turn off the main ; title. ; if(isatt(data,"long_name")) setvalues pl "tiMainString" : data@long_name "tiMainOn" : True end setvalues else setvalues pl "tiMainOn" : False end setvalues end if ; ; similar to the turning on the main title string except that here the ; long_name attribute is in the 0th dimension's coordinate variable ; dim!0 returns the string name of the 0th dimension ; data&$dim!0$ references the coordinate variable, if it exists ; if(.not.ismissing(data!0).and.isatt(data&$data!0$,"long_name")) setvalues pl "tiYAxisString" : data&$data!0$@long_name "tiYAxisOn" : True end setvalues else setvalues pl "tiYAxisOn" : False end setvalues end if ; ; same thing for x-axis ; if(.not.ismissing(data!1).and.isatt(data&$data!1$,"long_name")) setvalues pl "tiXAxisString" : data&$data!1$@long_name "tiXAxisOn" : True end setvalues else setvalues pl "tiYAxisOn" : False end setvalues end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Function SetUp2D ; data: a two dimensional scalar field ; ; This function sets up a scalarFieldData object and returns it. It sets any ; missing value information as well as coordinate information ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function SetUp2d(data[*][*]:numeric) begin ; ; create a scalar field description and assign the data array ; if(.not.isatt(data,"sf")) then sf = create "sf" scalarFieldClass defaultapp "sfDataArray" : data end create else sf = data@sf setvalues sf "sfDataArray" : data end setvalues end if ; ; check if dimension 0 has a coordinate variable and if so set the ; array to be the Y coordinate array for the fcontour plot ; if(iscoord(data,data!0)) setvalues sf "sfYArray" : data&$(data!0)$ end setvalues end if ; ; check if dimension 1 has a coordinate variable and if so set the ; array to be the X coordinate array for the contour plot ; if(iscoord(data,data!1)) setvalues sf "sfXArray" : data&$(data!1)$ end setvalues end if ; ; check for missing values at set the scalar field missing value ; resource ; if(isatt(data,"_FillValue")) setvalues sf "sfMissingValueV" : data@_FillValue end setvalues end if return(sf) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure Sprea ; pl: a single plot ; clen: length of color map ; ncols: number of color indexes to generate ; res: resource name to set ; ; Computes a set of indexes into the color map that are evenly spread out ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure Spread(pl[1]:graphic,clen[1]:integer,ncols[1]:integer,res[1]:string) begin if(clen.ge.ncols) cspacing = clen/ ncols setvalues pl res : ispan(1,ncols*cspacing,cspacing) end setvalues else setvalues pl res : ispan(1,ncols,1) % clen end setvalues end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure replace_contour_data ; plot : a single contour plot whose data are to be replaced ; data : the two dimensional scalar field to set ; ; This function only replaces a contour plot's data. It does not reset coordinate ; or missing value information. Use change_contour_data for this ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure replace_contour_data(plot[1]:graphic,data[*][*]) begin if(NhlClassName(plot).eq."contourPlotClass") getvalues plot "cnScalarFieldData" : sf end getvalues setvalues sf "sfDataArray" : data end setvalues end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure change_contour_data ; plot : a single contour plot whose data are to be replaced ; data : the two dimensional scalar field to set ; ; This procedure creates a new scalarField object for the input contour plot ; and resets the titles. This procedure should be called instead of ; replace_contour_data, when the new data have different units or exists on ; a different grid ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure change_contour_data(plot[1]:graphic,data[*][*]) begin if(NhlClassName(plot).eq."contourPlotClass") getvalues plot "cnScalarFieldData" : sf end getvalues data@sf = sf sf = SetUp2d(data) delete(data@sf) settitles(plot,data) end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function : fcontour ; opt: a logical variable if true all the attributes of this variable ; are assumed to be resoures for the contour ; wk : workstation to draw to ; data : 2D data to plot ; ; this function creates a filled contour plot. if the input data have ; coordinate variables this function sets both contour axis to the appropriate ; coordinate array. doing this assures that irregularly spaced rectilinear ; grids can be drawn and tick marked correctly. this function also checks ; to see if the input data have a "_FillValue" resource so that missing ; values will not be drawn in the contour plot. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function fcontour(opt[1]:logical,wk[1]:graphic,data[*][*]:numeric) local sf,cn begin wid = new(1,float) hid = new(1,float) sf = SetUp2d(data) ; ; create the contour plot and turn fill on and turn on the ; label bar ; if(isatt(data,"long_name")) cn = create data@long_name contourPlotClass wk "cnScalarFieldData" : sf "cnFillOn" : True "pmLabelBarDisplayMode" : "ALWAYS" "vpUseSegments" : True end create else cn = create "cn" contourPlotClass wk "cnScalarFieldData" : sf "cnFillOn" : True "pmLabelBarDisplayMode" : "ALWAYS" "vpUseSegments" : True end create end if ; set up the titles ; settitles(cn,data) ; ; set the title of the label bar to the units attribute of data ; if(isatt(data,"units")) setvalues cn "lbTitleString" : data@units "lbTitleOn" : True end setvalues end if ; ; Compute aspect ratio and call procedure setaspect ; dims = dimsizes(data) hid = dims(0) wid = dims(1) ratio = hid/wid setaspect(cn,ratio) getvalues cn "vpWidthF" : vpw "vpHeightF" : vph end getvalues ; ; Given the aspect ratio determine which side the ; label bar should go on ; if(ratio .gt. 1) setvalues cn "pmLabelBarSide" : "RIGHT" "pmLabelBarHeightF" : vph "pmLabelBarWidthF" : vph/5.0 "lbOrientation" : "VERTICAL" end setvalues else setvalues cn "pmLabelBarSide" : "BOTTOM" "lbOrientation" : "HORIZONTAL" "pmLabelBarHeightF" : vpw/5.0 "pmLabelBarWidthF" : vpw end setvalues end if ; ; Get color map length ; getvalues wk "wkColorMapLen" : len end getvalues ; ; Get number of contour levels ; getvalues cn "cnLevels" : levs end getvalues ; ; Spread computes evenly space color indexes ; Spread(cn,len,dimsizes(levs)+1,"cnFillColors") ; ; If opt is true its attributes need to be set ; to resources of the contour plot. HandleResourceAtts ; does this ; if(opt) HandleResourceAtts(cn,opt) end if return(cn) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Function SetUp1d ; xdata : either a one or two dimensional array ; ydata : either a one or two dimensional array ; ; This function sets up a coordArraysClass object which is used by the xyPlotClass ; as input data. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function SetUp1d(xdata:numeric,ydata:numeric) begin xdims = dimsizes(xdata) ydims = dimsizes(ydata) if(isatt(ydata,"long_name")) if(.not.isatt(xdata,"ca")) ca = create ydata@long_name coordArraysClass defaultapp "caXArray" : xdata "caYArray" : ydata end create else ca = xdata@ca setvalues ca "caXArray" : xdata "caYArray" : ydata end setvalues end if else if(.not.isatt(xdata,"ca")) ca = create "ca" coordArraysClass defaultapp "caXArray" : xdata "caYArray" : ydata end create else ca = xdata@ca setvalues ca "caXArray" : xdata "caYArray" : ydata end setvalues end if end if if(isatt(xdata,"_FillValue")) setvalues ca "caXMissingV" : xdata@_FillValue end setvalues end if if(isatt(ydata,"_FillValue")) setvalues ca "caYMissingV" : ydata@_FillValue end setvalues end if return(ca) end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Function getdataspec ; xy : a single xyPlot object ; ; This function returns the data specific object from an xyplot. if the input ; is not an xyplot then it returns a missing value ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function getdataspec(xy[1]:graphic) local dsp begin if(NhlClassName(xy).eq."xyPlotClass") getvalues xy "xyCoordDataSpec" : dsp end getvalues return(dsp) else return(new(1,graphic)) end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure replace_xyplot_data ; plot : xyPlot whose data are to be replaced ; xdata : a one or two dimensional numeric array ; ydata : a one or two dimensional numeric array ; ; This procedure replaces the existing data of an xyplot. change_xyplot_data ; should be used if titles units information have changed ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure replace_xyplot_data(plot[1]:graphic,xdata:numeric,ydata:numeric) begin if(NhlClassName(plot).eq."xyplotPlotClass") getvalues plot "xyCoordData" : ca end getvalues setvalues ca(0) "caXArray" : xdata "caYArray" : ydata end setvalues end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure add_xyplot_data ; plot : xyplot to which data are to be added ; xdata : a one or two dimensional data array ; ydata : a one or two dimensional data array ; ; Allows you to add additional data to xyPlots after they've be created. This ; does not delete data that the plot is already drawing. This adds more data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure add_xyplot_data(plot[1]:graphic,xdata:numeric,ydata:numeric) begin if(NhlClassName(plot).eq."xyplotPlotClass") ds = NhlAddData(plot,"xyCoordData",SetUp1d(xdata,ydata)) end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Procedure change_xyplot_data ; plot : xyplot to which data are assigned ; xdata : new x data for plot ; ydata : new y data for plot ; ; This procedure changes previously set data for an xyplot ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; procedure change_xyplot_data(plot[1]:graphic,xdata[*][*],ydata[*][*]) begin if(NhlClassName(plot).eq."xyplotPlotClass") getvalues plot "xyCoordData" : ca end getvalues xdata@ca = ca ca = SetUp1d(xdata,ydata) delete(xdata@ca) end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function : xyplot ; opt: a logical variable if true all the attributes of this variable ; are assumed to be resoures for the xyplot ; wk : workstation to draw to ; xdata :1 or 2D data to plot ; ydata :1 or 2D data to plot ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function xyplot(opt[1]:logical,wk[1]:graphic,xdata:numeric, ydata:numeric) begin dims = dimsizes(xdata) ca = SetUp1d(xdata,ydata) ; ; create the xyplot plot and turn fill on ; if(isatt(ydata,"long_name")) xy = create ydata@long_name xyPlotClass wk "vpUseSegments" : True "xyCoordData" : ca end create else xy = create "xy" xyPlotClass wk "vpUseSegments" : True "xyCoordData" : ca end create end if ; ; Set titles X Axis ; if(isatt(xdata,"units")) setvalues xy "tiXAxisString" : xdata@units "tiXAxisOn" : True end setvalues else if(isatt(xdata,"long_name")) setvalues xy "tiXAxisString" : xdata@long_name "tiXAxisOn" : True end setvalues end if end if ; ; Set titles Y Axis ; if(isatt(ydata,"units")) setvalues xy "tiYAxisString" : ydata@units "tiYAxisOn" : True end setvalues else if(isatt(ydata,"long_name")) setvalues xy "tiYAxisString" : ydata@long_name "tiYAxisOn" : True end setvalues end if end if getvalues xy "xyCoordDataSpec" : dsp end getvalues getvalues wk "wkColorMapLen" : len end getvalues ; ; assign spread out color maps to all color resources ; of the xyDataSpec object ; if(dimsizes(dims).eq.2) then Spread(dsp,len,dims(0),"xyLineColors") Spread(dsp,len,dims(0),"xyMarkerColors") Spread(dsp,len,dims(0),"xyLineLabelFontColors") Spread(dsp,16,dims(0),"xyMarkers") Spread(dsp,16,dims(0),"xyDashPatterns") end if ; ; If opt is true its attributes need to be set ; to resources of the contour plot. HandleResourceAtts ; does this ; if(opt) HandleResourceAtts(dsp,opt) end if return(xy) end function SetUpV2d(udata:numeric,vdata:numeric) begin if(isatt(udata,"long_name")) if(.not.isatt(udata,"vf")) vf = create udata@long_name vectorFieldClass defaultapp "vfUDataArray" : udata "vfVDataArray" : vdata end create else vf = udata@vf setvalues vf "vfUDataArray" : udata "vfVDataArray" : vdata end setvalues end if if(isatt(udata,"_FillValue")) setvalues vf "vfMissingUValueV": udata@_FillValue end setvalues end if if(isatt(vdata,"_FillValue")) setvalues vf "vfMissingVValueV": vdata@_FillValue end setvalues end if else if(.not.isatt(udata,"vf")) vf = create "vf" vectorFieldClass defaultapp "vfUDataArray" : udata "vfVDataArray" : vdata end create else vf = udata@vf setvalues vf "vfUDataArray" : udata "vfVDataArray" : vdata end setvalues end if if(isatt(udata,"_FillValue")) setvalues vf "vfMissingUValueV": udata@_FillValue end setvalues end if if(isatt(vdata,"_FillValue")) setvalues vf "vfMissingVValueV": vdata@_FillValue end setvalues end if end if if(iscoord(udata,udata!0)) setvalues vf "vfYArray" : udata&$(udata!0)$ end setvalues end if if(iscoord(udata,udata!1)) setvalues vf "vfXArray" : udata&$(udata!1)$ end setvalues end if return(vf) end procedure replace_vector_data(plot[1]:graphic,udata[*][*],vdata[*][*]) begin if(NhlClassName(plot).eq."vectorPlotClass") getvalues plot "vcVectorFieldData" : vf end getvalues setvalues vf "vfUDataArray" : udata "vfVDataArray" : vdata end setvalues end if end procedure change_vector_data(plot[1]:graphic,udata[*][*],vdata[*][*]) begin if(NhlClassName(plot).eq."vectorPlotClass") getvalues plot "vcVectorFieldData" : vf end getvalues udata@vf = vf vf = SetUpV2d(udata,vdata) delete(udata@vf) end if end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function : fvector ; opt: a logical variable if true all the attributes of this variable ; are assumed to be resoures for the xyplot ; wk : workstation to draw to ; data : 2D data to plot ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; function fvector(opt[1]:logical,wk[1]:graphic,udata[*][*]:numeric,vdata[*][*]) local sf,vc begin wid = new(1,float) hid = new(1,float) dims = dimsizes(udata) hid = dims(0) wid = dims(1) ratio = hid/wid sf = SetUpV2d(udata,vdata) ; ; create the vector plot and turn fill on ; if(isatt(udata,"long_name")) vc = create udata@long_name vectorPlotClass wk "vpUseSegments" : True "vcVectorFieldData" : sf "vcFillArrowsOn" : True "vcMonoFillArrowFillColor" : False "pmLabelBarDisplayMode" : "ALWAYS" "vcFillArrowsOn" : True end create else vc = create "vc" vectorPlotClass wk "vpUseSegments" : True "vcVectorFieldData" : sf "vcMonoFillArrowFillColor" : False "vcFillArrowsOn" : True "pmLabelBarDisplayMode" : "ALWAYS" end create end if getvalues vc "vpXF" : vpx "vpYF" : vpy "vpWidthF" : vpw "vpHeightF" : vph end getvalues settitles(vc,udata) if(isatt(udata,"units")) setvalues vc "lbTitleString" : udata@units "lbTitleOn" : True end setvalues end if setaspect(vc,ratio) getvalues vc "vpWidthF" : vpw end getvalues setvalues vc "vcRefLengthF" : vpw/25.0 "vcMinDistanceF" : .005 end setvalues if(ratio .gt. 1) setvalues vc "pmLabelBarSide" : "RIGHT" "pmLabelBarHeightF" : vph "pmLabelBarWidthF" : vph/5.0 "lbOrientation" : "VERTICAL" end setvalues else setvalues vc "pmLabelBarSide" : "BOTTOM" "lbOrientation" : "HORIZONTAL" "pmLabelBarHeightF" : vpw/5.0 "pmLabelBarWidthF" : vpw end setvalues end if getvalues wk "wkColorMapLen" : len end getvalues getvalues vc "vcLevels" : levs end getvalues Spread(vc,len,dimsizes(levs)+1,"vcLevelColors") if(opt) HandleResourceAtts(vc,opt) end if return(vc) end procedure replace_stream_data(plot[1]:graphic,udata[*][*],vdata[*][*]) begin if(NhlClassName(plot).eq."streamlinePlotClass") getvalues plot "stVectorFieldData" : vf end getvalues setvalues vf "vfUDataArray" : udata "vfVDataArray" : vdata end setvalues end if end procedure change_stream_data(plot[1]:graphic,udata[*][*],vdata[*][*]) begin if(NhlClassName(plot).eq."streamlinePlotClass") getvalues plot "vcVectorFieldData" : vf end getvalues udata@vf = vf vf = SetUpV2d(udata,vdata) delete(udata@vf) end if end function stream(opt[1]:logical,wk[1]:graphic,udata[*][*]:numeric,vdata[*][*]) local sf,vc begin wid = new(1,float) hid = new(1,float) dims = dimsizes(udata) hid = dims(0) wid = dims(1) ratio = hid/wid sf = SetUpV2d(udata,vdata) ; ; create the vector plot and turn fill on ; if(isatt(udata,"long_name")) st = create udata@long_name streamlinePlotClass wk "vpUseSegments" : True "stVectorFieldData" : sf end create else st = create "st" streamlinePlotClass wk "vpUseSegments" : True "stVectorFieldData" : sf end create end if getvalues st "vpXF" : vpx "vpYF" : vpy "vpWidthF" : vpw "vpHeightF" : vph end getvalues settitles(st,udata) setaspect(st,ratio) if(opt) HandleResourceAtts(st,opt) end if return(st) end