def prepPrimitive(prim): if prim.x is None or prim.y is None: return 0 if not isinstance(prim.x[0], (list, tuple)): prim.x = [ prim.x, ] if not isinstance(prim.y[0], (list, tuple)): prim.y = [ prim.y, ] if vcs.isfillarea(prim): atts = ["x", "y", "color", "style", "index"] elif vcs.ismarker(prim): atts = ["x", "y", "color", "size", "type"] elif vcs.isline(prim): atts = ["x", "y", "color", "width", "type"] n = 0 for a in atts: n = max(n, len(getattr(prim, a))) for a in atts: v = getattr(prim, a) while len(v) < n: v.append(v[-1]) setattr(prim, a, v) return n
def prepPrimitive(prim): if prim.x is None or prim.y is None: return 0 if not isinstance(prim.x[0],(list,tuple)): prim.x = [prim.x,] if not isinstance(prim.y[0],(list,tuple)): prim.y = [prim.y,] if vcs.isfillarea(prim): atts = ["x","y","color","style","index"] elif vcs.ismarker(prim): atts = ["x","y","color","size","type"] elif vcs.isline(prim): atts = ["x","y","color","width","type"] n=0 for a in atts: n = max(n,len(getattr(prim,a))) for a in atts: v = getattr(prim,a) while len(v)<n: v.append(v[-1]) setattr(prim,a,v) return n
def test(): import vcs, cdms2 as cdms, time, os, sys, support # import vcs and cu bg = support.bg f = cdms.open( os.path.join(cdms.__path__[0], '..', '..', '..', '..', 'sample_data', 'clt.nc')) # open clt file u = f('u') # get slab u v = f('v') # get slab v x = vcs.init() # construct vcs canvas a = x.createxvsy('quick') # create 'quick' xvsy if not vcs.isgraphicsmethod(a): # test object 'a' for graphics method raise Exception, "Error did not retrieve the gm" else: if not vcs.isxvsy(a): # test object 'a' if xvsy raise Exception, "Error gm is not right type" x.plot(u, v, 'default', 'xvsy', 'quick', bg=bg) # plot slabs the old way support.check_plot(x) if bg == 0: x.geometry(450, 337, 100, 0) # change the geometry and location x.flush() support.check_plot(x) a.script('test', 'w') # save 'quick' xvsy as a Python script a.xticlabels('', '') # remove the x-axis support.check_plot(x) a.xticlabels('*') # put the x-axis support.check_plot(x) ############################################################################ # Change the xvsy line # ############################################################################ a.line = 0 # same as 'solid' support.check_plot(x) a.line = 1 # same as 'dash' support.check_plot(x) a.line = 2 # same as 'dot' support.check_plot(x) a.line = 3 # same as 'dash-dot' support.check_plot(x) a.line = 4 # same as 'long-dash' support.check_plot(x) if not '--extended' in sys.argv: print '\n************* PARTIAL TEST *****************' print 'FOR COMPLETE TEST OF THIS MODULE USE ' print ' -F (--full) or -E (--extended) option' print '************* PARTIAL TEST *****************\n' sys.exit() ############################################################################ # Change the xvsy line color # ############################################################################ a.linecolor = (77) support.check_plot(x) a.linecolor = 16 support.check_plot(x) a.linecolor = 44 # same as a.color=(44) support.check_plot(x) a.linecolor = None support.check_plot(x) ############################################################################ # Change the xvsy marker # ############################################################################ a.marker = 1 # Same as a.marker='dot' support.check_plot(x) a.marker = 2 # Same as a.marker='plus' support.check_plot(x) a.marker = 3 # Same as a.marker='star' support.check_plot(x) a.marker = 4 # Same as a.marker='circle' support.check_plot(x) a.marker = 5 # Same as a.marker='cross' support.check_plot(x) a.marker = 6 # Same as a.marker='diamond' support.check_plot(x) a.marker = 7 # Same as a.marker='triangle_up' support.check_plot(x) a.marker = 8 # Same as a.marker='triangle_down' support.check_plot(x) a.marker = 9 # Same as a.marker='triangle_left' support.check_plot(x) a.marker = 10 # Same as a.marker='triangle_right' support.check_plot(x) a.marker = 11 # Same as a.marker='square' support.check_plot(x) a.marker = 12 # Same as a.marker='diamond_fill' support.check_plot(x) a.marker = 13 # Same as a.marker='triangle_up_fill' support.check_plot(x) a.marker = 14 # Same as a.marker='triangle_down_fill' support.check_plot(x) a.marker = 15 # Same as a.marker='triangle_left_fill' support.check_plot(x) a.marker = 16 # Same as a.marker='triangle_right_fill' support.check_plot(x) a.marker = 17 # Same as a.marker='square_fill' support.check_plot(x) a.marker = None # Draw no markers support.check_plot(x) ############################################################################ # Change the xvsy marker color # ############################################################################ a.marker = 'dot' support.check_plot(x) a.markercolor = 16 support.check_plot(x) a.markercolor = 44 # same as a.markercolor=(44) support.check_plot(x) a.markercolor = None support.check_plot(x) ############################################################################ # Change the xvsy marker size # ############################################################################ a.markersize = 5 support.check_plot(x) a.markersize = 55 support.check_plot(x) a.markersize = 10 support.check_plot(x) a.markersize = 100 support.check_plot(x) a.markersize = 300 support.check_plot(x) a.markersize = None support.check_plot(x) x.clear() # clear the VCS Canvas x.xvsy(u, v, a, 'default', bg=bg) # plot xvsy using 'default' template support.check_plot(x) ######################################################################### # Create template 'test' from the default template # ######################################################################### objs = x.listelements('template') # get the list of templates t = x.createtemplate( 'test') # create template 'test' from 'default' template if not vcs.istemplate(t): # test whether 't' is a template or not raise Exception, "Error template not created" else: a2 = x.listelements('template') # get the list of templates if objs == a2: raise Exception, "Error template not created or added to list" x.clear() # clear the VCS Canvas x.plot(t, a, u, v, bg=bg) # plot xvsy template 't', outline 'a', and arrays 'u':'v' support.check_plot(x) x.clear() # clear the VCS Canvas x.xvsy(a, u, v, t, bg=bg) # plot using outline 'a', array 'u':'v', and template 't' support.check_plot(x) l = x.getline('red') # get line 'red' if not vcs.issecondaryobject( l): # check to see if it is a secondary object raise Exception, "Error did not get line" else: if not vcs.isline(l): # check to see if it is a line raise Exception, "Error object created is not line" ########################################################################### # Use the create line object 'm' from above and modify the line object # ########################################################################### a.line = l # use the line object support.check_plot(x) l.color = 44 # change the line color support.check_plot(x) l.type = 'dot' # change the line type support.check_plot(x) l.width = 4 # change the line size support.check_plot(x) m = x.getmarker('red') # get marker 'red' if not vcs.issecondaryobject( m): # check to see if it is a secondary object raise Exception, "Error did not get marker" else: if not vcs.ismarker(m): # check to see if it is a line raise Exception, "Error object created is not marker" ########################################################################### # Use the create marker object 'm' from above and modify the line object # ########################################################################### a.marker = m # use the marker object support.check_plot(x) m.color = 44 # change the marker color support.check_plot(x) m.type = 'square' # change the marker type support.check_plot(x) m.size = 20 # change the marker size support.check_plot(x) a = x.listelements('xvsy') # show list of gm r = x.createxvsy('test2', 'quick') # create xyvsy 'test2' a2 = x.listelements('xvsy') # show list of gm if a2 == a: raise "error gm not created or not added to list" x.removeobject(r) # remove xyvsy 'test2' a3 = x.listelements('xvsy') # show list of gm if a3 != a: raise "error gm not removed" ################################################################################# # to see how x.update and x.mode work, see testoutline.py # ################################################################################# #x.update() #x.mode=1 #x.mode=0 print '*************************************************************************************' print '****** ******' print '****** X v s Y T E S T C O M P L E T E D S U C E S S F U L L Y ******' print '****** ******' print '*************************************************************************************'
def test(): import vcs import cdms2 as cdms import os import support # import vcs and cdms bg = support.bg f = cdms.open(os.path.join(vcs.sample_data, 'clt.nc')) # open clt file u = f('u') # get slab u x = vcs.init() # construct vcs canvas x.plot(u, 'default', 'yxvsx', 'ASD7', bg=bg) # plot slab the old way support.check_plot(x) if support.dogui: x.geometry(450, 337, 100, 0) # change the geometry and location x.flush() support.check_plot(x) a = x.getyxvsx('ASD7') # get 'ASD7' yxvsx # test object 'a' for graphics method if not vcs.isgraphicsmethod(a): raise Exception("Error not a gm") else: if not vcs.isyxvsx(a): # test object 'a' if yxvsx raise Exception("Error wrong type of gm") # save 'ASD7' yxvsx as a Python script a.script('test', 'w') a.xticlabels('', '') # remove the x-axis support.check_plot(x) a.xticlabels('*') # put the x-axis support.check_plot(x) ########################################################################## # Change the yxvsx line # ########################################################################## a.line = 0 # same as 'solid' support.check_plot(x) a.line = 1 # same as 'dash' support.check_plot(x) a.line = 2 # same as 'dot' support.check_plot(x) a.line = 3 # same as 'dash-dot' support.check_plot(x) a.line = 4 # same as 'long-dash' support.check_plot(x) if '--extended' not in sys.argv: print '\n************* PARTIAL TEST *****************' print 'FOR COMPLETE TEST OF THIS MODULE USE ' print ' -F (--full) or -E (--extended) option' print '************* PARTIAL TEST *****************\n' sys.exit() ########################################################################## # Change the yxvsx line color # ########################################################################## a.linecolor = (77) support.check_plot(x) a.linecolor = 16 support.check_plot(x) a.linecolor = 44 # same as a.color=(44) support.check_plot(x) a.linecolor = None support.check_plot(x) ########################################################################## # Change the yxvsx marker # ########################################################################## a.marker = 1 # Same as a.marker='dot' support.check_plot(x) a.marker = 2 # Same as a.marker='plus' support.check_plot(x) a.marker = 3 # Same as a.marker='star' support.check_plot(x) a.marker = 4 # Same as a.marker='circle' support.check_plot(x) a.marker = 5 # Same as a.marker='cross' support.check_plot(x) a.marker = 6 # Same as a.marker='diamond' support.check_plot(x) a.marker = 7 # Same as a.marker='triangle_up' support.check_plot(x) a.marker = 8 # Same as a.marker='triangle_down' support.check_plot(x) a.marker = 9 # Same as a.marker='triangle_left' support.check_plot(x) a.marker = 10 # Same as a.marker='triangle_right' support.check_plot(x) a.marker = 11 # Same as a.marker='square' support.check_plot(x) a.marker = 12 # Same as a.marker='diamond_fill' support.check_plot(x) a.marker = 13 # Same as a.marker='triangle_up_fill' support.check_plot(x) # Same as a.marker='triangle_down_fill' a.marker = 14 support.check_plot(x) # Same as a.marker='triangle_left_fill' a.marker = 15 support.check_plot(x) # Same as a.marker='triangle_right_fill' a.marker = 16 support.check_plot(x) a.marker = 17 # Same as a.marker='square_fill' support.check_plot(x) a.marker = None # Draw no markers support.check_plot(x) ########################################################################## # Change the yxvsx marker color # ########################################################################## a.marker = 'dot' support.check_plot(x) a.markercolor = 16 support.check_plot(x) a.markercolor = 44 # same as a.markercolor=(44) support.check_plot(x) a.markercolor = None support.check_plot(x) ########################################################################## # Change the yxvsx marker size # ########################################################################## a.markersize = 5 support.check_plot(x) a.markersize = 55 support.check_plot(x) a.markersize = 10 support.check_plot(x) a.markersize = 100 support.check_plot(x) a.markersize = 300 support.check_plot(x) a.markersize = None support.check_plot(x) x.clear() # clear the VCS Canvas x.yxvsx(u, a, 'default', bg=bg) # plot yxvsx using 'default' template support.check_plot(x) # show the list of templates # create template 'test' from 'default' template t = x.createtemplate('test') # test whether 't' is a template or not if not vcs.istemplate(t): raise Exception("Error creating tmeplate") x.clear() # clear the VCS Canvas # plot yxvsx template 't', outline 'a', and arrays 'u':'v' x.plot(t, a, u, bg=bg) support.check_plot(x) x.clear() # clear the VCS Canvas # plot using outline 'a', array 'u':'v', and template 't' x.yxvsx(a, u, t, bg=bg) support.check_plot(x) # show the list of line secondary objects l = x.getline('red') # get line 'red' # check to see if it is a secondary object if not vcs.issecondaryobject(l): raise Exception("Error did not get line") else: if not vcs.isline(l): # check to see if it is a line raise Exception("Error object created is not line") ########################################################################### # Use the create line object 'm' from above and modify the line object # ########################################################################### a.line = l # use the line object support.check_plot(x) l.color = 44 # change the line color support.check_plot(x) l.type = 'dot' # change the line type support.check_plot(x) l.width = 4 # change the line size support.check_plot(x) # show the list of marker secondary objects m = x.getmarker('red') # get marker 'red' # check to see if it is a secondary object if not vcs.issecondaryobject(m): raise Exception("Error did not get marker") else: # check to see if it is a line if not vcs.ismarker(m): raise Exception("Error object created is not marker") ########################################################################### # Use the create marker object 'm' from above and modify the line object # ########################################################################### a.marker = m # use the marker object support.check_plot(x) m.color = 44 # change the marker color support.check_plot(x) m.type = 'square' # change the marker type support.check_plot(x) m.size = 20 # change the marker size support.check_plot(x) a = x.listelements('yxvsx') # show list of xyvsy r = x.createyxvsx('test2', 'ASD1') # create xyvsy 'test2' a2 = x.listelements('yxvsx') # show list of xyvsy if a2 == a: raise "error gm not created or not added to list" x.removeobject(r) # remove xyvsy 'test2' a3 = x.listelements('yxvsx') # show list of xyvsy if a3 != a: raise "error gm not removed" ########################################################################## # to see how x.update and x.mode work, see testoutline.py # ########################################################################## # x.update() # x.mode=1 # x.mode=0 print '*************************************************************************************' print '****** ******' print '****** Y x v s x T E S T C O M P L E T E D S U C E S S F U L L Y ******' print '****** ******' print '*************************************************************************************'
def test(): import vcs, cdms2 as cdms, time, os, sys, support # import vcs and cdms bg = support.bg f = cdms.open(os.path.join(cdms.__path__[0], "..", "..", "..", "..", "sample_data", "clt.nc")) # open clt file u = f("u") # get slab u x = vcs.init() # construct vcs canvas x.plot(u, "default", "xyvsy", "ASD7", bg=bg) # plot slab the old way support.check_plot(x) if bg == 0: x.geometry(450, 337, 100, 0) # change the geometry and location x.flush() support.check_plot(x) a = x.getxyvsy("ASD7") # get 'ASD1' xyvsy if not vcs.isgraphicsmethod(a): # test object 'a' for graphics method raise Exception, "Error did not retrieve the gm" else: if not vcs.isxyvsy(a): # test object 'a' if xyvsy raise Exception, "Error gm is not right type" a.script("test", "w") # save 'ASD7' xyvsy as a Python script a.xticlabels("", "") # remove the x-axis support.check_plot(x) a.xticlabels("*") # put the x-axis support.check_plot(x) ############################################################################ # Change the xyvsy line # ############################################################################ a.line = 0 # same as 'solid' support.check_plot(x) a.line = 1 # same as 'dash' support.check_plot(x) a.line = 2 # same as 'dot' support.check_plot(x) a.line = 3 # same as 'dash-dot' support.check_plot(x) a.line = 4 # same as 'long-dash' support.check_plot(x) if not "--extended" in sys.argv: print "\n************* PARTIAL TEST *****************" print "FOR COMPLETE TEST OF THIS MODULE USE " print " -F (--full) or -E (--extended) option" print "************* PARTIAL TEST *****************\n" sys.exit() ############################################################################ # Change the xyvsy line color # ############################################################################ a.linecolor = 77 support.check_plot(x) a.linecolor = 16 support.check_plot(x) a.linecolor = 44 # same as a.color=(44) support.check_plot(x) a.linecolor = None support.check_plot(x) ############################################################################ # Change the xyvsy marker # ############################################################################ a.marker = 1 # Same as a.marker='dot' support.check_plot(x) a.marker = 2 # Same as a.marker='plus' support.check_plot(x) a.marker = 3 # Same as a.marker='star' support.check_plot(x) a.marker = 4 # Same as a.marker='circle' support.check_plot(x) a.marker = 5 # Same as a.marker='cross' support.check_plot(x) a.marker = 6 # Same as a.marker='diamond' support.check_plot(x) a.marker = 7 # Same as a.marker='triangle_up' support.check_plot(x) a.marker = 8 # Same as a.marker='triangle_down' support.check_plot(x) a.marker = 9 # Same as a.marker='triangle_left' support.check_plot(x) a.marker = 10 # Same as a.marker='triangle_right' support.check_plot(x) a.marker = 11 # Same as a.marker='square' support.check_plot(x) a.marker = 12 # Same as a.marker='diamond_fill' support.check_plot(x) a.marker = 13 # Same as a.marker='triangle_up_fill' support.check_plot(x) a.marker = 14 # Same as a.marker='triangle_down_fill' support.check_plot(x) a.marker = 15 # Same as a.marker='triangle_left_fill' support.check_plot(x) a.marker = 16 # Same as a.marker='triangle_right_fill' support.check_plot(x) a.marker = 17 # Same as a.marker='square_fill' support.check_plot(x) a.marker = None # Draw no markers support.check_plot(x) ############################################################################ # Change the xyvsy marker color # ############################################################################ a.marker = "dot" support.check_plot(x) a.markercolor = 16 support.check_plot(x) a.markercolor = 44 # same as a.markercolor=(44) support.check_plot(x) a.markercolor = None support.check_plot(x) ############################################################################ # Change the xyvsy marker size # ############################################################################ a.markersize = 5 support.check_plot(x) a.markersize = 55 support.check_plot(x) a.markersize = 10 support.check_plot(x) a.markersize = 100 support.check_plot(x) a.markersize = 300 support.check_plot(x) a.markersize = None support.check_plot(x) x.clear() # clear the VCS Canvas x.xyvsy(u, a, "default", bg=bg) # plot xyvsy using 'default' template support.check_plot(x) objs = x.listelements("template") # get the list of templates t = x.createtemplate("test") # create template 'test' from 'default' template if not vcs.istemplate(t): # test whether 't' is a template or not raise Exception, "Error template not created" else: a2 = x.listelements("template") # get the list of templates if objs == a2: raise Exception, "Error template not created or added to list" x.clear() # clear the VCS Canvas x.plot(t, a, u, bg=bg) # plot xyvsy template 't', outline 'a', and arrays 'u':'v' support.check_plot(x) x.clear() # clear the VCS Canvas x.xyvsy(a, u, t, bg=bg) # plot using outline 'a', array 'u':'v', and template 't' support.check_plot(x) objs = x.listelements("line") # show the list of line secondary objects l = x.getline("red") # get line 'red' if not vcs.issecondaryobject(l): # check to see if it is a secondary object raise Exception, "Error did not get line" else: if not vcs.isline(l): # check to see if it is a line raise Exception, "Error object created is not line" ########################################################################### # Use the create line object 'm' from above and modify the line object # ########################################################################### a.line = l # use the line object l.color = 44 # change the line color support.check_plot(x) l.type = "dot" # change the line type support.check_plot(x) l.width = 4 # change the line size support.check_plot(x) objs = x.listelements("marker") # show the list of marker secondary objects m = x.getmarker("red") # get marker 'red' if not vcs.issecondaryobject(m): # check to see if it is a secondary object raise Exception, "Error did not get marker" else: if not vcs.ismarker(m): # check to see if it is a line raise Exception, "Error object created is not marker" ########################################################################### # Use the create marker object 'm' from above and modify the line object # ########################################################################### a.marker = m # use the marker object support.check_plot(x) m.color = 44 # change the marker color support.check_plot(x) m.type = "square" # change the marker type support.check_plot(x) m.size = 20 # change the marker size support.check_plot(x) a = x.listelements("xyvsy") # show list of xyvsy r = x.createxyvsy("test2", "ASD1") # create xyvsy 'test2' a2 = x.listelements("xyvsy") # show list of xyvsy if a2 == a: raise "error gm not created or not added to list" x.removeobject(r) # remove xyvsy 'test2' a3 = x.listelements("xyvsy") # show list of xyvsy if a3 != a: raise "error gm not removed" ################################################################################# # to see how x.update and x.mode work, see testoutline.py # ################################################################################# # x.update() # x.mode=1 # x.mode=0 print "*************************************************************************************" print "****** ******" print "****** X y v s y T E S T C O M P L E T E D S U C E S S F U L L Y ******" print "****** ******" print "*************************************************************************************"
def test(): import vcs,cdms2,time,os,sys,support # import vcs and cu bg=support.bg f=cdms2.open(os.path.join(cdms2.__path__[0],'..','..','..','..','sample_data','clt.nc')) u=f('u') # get slab u v=f('v') # get slab v x=vcs.init() # construct vcs canvas x.plot(u, v, 'default','scatter','quick',bg=bg) # plot slab the old way support.check_plot(x) if bg==0: x.mode=1 x.geometry(450,337,100,0) # change the geometry and location x.flush() support.check_plot(x) a=x.getscatter('quick') # get 'quick' scatter if not vcs.isgraphicsmethod(a): # test object 'a' for graphics method raise Exception, "Error did not retrieve the gm" else: if not vcs.isscatter(a): # test object 'a' if scatter raise Exception, "Error gm is not right type" a.script('test','w') # save 'quick' scatter as a Python script print 'yepp' a.xticlabels('','') # remove the x-axis support.check_plot(x) a.xticlabels('*') # put the x-axis support.check_plot(x) ############################################################################ # Change the scatter marker type # ############################################################################ #a.marker=0 a.marker=1 # same as a.marker='dot' support.check_plot(x) a.marker=2 # same as a.marker='plus' support.check_plot(x) a.marker=3 # same as a.marker='star' support.check_plot(x) a.marker=4 # same as a.marker='circle' support.check_plot(x) a.marker=5 # same as a.marker='cross' support.check_plot(x) a.marker=6 # same as a.marker='diamond' support.check_plot(x) a.marker=7 # same as a.marker='triangle_up' support.check_plot(x) a.marker=8 # same as a.marker='triangle_down' support.check_plot(x) a.marker=9 # same as a.marker='triangle_left' support.check_plot(x) a.marker=10 # same as a.marker='triangle_right' support.check_plot(x) a.marker=11 # same as a.marker='square' support.check_plot(x) a.marker=12 # same as a.marker='diamond_fill' support.check_plot(x) a.marker=13 # same as a.marker='triangle_up_fill' support.check_plot(x) a.marker=14 # same as a.marker='triangle_down_fill' support.check_plot(x) a.marker=15 # same as a.marker='triangle_left_fill' support.check_plot(x) a.marker=16 # same as a.marker='triangle_right_fill' support.check_plot(x) a.marker=17 # same as a.marker='square_fill' support.check_plot(x) ############################################################################ # Change the scatter marker size # ############################################################################ a.markersize=5 support.check_plot(x) a.markersize=55 support.check_plot(x) a.markersize=100 support.check_plot(x) a.markersize=300 support.check_plot(x) a.markersize=15 support.check_plot(x) ############################################################################ # Change the scatter marker color # ############################################################################ a.markercolor=(77) support.check_plot(x) a.markercolor=16 support.check_plot(x) a.markercolor=44 # same as a.markercolor=(44) support.check_plot(x) ############################################################################ # Change the scatter settings to default # ############################################################################ a.markercolor=None support.check_plot(x) a.markersize=None support.check_plot(x) a.marker=None support.check_plot(x) a.marker=1 # same as a.marker='dot' support.check_plot(x) x.clear() # clear the VCS Canvas x.scatter(u, v, a,'default',bg=bg) # plot scatter using 'default' template support.check_plot(x) t=x.createtemplate('test') # create template 'test' from 'default' template x.clear() # clear the VCS Canvas x.plot(t,a,u,v,bg=bg) # plot scatter template 't', outline 'a', and arrays 'u':'v' support.check_plot(x) x.clear() # clear the VCS Canvas x.scatter(a,u,v,t,bg=bg) # plot using outline 'a', array 'u':'v', and template 't' support.check_plot(x) m=x.getmarker('red') # get marker 'red' if vcs.issecondaryobject(m): # check to see if it is a secondary object if not vcs.ismarker(m): # check to see if it is a fill area raise Exception, "Error: this is not a marker object." else: raise Exception, "Error: this is not a sceondary object." ########################################################################### # Use the create marker object 'm' from above and modify the line object # ########################################################################### a.marker=m # use the marker object support.check_plot(x) m.color = 44 # change the marker color support.check_plot(x) m.type ='square' # change the marker type support.check_plot(x) m.size=20 # change the marker size support.check_plot(x) e = x.listelements('scatter') # show list of scatter r=x.createscatter('test2','quick') # create scatter 'test2' e2 = x.listelements('scatter') # show list of scatter if e2==e: raise Exception,"Error new scatter does not appear in list" e3=list(e) e3.append("test2") e3.sort() if e3!=e2: raise "Error new scatter created but not matching old list of scatter" x.removeobject(r) # remove scatter 'test2' e4 = x.listelements('scatter') # show list of scatter if e4!=e: raise Exception,"Error method not removed" ################################################################################# # to see how x.update and x.mode work, see testoutline.py # ################################################################################# #x.update() #x.mode=1 #x.mode=0 print '*************************************************************************************' print '****** ******' print '****** S C A T T E R T E S T C O M P L E T E D S U C E S S F U L L Y ******' print '****** ******' print '*************************************************************************************'
def test(): import vcs,cdms2 as cdms,time,os,sys,support # import vcs and cu bg=support.bg f=cdms.open(os.path.join(cdms.__path__[0],'..','..','..','..','sample_data','clt.nc')) # open clt file u=f('u') # get slab u v=f('v') # get slab v x=vcs.init() # construct vcs canvas a=x.createxvsy('quick') # create 'quick' xvsy if not vcs.isgraphicsmethod(a): # test object 'a' for graphics method raise Exception, "Error did not retrieve the gm" else: if not vcs.isxvsy(a): # test object 'a' if xvsy raise Exception, "Error gm is not right type" x.plot(u, v, 'default','xvsy','quick',bg=bg) # plot slabs the old way support.check_plot(x) if bg==0: x.geometry(450,337,100,0) # change the geometry and location x.flush() support.check_plot(x) a.script('test','w') # save 'quick' xvsy as a Python script a.xticlabels('','') # remove the x-axis support.check_plot(x) a.xticlabels('*') # put the x-axis support.check_plot(x) ############################################################################ # Change the xvsy line # ############################################################################ a.line=0 # same as 'solid' support.check_plot(x) a.line=1 # same as 'dash' support.check_plot(x) a.line=2 # same as 'dot' support.check_plot(x) a.line=3 # same as 'dash-dot' support.check_plot(x) a.line=4 # same as 'long-dash' support.check_plot(x) if not '--extended' in sys.argv: print '\n************* PARTIAL TEST *****************' print 'FOR COMPLETE TEST OF THIS MODULE USE ' print ' -F (--full) or -E (--extended) option' print '************* PARTIAL TEST *****************\n' sys.exit() ############################################################################ # Change the xvsy line color # ############################################################################ a.linecolor=(77) support.check_plot(x) a.linecolor=16 support.check_plot(x) a.linecolor=44 # same as a.color=(44) support.check_plot(x) a.linecolor=None support.check_plot(x) ############################################################################ # Change the xvsy marker # ############################################################################ a.marker=1 # Same as a.marker='dot' support.check_plot(x) a.marker=2 # Same as a.marker='plus' support.check_plot(x) a.marker=3 # Same as a.marker='star' support.check_plot(x) a.marker=4 # Same as a.marker='circle' support.check_plot(x) a.marker=5 # Same as a.marker='cross' support.check_plot(x) a.marker=6 # Same as a.marker='diamond' support.check_plot(x) a.marker=7 # Same as a.marker='triangle_up' support.check_plot(x) a.marker=8 # Same as a.marker='triangle_down' support.check_plot(x) a.marker=9 # Same as a.marker='triangle_left' support.check_plot(x) a.marker=10 # Same as a.marker='triangle_right' support.check_plot(x) a.marker=11 # Same as a.marker='square' support.check_plot(x) a.marker=12 # Same as a.marker='diamond_fill' support.check_plot(x) a.marker=13 # Same as a.marker='triangle_up_fill' support.check_plot(x) a.marker=14 # Same as a.marker='triangle_down_fill' support.check_plot(x) a.marker=15 # Same as a.marker='triangle_left_fill' support.check_plot(x) a.marker=16 # Same as a.marker='triangle_right_fill' support.check_plot(x) a.marker=17 # Same as a.marker='square_fill' support.check_plot(x) a.marker=None # Draw no markers support.check_plot(x) ############################################################################ # Change the xvsy marker color # ############################################################################ a.marker='dot' support.check_plot(x) a.markercolor=16 support.check_plot(x) a.markercolor=44 # same as a.markercolor=(44) support.check_plot(x) a.markercolor=None support.check_plot(x) ############################################################################ # Change the xvsy marker size # ############################################################################ a.markersize=5 support.check_plot(x) a.markersize=55 support.check_plot(x) a.markersize=10 support.check_plot(x) a.markersize=100 support.check_plot(x) a.markersize=300 support.check_plot(x) a.markersize=None support.check_plot(x) x.clear() # clear the VCS Canvas x.xvsy(u, v, a,'default',bg=bg) # plot xvsy using 'default' template support.check_plot(x) ######################################################################### # Create template 'test' from the default template # ######################################################################### objs =x.listelements('template') # get the list of templates t=x.createtemplate('test') # create template 'test' from 'default' template if not vcs.istemplate(t): # test whether 't' is a template or not raise Exception,"Error template not created" else: a2 =x.listelements('template') # get the list of templates if objs==a2: raise Exception,"Error template not created or added to list" x.clear() # clear the VCS Canvas x.plot(t,a,u,v,bg=bg) # plot xvsy template 't', outline 'a', and arrays 'u':'v' support.check_plot(x) x.clear() # clear the VCS Canvas x.xvsy(a,u,v,t,bg=bg) # plot using outline 'a', array 'u':'v', and template 't' support.check_plot(x) l=x.getline('red') # get line 'red' if not vcs.issecondaryobject(l): # check to see if it is a secondary object raise Exception,"Error did not get line" else: if not vcs.isline(l): # check to see if it is a line raise Exception, "Error object created is not line" ########################################################################### # Use the create line object 'm' from above and modify the line object # ########################################################################### a.line=l # use the line object support.check_plot(x) l.color = 44 # change the line color support.check_plot(x) l.type ='dot' # change the line type support.check_plot(x) l.width=4 # change the line size support.check_plot(x) m=x.getmarker('red') # get marker 'red' if not vcs.issecondaryobject(m): # check to see if it is a secondary object raise Exception,"Error did not get marker" else: if not vcs.ismarker(m): # check to see if it is a line raise Exception, "Error object created is not marker" ########################################################################### # Use the create marker object 'm' from above and modify the line object # ########################################################################### a.marker=m # use the marker object support.check_plot(x) m.color = 44 # change the marker color support.check_plot(x) m.type ='square' # change the marker type support.check_plot(x) m.size=20 # change the marker size support.check_plot(x) a = x.listelements('xvsy') # show list of gm r=x.createxvsy('test2','quick') # create xyvsy 'test2' a2 = x.listelements('xvsy') # show list of gm if a2==a: raise "error gm not created or not added to list" x.removeobject(r) # remove xyvsy 'test2' a3 = x.listelements('xvsy') # show list of gm if a3!=a: raise "error gm not removed" ################################################################################# # to see how x.update and x.mode work, see testoutline.py # ################################################################################# #x.update() #x.mode=1 #x.mode=0 print '*************************************************************************************' print '****** ******' print '****** X v s Y T E S T C O M P L E T E D S U C E S S F U L L Y ******' print '****** ******' print '*************************************************************************************'
def test(): import vcs import cdms2 import os import support # import vcs and cu bg = support.bg f = cdms2.open(os.path.join(vcs.sample_data, 'clt.nc')) u = f('u') # get slab u v = f('v') # get slab v x = vcs.init() # construct vcs canvas x.plot(u, v, 'default', 'scatter', 'quick', bg=bg) # plot slab the old way support.check_plot(x) if bg == 0: x.mode = 1 x.geometry(450, 337, 100, 0) # change the geometry and location x.flush() support.check_plot(x) a = x.getscatter('quick') # get 'quick' scatter # test object 'a' for graphics method if not vcs.isgraphicsmethod(a): raise Exception("Error did not retrieve the gm") else: if not vcs.isscatter(a): # test object 'a' if scatter raise Exception("Error gm is not right type") # save 'quick' scatter as a Python script a.script('test', 'w') print 'yepp' a.xticlabels('', '') # remove the x-axis support.check_plot(x) a.xticlabels('*') # put the x-axis support.check_plot(x) ########################################################################## # Change the scatter marker type # ########################################################################## # a.marker=0 a.marker = 1 # same as a.marker='dot' support.check_plot(x) a.marker = 2 # same as a.marker='plus' support.check_plot(x) a.marker = 3 # same as a.marker='star' support.check_plot(x) a.marker = 4 # same as a.marker='circle' support.check_plot(x) a.marker = 5 # same as a.marker='cross' support.check_plot(x) a.marker = 6 # same as a.marker='diamond' support.check_plot(x) a.marker = 7 # same as a.marker='triangle_up' support.check_plot(x) a.marker = 8 # same as a.marker='triangle_down' support.check_plot(x) a.marker = 9 # same as a.marker='triangle_left' support.check_plot(x) a.marker = 10 # same as a.marker='triangle_right' support.check_plot(x) a.marker = 11 # same as a.marker='square' support.check_plot(x) a.marker = 12 # same as a.marker='diamond_fill' support.check_plot(x) a.marker = 13 # same as a.marker='triangle_up_fill' support.check_plot(x) a.marker = 14 # same as a.marker='triangle_down_fill' support.check_plot(x) a.marker = 15 # same as a.marker='triangle_left_fill' support.check_plot(x) a.marker = 16 # same as a.marker='triangle_right_fill' support.check_plot(x) a.marker = 17 # same as a.marker='square_fill' support.check_plot(x) ########################################################################## # Change the scatter marker size # ########################################################################## a.markersize = 5 support.check_plot(x) a.markersize = 55 support.check_plot(x) a.markersize = 100 support.check_plot(x) a.markersize = 300 support.check_plot(x) a.markersize = 15 support.check_plot(x) ########################################################################## # Change the scatter marker color # ########################################################################## a.markercolor = (77) support.check_plot(x) a.markercolor = 16 support.check_plot(x) a.markercolor = 44 # same as a.markercolor=(44) support.check_plot(x) ########################################################################## # Change the scatter settings to default # ########################################################################## a.markercolor = None support.check_plot(x) a.markersize = None support.check_plot(x) a.marker = None support.check_plot(x) a.marker = 1 # same as a.marker='dot' support.check_plot(x) x.clear() # clear the VCS Canvas x.scatter( u, v, a, 'default', bg=bg) # plot scatter using 'default' template support.check_plot(x) # create template 'test' from 'default' template t = x.createtemplate('test') x.clear() # clear the VCS Canvas # plot scatter template 't', outline 'a', and arrays 'u':'v' x.plot(t, a, u, v, bg=bg) support.check_plot(x) x.clear() # clear the VCS Canvas # plot using outline 'a', array 'u':'v', and template 't' x.scatter(a, u, v, t, bg=bg) support.check_plot(x) m = x.getmarker('red') # get marker 'red' # check to see if it is a secondary object if vcs.issecondaryobject(m): # check to see if it is a fill area if not vcs.ismarker(m): raise Exception("Error: this is not a marker object.") else: raise Exception("Error: this is not a sceondary object.") ########################################################################### # Use the create marker object 'm' from above and modify the line object # ########################################################################### a.marker = m # use the marker object support.check_plot(x) m.color = 44 # change the marker color support.check_plot(x) m.type = 'square' # change the marker type support.check_plot(x) m.size = 20 # change the marker size support.check_plot(x) e = x.listelements('scatter') # show list of scatter r = x.createscatter('test2', 'quick') # create scatter 'test2' e2 = x.listelements('scatter') # show list of scatter if e2 == e: raise Exception("Error new scatter does not appear in list") e3 = list(e) e3.append("test2") e3.sort() if e3 != e2: raise "Error new scatter created but not matching old list of scatter" x.removeobject(r) # remove scatter 'test2' e4 = x.listelements('scatter') # show list of scatter if e4 != e: raise Exception("Error method not removed") ########################################################################## # to see how x.update and x.mode work, see testoutline.py # ########################################################################## # x.update() # x.mode=1 # x.mode=0 print '*************************************************************************************' print '****** ******' print '****** S C A T T E R T E S T C O M P L E T E D S U C E S S F U L L Y ******' print '****** ******' print '*************************************************************************************'