Example #1
0
 def label_mode(self, v):
     if v == "Auto":
         self.labels = None
     elif v == "None":
         self.labels = {}
     else:
         if vcs.isboxfill(self._gm):
             self.labels = self._gm.autolabels(self._var)
Example #2
0
 def label_mode(self, v):
     if v == "Auto":
         self.labels = None
     elif v == "None":
         self.labels = {}
     else:
         if vcs.isboxfill(self._gm):
             self.labels = self._gm.autolabels(self._var)
Example #3
0
    def levels(self):
        """Used internally, don't worry about it."""
        levs = list(self._gm.levels)
        # Check if they're autolevels
        if numpy.allclose(levs, 1e20):
            if vcs.isboxfill(self._gm) == 1:
                nlevs = self.color_2 - self.color_1 + 1
                minval, maxval = vcs.minmax(self._var)
                levs = vcs.mkscale(minval, maxval)
                if len(levs) == 1:
                    levs.append(levs[0] + .00001)
                delta = (levs[-1] - levs[0]) / nlevs
                levs = list(numpy.arange(levs[0], levs[-1] + delta, delta))
            else:
                levs = vcs.mkscale(*vcs.minmax(self._var))

        # Now adjust for ext_1 nad ext_2
        if self.ext_left:
            levs.insert(0, -1e20)
        if self.ext_right:
            levs.append(1e20)

        return levs
Example #4
0
    def levels(self):
        """Used internally, don't worry about it."""
        levs = list(self._gm.levels)
        # Check if they're autolevels
        if numpy.allclose(levs, 1e20):
            if vcs.isboxfill(self._gm) == 1:
                nlevs = self.color_2 - self.color_1 + 1
                minval, maxval = vcs.minmax(self._var)
                levs = vcs.mkscale(minval, maxval)
                if len(levs) == 1:
                    levs.append(levs[0] + .00001)
                delta = (levs[-1] - levs[0]) / nlevs
                levs = list(numpy.arange(levs[0], levs[-1] + delta, delta))
            else:
                levs = vcs.mkscale(*vcs.minmax(self._var))

        # Now adjust for ext_1 nad ext_2
        if self.ext_left:
            levs.insert(0, -1e20)
        if self.ext_right:
            levs.append(1e20)

        return levs
Example #5
0
    def finalize( self, flip_x=False, flip_y=False ):
        """By the time this is called, all synchronize operations should have been done.  But even
        so, each variable has a min and max and a min and max for each of its axes.  We need to
        simplify further for the plot package.
        The options flip_x and flip_y may be set to True to flip the axis.  That is, in x right
        to left and left to right, and in y top to bottom and bottom to top."""
        # old test:
        #if self.presentation.__class__.__name__=="GYx" or\
        #        self.presentation.__class__.__name__=="Gfi":
        # interim test here and below.  Once all the is* functions work, I should
        # drop the tests on self.presentation.__class__.__name__ :
        if vcs.isscatter(self.presentation):
            ylabel, xlabel = string.split(self.title, ' vs ')
            #pdb.set_trace()
            #in the case of scatter plots there are 2 variables packed together
            var = self.vars[0]
            [xMIN, xMAX], [yMIN, yMAX] = self.make_ranges(var)

            #print xMIN, xMAX, yMIN, yMAX
            #print vcs.mkscale(xMIN, xMAX)
            #print vcs.mkscale(yMIN, yMAX)
            self.presentation.xticlabels1 = vcs.mklabels(vcs.mkscale(xMIN, xMAX))
            self.presentation.datawc_x1 = xMIN
            self.presentation.datawc_x2 = xMAX
            self.presentation.xticlabels2 = {(xMIN+xMAX)/2.: xlabel}
            if flip_y:
                self.presentation.datawc_y2 = yMIN
                self.presentation.datawc_y1 = yMAX
                self.presentation.flip = True
            else:
                self.presentation.datawc_y1 = yMIN
                self.presentation.datawc_y2 = yMAX   
            self.presentation.yticlabels1 = vcs.mklabels(vcs.mkscale(yMIN, yMAX))
            self.presentation.yticlabels2 = {(yMIN+yMAX)/2.: ylabel}
            self.presentation.linewidth = 0
            self.presentation.markercolor = 1
            self.presentation.markersize = 5
            #add overplotline is a total kludge
            self.presentation.overplotline = self.overplotline
            if flip_y:
                self.presentation.flip = True
            #self.presentation.list()              
        elif vcs.isyxvsx(self.presentation) or\
                vcs.isisofill(self.presentation) or\
                vcs.isboxfill(self.presentation) or\
                self.presentation.__class__.__name__=="GYx" or\
                self.presentation.__class__.__name__=="G1d" or\
                self.presentation.__class__.__name__=="Gv":
            #pdb.set_trace()
            if flip_y:
                self.presentation.flip = True
            var = self.vars[0]
            axmax = self.axmax[seqgetattr(var,'id','')]
            axmin = self.axmin[seqgetattr(var,'id','')]
            varmax = self.varmax[seqgetattr(var,'id','')]
            varmin = self.varmin[seqgetattr(var,'id','')]
            for v in self.vars[1:]:
                for ax in axmax.keys():
                    axmax[ax] = max(axmax[ax],self.axmax[seqgetattr(v,'id','')][ax])
                    axmin[ax] = min(axmin[ax],self.axmin[seqgetattr(v,'id','')][ax])
                varmax = max(varmax,self.varmax[v.id])
                varmin = min(varmin,self.varmin[v.id])                 
            if vcs.isyxvsx(self.presentation) or\
                    self.presentation.__class__.__name__=="GYx" or\
                    self.presentation.__class__.__name__=="G1d":
                if len(axmax.keys())<=0:
                    return None
                # VCS Yxvsx
                ax = axmax.keys()[0]
                if flip_x:
                    self.presentation.datawc_x2 = axmin[ax]
                    self.presentation.datawc_x1 = axmax[ax]
                else:
                    self.presentation.datawc_x1 = axmin[ax]
                    self.presentation.datawc_x2 = axmax[ax]
                if flip_y:
                    self.presentation.datawc_y2 = varmin
                    self.presentation.datawc_y1 = varmax
                else:
                    self.presentation.datawc_y1 = varmin
                    self.presentation.datawc_y2 = varmax
                #print "DEBUG, in finalize for line plot, datawc_{x1,x2,y1,y2}=",\
                #    self.presentation.datawc_x1, self.presentation.datawc_x2,\
                #    self.presentation.datawc_y1, self.presentation.datawc_y2
            if vcs.isisofill(self.presentation) or self.presentation.__class__.__name__=="Gfi"\
                    or vcs.isboxfill(self.presentation):
                # VCS Isofill or Boxfill

                # First we have to identify which axes will be plotted as X and Y.
                # If the axes each had an 'axis' attribute, axaxi will look something like
                # {'X':'axis1id', 'Y':'axis2id'}.  If one misses the attribute, 'axis0id':'axis0id'.
                axaxi = {ax:id for id,ax in self.axax[seqgetattr(var,'id','')].items()}
                if 'X' in axaxi.keys() and 'Y' in axaxi.keys():
                    axx = axaxi['X']
                    axy = axaxi['Y']
                elif 'Y' in axaxi.keys() and 'Z' in axaxi.keys():
                    axx = axaxi['Y']
                    axy = axaxi['Z']
                #added case of time vs variable
                elif 'T' in axaxi.keys() and 'Y' in axaxi.keys():
                    axx = axaxi['T']
                    axy = axaxi['Y']
                    if axx == 'time':
                        t=var.getTime()
                        if 'units' in dir(t) and t.units == "months since 1800":
                            time_lables = {}
                            months_names = get_month_strings(length=3)             
                            tc=t.asComponentTime()
                            for i, v in enumerate(t):
                                time_lables[v] = months_names[tc[i].month-1]
                            self.presentation.xticlabels1 = time_lables
                            self.presentation.datawc_timeunits = t.units
                            #self.presentation.list()
                elif len(axaxi.keys())==2:
                    # It's not clear what should be the X variable and what the Y variable,
                    # but it's worth trying to do something
                    axx = None
                    axy = None
                    for axetc in var.getDomain()[:]:
                        ax = axetc[0]
                        if getattr(ax,'units',None)=='mbar':
                            # probably pressure levels, a vertical axis
                            axy = ax.id
                        else:
                            axx = ax.id
                    if axx is None or axy is None:
                        # last resort
                        axy = axaxi[axaxi.keys()[0]]
                        axx = axaxi[axaxi.keys()[1]]
                else:
                    return None

                # Now send the plotted min,max for the X,Y axes to the graphics:
                # and if it is not a polar projection
                if vcs.getprojection(self.presentation.projection)._type!=-3:
                    if flip_x:
                        self.presentation.datawc_x2 = axmin[axx]
                        self.presentation.datawc_x1 = axmax[axx]
                    else:
                        self.presentation.datawc_x1 = axmin[axx]
                        self.presentation.datawc_x2 = axmax[axx]
                    if flip_y:
                        self.presentation.datawc_y2 = axmin[axy]
                        self.presentation.datawc_y1 = axmax[axy]
                    else:
                        self.presentation.datawc_y1 = axmin[axy]
                        self.presentation.datawc_y2 = axmax[axy]

                # The variable min and max, varmin and varmax, should be passed on to the graphics
                # for setting the contours.  But apparently you can't tell VCS just the min and max;
                # you have to give it all the contour levels.  So...
                if vcs.isboxfill(self.presentation):
                    self.presentation.boxfill_type = 'custom'  # without this, can't set levels
                nlevels = 16
                try:
                    levels = [float(v) for v in vcs.mkscale( varmin, varmax, nlevels )]
                    # Exceptions occur because mkscale doesn't always work.  E.g. vcs.mkscale(0,1.e35,16)
                except RuntimeWarning:
                    levels = []
                if levels==[]:
                    ## Here's how to do it with percentiles (clip out large values first).
                    #pc05 = numpy.percentile(self.vars[0],0.05)
                    #pc95 = numpy.percentile(self.vars[0],0.95)
                    #levels = [float(v) for v in vcs.mkscale( pc05, pc95, nlevels-2 )]
                    #levels = [varmin]+levels+[varmax]
                    # Evenly distributed levels, after clipping out large values:
                    # This cannot be expected to work always, but it's better than doing nothing.
                    amed = numpy.median(self.vars[0]._data)
                    vclip = amed * 1.0e6
                    print "WARNING graphics problems, clipping some data at",vclip
                    self.vars[0]._data[ self.vars[0]._data > vclip ] = vclip
                    a = numpy.sort(self.vars[0]._data.flatten())
                    asp = numpy.array_split(a,nlevels)
                    afirsts = [c[0] for c in asp]+[asp[-1][-1]]
                    alasts = [asp[0][0]]+[c[-1] for c in asp]
                    levels = [0.5*(afirsts[i]+alasts[i]) for i in range(len(afirsts))]
                    levf = levels[0]
                    levl = levels[-1]
                    levels = [ round(lv,2) for lv in levels ]
                    levels[0] = round(1.1*levels[0]-0.1*levels[1],2)
                    levels[-1] = round(1.1*levels[-1]-0.1*levels[-2],2)

                # ... mkscale returns numpy.float64, which behaves unexpectedly in _setlevels when
                # passed a tuple value
                if levels is not None and len(levels)>0:
                    self.presentation.levels = levels
                #nlevels = max(1, len(levels) - 1)
                #nlrange = range(nlevels+1)
                #nlrange.reverse()
                #self.presentation.legend = vcs.mklabels( self.presentation.levels )
                ## Once you set the levels, the VCS default color choice looks bad.  So you really
                ## have to set contour fill colors (integers from 0 through 255) too:
                #cmin = 32./nlevels
                #cmax = 255./nlevels
                ## A more flexible way to do what's going on here, thanks to Charles Doutriaux:
                ## r=10
                ## g=16
                ## b=20
                ## X.setcolorcell(16,r,g,b)
                ## colors = [16,17,18,...] etc.
                ## vcs.getcolors is useful, more complicated - see its doc string
                #colors =  [int(round(a*cmin+(nlevels-a)*cmax)) for a in nlrange]
                #self.presentation.fillareacolors = colors
                ##self.presentation.fillareacolors=[32,48,64,80,96,112,128,144,160,176,240]
            elif vcs.isvector(self.presentation) or self.presentation.__class__.__name__=="Gv":
                # axis min,max copied from isofill
                axaxi = {ax:id for id,ax in self.axax[seqgetattr(var,'id','')].items()}
                if 'X' in axaxi.keys() and 'Y' in axaxi.keys():
                    axx = axaxi['X']
                    axy = axaxi['Y']
                elif 'Y' in axaxi.keys() and 'Z' in axaxi.keys():
                    axx = axaxi['Y']
                    axy = axaxi['Z']
                self.presentation.datawc_x1 = axmin[axx]
                self.presentation.datawc_x2 = axmax[axx]
                self.presentation.datawc_y1 = axmin[axy]
                self.presentation.datawc_y2 = axmax[axy]

                vec = self.presentation
                vec.scale = min(vcsx.bgX,vcsx.bgY)/ 10.
                if hasattr(self.vars[0],'__getitem__') and not hasattr( self.vars[0], '__cdms_internals__'):
                    # generally a tuple of variables - we need 2 variables to describe a vector
                    v = self.vars[0][0]
                    w = self.vars[0][1]
                else:   # We shouldn't get here, but may as well try to make it work if possible:
                    print "WARNING trying to make a vector plot without tuples!  Variables involved are:"
                    v = self.vars[0]
                    print "variable",v.id
                    v = self.vars[1]
                    print "variable",v.id
                nlats = latAxis(v).shape[0]
                nlons = lonAxis(w).shape[0]
                nlatvs = vcsx.bgY/16   # how many vectors we want in lat direction
                nlonvs = vcsx.bgX/16
                #self.strideX = int( 0.9* vcsx.bgX/nlons )
                #self.strideY = int( 0.6* vcsx.bgY/nlats )
                self.strideX = max(1, int( nlons/nlonvs )) # stride values must be at least 1
                self.strideY = max(1, int( nlats/nlatvs ))
        else:
            print "ERROR cannot identify graphics method",self.presentation.__class__.__name__
Example #6
0
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'))
   s=f('clt')			        # get slab clt
   x=vcs.init()				# construct vcs canvas
   
   x.plot(s,'default','boxfill','quick',bg=bg)# plot slab the old way
   #support.check_plot(x)
   if bg==0:
      x.geometry(450,337)                  # change the geometry
      x.flush()
      #support.check_plot(x)
   
   a=x.getboxfill('quick') 		# get 'quick' boxfill graphics method
   if not vcs.isgraphicsmethod(a):            # test object 'a' for graphics method
      raise Exception, "Error did not retrieve the gm"
   else:
      if not vcs.isboxfill(a):		# check for boxfill
         raise Exception, "Error gm is not right type"

   # Change boxfill's legend
   a.legend={0:'Great',20:'Outstanding',40:'Wonderful',60:'Happy',80:'Exciting!',100:'Best'}
   support.check_plot(x)
   a.legend={0:'100',20:'80',40:'60',60:'40',80:'20',100:'0'}
   support.check_plot(x)
   a.legend={0:'Blue',20:'Green',40:'Yellow',60:'Red',80:'Burgundy',100:'Magenta'}
   support.check_plot(x)
   a.legend=(90)
   support.check_plot(x)
   a.legend=[10,90]
   support.check_plot(x)
   a.legend=(1.5,45.8,89.7)
   support.check_plot(x)
   a.legend=None
   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()

   a.color_1=50				# change color_1 index attribute
   support.check_plot(x)
   
   a.xticlabels('lon30','lon30')	# change xlabels attribute
   support.check_plot(x)
   a.xticlabels('','')			# change remove xlables from plot
   support.check_plot(x)
   a.datawc(-45.0, 45.0, -90.0, 90.0) 	# change region
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)	# change region back
   support.check_plot(x)
   a.xticlabels('*')			# change attribute labels back
   support.check_plot(x)
   
   x.mode=0				# turn atomatic update off
   a.color_1=100			# change color_1 attribute
   a.color_2=200			# change color_2 index value
   a.xticlabels('lon30','lon30')	# change attribute
   a.yticlabels('','')			# change y-labels off attribute
   a.datawc(-45.0, 45.0, -90.0, 90.0) 	# change region
   support.check_plot(x)
   x.update()				# view changes now
   support.check_plot(x)
   
   # Test log10 boxfill plot
   x.clear()				# clear the VCS Canvas
   a.boxfill_type = 'log10'             # Change the Boxfill type to log10
   a.datawc(1e20,1e20,1e20,1e20) 	# change region
   a.level_1=1e20			# change level_1
   a.level_2=1e20			# change level_2
   a.color_1=16				# change color_1 attribute
   a.color_2=239			# change color_2 index value
   x.boxfill(s,a,bg=bg)		        # plot using default template
   support.check_plot(x)


   # Test custom boxfill plot
   x.clear()				# clear the VCS Canvas
   a.boxfill_type = 'custom'            # Change the Boxfill type to custom 
   a.levels=(0,20,35,40,75,100)         # Set the custom ranges
   a.fillareacolors=(16,25,38,55,100,166) # Set the color indices
   x.boxfill(s,a,bg=bg)		        # plot using default template
   support.check_plot(x)

   # Test legend with fillareacolors boxfill plot
   x.clear()				# clear the VCS Canvas
   a.boxfill_type = 'linear'            # Change the Boxfill type back to linear 
   a.fillareacolors=(254,)           # Set the color indices
   a.level_1=0				# change level_1
   a.level_2=0				# change level_2
   x.boxfill(s,a,bg=bg)		        # plot using default template
   support.check_plot(x)
   
   a.script('test','w')			# save 'quick' boxfill as a Python script
   
   x.mode=1				# turn atomatic update mode back on
   a.color_1=16				# change color_1 attribute
   support.check_plot(x)
   a.color_2=239			# change color_2 index value
   support.check_plot(x)
   a.level_1=20				# change level_1
   support.check_plot(x)
   a.level_2=80				# change level_2
   support.check_plot(x)
   a.datawc(1e20,1e20,1e20,1e20)	# change region back
   support.check_plot(x)
   a.yticlabels('*')                    # change y-labels attribute
   support.check_plot(x)
   
   x.scriptobject(a,'test', 'a')	# append 'quick' to the existing file 
   a.script('test.scr','w')		# save 'quick' as a VCS script file
   
   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.boxfill(s,a,'default',bg=bg)		# plot using default template
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(a,'default',s,bg=bg)		# plot using default template, but, reverse the order
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(s,a,t,bg=bg)			# plot using template 'test'
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(a,s,t,bg=bg)			# plot using template 'test', but reverse the objects
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.boxfill(t,a,s,bg=bg)			# plot using template 'test', but reverse the objects
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   
   x.plot(t,a,s,bg=bg)			# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot(a,t,s,bg=bg)			# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot(s,t,a,bg=bg)			# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot('default',a,s,bg=bg)		# plot using the new way
   support.check_plot(x)
   x.clear()				# clear the VCS Canvas
   x.plot('default',s,bg=bg)			# plot using the new way
   support.check_plot(x)
   
   a = x.listelements('boxfill')                      # show list of xyvsy
   r=x.createboxfill('test2','quick')     # create xyvsy 'test2'
   a2 = x.listelements('boxfill')                      # 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('boxfill')                      # show list of xyvsy
   if a3!=a:
      raise "error gm not removed"

   a=x.getboxfill('quick')              # get 'quick' boxfill graphics method
   x.clear()
   x.plot(s,a,bg=bg)
   support.check_plot(x)
   if support.dogui:
      x.graphicsmethodgui('boxfill','quick')	# display the boxfill graphics method GUI
      raw_input("Press enter when done with gui testing")
   print '*************************************************************************************'
   print '******                                                                         ******'
   print '******   B O X F I L L   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 '*************************************************************************************'
Example #7
0
 def color_2(self, c):
     if vcs.isboxfill(self._gm):
         if self._gm.fillareacolors:
             self._gm.fillareacolors = None
         self._gm.color_2 = c
Example #8
0
 def color_2(self):
     """Used for boxfills only."""
     if vcs.isboxfill(self._gm):
         return self._gm.color_2
     else:
         return None
Example #9
0
 def labels(self):
     if self._gm.legend is None:
         if vcs.isboxfill(self._gm):
             return self._gm.autolabels(self._var)
     return self._gm.legend
Example #10
0
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'))
    s = f('clt')  # get slab clt
    x = vcs.init()  # construct vcs canvas

    x.plot(s, 'default', 'boxfill', 'quick', bg=bg)  # plot slab the old way
    # support.check_plot(x)
    if bg == 0:
        x.geometry(450, 337)  # change the geometry
        x.flush()
        # support.check_plot(x)

    a = x.getboxfill('quick')  # get 'quick' boxfill graphics method
    # test object 'a' for graphics method
    if not vcs.isgraphicsmethod(a):
        raise Exception("Error did not retrieve the gm")
    else:
        if not vcs.isboxfill(a):  # check for boxfill
            raise Exception("Error gm is not right type")

    # Change boxfill's legend
    a.legend = {
        0: 'Great',
        20: 'Outstanding',
        40: 'Wonderful',
        60: 'Happy',
        80: 'Exciting!',
        100: 'Best'
    }
    support.check_plot(x)
    a.legend = {0: '100', 20: '80', 40: '60', 60: '40', 80: '20', 100: '0'}
    support.check_plot(x)
    a.legend = {
        0: 'Blue',
        20: 'Green',
        40: 'Yellow',
        60: 'Red',
        80: 'Burgundy',
        100: 'Magenta'
    }
    support.check_plot(x)
    a.legend = (90)
    support.check_plot(x)
    a.legend = [10, 90]
    support.check_plot(x)
    a.legend = (1.5, 45.8, 89.7)
    support.check_plot(x)
    a.legend = None
    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()

    a.color_1 = 50  # change color_1 index attribute
    support.check_plot(x)

    a.xticlabels('lon30', 'lon30')  # change xlabels attribute
    support.check_plot(x)
    a.xticlabels('', '')  # change remove xlables from plot
    support.check_plot(x)
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change region
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # change region back
    support.check_plot(x)
    a.xticlabels('*')  # change attribute labels back
    support.check_plot(x)

    x.mode = 0  # turn atomatic update off
    a.color_1 = 100  # change color_1 attribute
    a.color_2 = 200  # change color_2 index value
    a.xticlabels('lon30', 'lon30')  # change attribute
    a.yticlabels('', '')  # change y-labels off attribute
    a.datawc(-45.0, 45.0, -90.0, 90.0)  # change region
    support.check_plot(x)
    x.update()  # view changes now
    support.check_plot(x)

    # Test log10 boxfill plot
    x.clear()  # clear the VCS Canvas
    a.boxfill_type = 'log10'  # Change the Boxfill type to log10
    a.datawc(1e20, 1e20, 1e20, 1e20)  # change region
    a.level_1 = 1e20  # change level_1
    a.level_2 = 1e20  # change level_2
    a.color_1 = 16  # change color_1 attribute
    a.color_2 = 239  # change color_2 index value
    x.boxfill(s, a, bg=bg)  # plot using default template
    support.check_plot(x)

    # Test custom boxfill plot
    x.clear()  # clear the VCS Canvas
    a.boxfill_type = 'custom'  # Change the Boxfill type to custom
    a.levels = (0, 20, 35, 40, 75, 100)  # Set the custom ranges
    a.fillareacolors = (16, 25, 38, 55, 100, 166)  # Set the color indices
    x.boxfill(s, a, bg=bg)  # plot using default template
    support.check_plot(x)

    # Test legend with fillareacolors boxfill plot
    x.clear()  # clear the VCS Canvas
    # Change the Boxfill type back to linear
    a.boxfill_type = 'linear'
    a.fillareacolors = (254, )  # Set the color indices
    a.level_1 = 0  # change level_1
    a.level_2 = 0  # change level_2
    x.boxfill(s, a, bg=bg)  # plot using default template
    support.check_plot(x)

    a.script('test', 'w')  # save 'quick' boxfill as a Python script

    x.mode = 1  # turn atomatic update mode back on
    a.color_1 = 16  # change color_1 attribute
    support.check_plot(x)
    a.color_2 = 239  # change color_2 index value
    support.check_plot(x)
    a.level_1 = 20  # change level_1
    support.check_plot(x)
    a.level_2 = 80  # change level_2
    support.check_plot(x)
    a.datawc(1e20, 1e20, 1e20, 1e20)  # change region back
    support.check_plot(x)
    a.yticlabels('*')  # change y-labels attribute
    support.check_plot(x)

    x.scriptobject(a, 'test', 'a')  # append 'quick' to the existing file
    a.script('test.scr', 'w')  # save 'quick' as a VCS script file

    # get the list of templates
    objs = x.listelements('template')
    # 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 template not created")
    else:
        # get the list of templates
        a2 = x.listelements('template')
        if objs == a2:
            raise Exception("Error template not created or added to list")

    x.clear()  # clear the VCS Canvas
    x.boxfill(s, a, 'default', bg=bg)  # plot using default template
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    # plot using default template, but, reverse the order
    x.boxfill(a, 'default', s, bg=bg)
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.boxfill(s, a, t, bg=bg)  # plot using template 'test'
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    # plot using template 'test', but reverse the objects
    x.boxfill(a, s, t, bg=bg)
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    # plot using template 'test', but reverse the objects
    x.boxfill(t, a, s, bg=bg)
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas

    x.plot(t, a, s, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot(a, t, s, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot(s, t, a, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot('default', a, s, bg=bg)  # plot using the new way
    support.check_plot(x)
    x.clear()  # clear the VCS Canvas
    x.plot('default', s, bg=bg)  # plot using the new way
    support.check_plot(x)

    a = x.listelements('boxfill')  # show list of xyvsy
    r = x.createboxfill('test2', 'quick')  # create xyvsy 'test2'
    a2 = x.listelements('boxfill')  # 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('boxfill')  # show list of xyvsy
    if a3 != a:
        raise "error gm not removed"

    # get 'quick' boxfill graphics method
    a = x.getboxfill('quick')
    x.clear()
    x.plot(s, a, bg=bg)
    support.check_plot(x)
    if support.dogui:
        x.graphicsmethodgui('boxfill',
                            'quick')  # display the boxfill graphics method GUI
        raw_input("Press enter when done with gui testing")
    print '*************************************************************************************'
    print '******                                                                         ******'
    print '******   B O X F I L L   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 '*************************************************************************************'
Example #11
0
 def color_2(self, c):
     if vcs.isboxfill(self._gm):
         if self._gm.fillareacolors:
             self._gm.fillareacolors = None
         self._gm.color_2 = c
Example #12
0
 def color_2(self):
     """Used for boxfills only."""
     if vcs.isboxfill(self._gm):
         return self._gm.color_2
     else:
         return None
Example #13
0
 def labels(self):
     if self._gm.legend is None:
         if vcs.isboxfill(self._gm):
             return self._gm.autolabels(self._var)
     return self._gm.legend