From a07d3c4cd485d99a180161f849317acac2a899e1 Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Fri, 11 Sep 2015 13:09:51 -0700
Subject: [PATCH 01/68] Display plots are now preserved, instead of constantly
 being thrown out

---
 Packages/vcs/Lib/Canvas.py   | 29 +++++++++++++++++++++--------
 Packages/vcs/Lib/VTKPlots.py |  8 ++++----
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/Packages/vcs/Lib/Canvas.py b/Packages/vcs/Lib/Canvas.py
index 7f066aec8..cf4edd2d4 100644
--- a/Packages/vcs/Lib/Canvas.py
+++ b/Packages/vcs/Lib/Canvas.py
@@ -2374,7 +2374,7 @@ Options:::
                        'xbounds', 'ybounds', 'xname', 'yname', 'xunits', 'yunits', 'xweights', 'yweights',
                        'comment1', 'comment2', 'comment3', 'comment4', 'hms', 'long_name', 'zaxis',
                        'zarray', 'zname', 'zunits', 'taxis', 'tarray', 'tname', 'tunits', 'waxis', 'warray',
-                       'wname', 'wunits', 'bg', 'ratio', 'donotstoredisplay', 'render']
+                       'wname', 'wunits', 'bg', 'ratio', 'donotstoredisplay', 'render', "display_name"]
 
     # def replot(self):
     #    """ Clears and plots with last used plot arguments
@@ -3584,14 +3584,18 @@ Options:::
                     "unknown taylordiagram graphic method: %s" %
                     arglist[4])
             t.plot(arglist[0], canvas=self, template=arglist[2], **keyargs)
-            nm, src = self.check_name_source(None, "default", "display")
-            dn = displayplot.Dp(nm)
+
+            dname = keyargs.get("display_name")
+            if dname is not None:
+                dn = vcs.elements["display"][dname]
+            else:
+                nm, src = self.check_name_source(None, "default", "display")
+                dn = displayplot.Dp(nm)
             dn.template = arglist[2]
             dn.g_type = arglist[3]
             dn.g_name = arglist[4]
             dn.array = arglist[:2]
             dn.extradisplays = t.displays
-# dn.array=arglist[0]
             for p in slab_changed_attributes.keys():
                 tmp = slab_changed_attributes[p]
                 if tmp == (None, None):
@@ -3838,9 +3842,13 @@ Options:::
             else:
                 returned_kargs = self.backend.plot(*arglist, **keyargs)
                 if not keyargs.get("donotstoredisplay", False):
-                    nm, src = self.check_name_source(
-                        None, "default", "display")
-                    dn = displayplot.Dp(nm)
+                    dname = keyargs.get("display_name")
+                    if dname is not None:
+                        dn = vcs.elements['display'][dname]
+                    else:
+                        nm, src = self.check_name_source(
+                            None, "default", "display")
+                        dn = displayplot.Dp(nm)
                     dn.template = arglist[2]
                     dn.g_type = arglist[3]
                     dn.g_name = arglist[4]
@@ -3990,6 +3998,10 @@ Options:::
             self.configurator.stop_animating()
         self.animate_info = []
         self.animate.update_animate_display_list()
+
+        preserve_display = kargs.get("preserve_display", False)
+        if "preserve_display" in kargs:
+            del kargs["preserve_display"]
         self.backend.clear(*args, **kargs)
         for nm in self.display_names:
             # Lets look at elements created by dispaly production
@@ -4004,7 +4016,8 @@ Options:::
                     for k in new_elts[e]:
                         if k in vcs.elements[e].keys():
                             del(vcs.elements[e][k])
-            del(vcs.elements["display"][nm])
+            if not preserve_display:
+                del(vcs.elements["display"][nm])
         self.display_names = []
         return
 
diff --git a/Packages/vcs/Lib/VTKPlots.py b/Packages/vcs/Lib/VTKPlots.py
index eb923f0c4..db6f45d97 100644
--- a/Packages/vcs/Lib/VTKPlots.py
+++ b/Packages/vcs/Lib/VTKPlots.py
@@ -232,15 +232,15 @@ class VTKVCSBackend(object):
             parg.append(d.g_type)
             parg.append(d.g_name)
             plots_args.append(parg)
+            key = {"display_name": dnm}
             if d.ratio is not None:
-                key_args.append({"ratio": d.ratio})
-            else:
-                key_args.append({})
+                key["ratio"] = d.ratio
+            key_args.append(key)
 
         # Have to pull out the UI layer so it doesn't get borked by the clear
         self.hideGUI()
 
-        self.canvas.clear(render=False)
+        self.canvas.clear(render=False, preserve_display=True)
 
         for i, pargs in enumerate(plots_args):
             self.canvas.plot(*pargs, render=False, **key_args[i])
-- 
GitLab


From 1bb3806f83652635c3f8e44be937721ae1c22463 Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Fri, 25 Mar 2016 15:26:31 -0700
Subject: [PATCH 02/68] Fixes #1894

---
 Packages/vcs/Lib/vcsvtk/boxfillpipeline.py |  4 ++--
 Packages/vcs/Lib/vcsvtk/isofillpipeline.py | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
index 64ad4f00c..54d9b8a60 100644
--- a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
+++ b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
@@ -52,7 +52,7 @@ class BoxfillPipeline(Pipeline2D):
         if numpy.allclose(self._gm.level_1, 1.e20) or \
            numpy.allclose(self._gm.level_2, 1.e20):
             self._contourLevels = vcs.mkscale(self._scalarRange[0],
-                                              self._scalarRange[1])
+                                              self._scalarRange[1], nc=min(nlev, 12))
             if len(self._contourLevels) == 1:  # constant value ?
                 self._contourLevels = [self._contourLevels[0],
                                        self._contourLevels[0] + .00001]
@@ -282,7 +282,7 @@ class BoxfillPipeline(Pipeline2D):
 
         # Colortable bit
         # make sure length match
-        numLevels = len(self._contourLevels)
+        numLevels = len(self._contourLevels) - 1
         while len(self._contourColors) < numLevels:
             self._contourColors.append(self._contourColors[-1])
 
diff --git a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py
index 59b31272a..28c7ee469 100644
--- a/Packages/vcs/Lib/vcsvtk/isofillpipeline.py
+++ b/Packages/vcs/Lib/vcsvtk/isofillpipeline.py
@@ -46,11 +46,11 @@ class IsofillPipeline(Pipeline2D):
     def _plotInternal(self):
         """Overrides baseclass implementation."""
 
-        prepedContours = self._prepContours()
-        tmpLevels = prepedContours["tmpLevels"]
-        tmpIndices = prepedContours["tmpIndices"]
-        tmpColors = prepedContours["tmpColors"]
-        tmpOpacities = prepedContours["tmpOpacities"]
+        preppedCountours = self._prepContours()
+        tmpLevels = preppedCountours["tmpLevels"]
+        tmpIndices = preppedCountours["tmpIndices"]
+        tmpColors = preppedCountours["tmpColors"]
+        tmpOpacities = preppedCountours["tmpOpacities"]
         style = self._gm.fillareastyle
 
         luts = []
-- 
GitLab


From eb791bcfb6cfb01bb44f83a916ecd0da659fa862 Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Tue, 5 Apr 2016 09:37:12 -0700
Subject: [PATCH 03/68] fix #1907

---
 CMake/cdat_modules/docutils_external.cmake               | 2 +-
 CMake/cdat_modules/gdal_external.cmake                   | 4 +++-
 CMake/cdat_modules/spyder_external.cmake                 | 2 +-
 CMake/cdat_modules_extra/cdatmpi_configure_step.cmake.in | 1 +
 CMake/cmake_modules/pipinstaller.cmake                   | 2 ++
 5 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/CMake/cdat_modules/docutils_external.cmake b/CMake/cdat_modules/docutils_external.cmake
index ae62d3b59..8e419bd00 100644
--- a/CMake/cdat_modules/docutils_external.cmake
+++ b/CMake/cdat_modules/docutils_external.cmake
@@ -2,5 +2,5 @@
 # and configure and build it
 
 set(nm docutils)
-
+set(OLD "")
 include(pipinstaller)
diff --git a/CMake/cdat_modules/gdal_external.cmake b/CMake/cdat_modules/gdal_external.cmake
index 6efa6ae11..33e4c8e60 100644
--- a/CMake/cdat_modules/gdal_external.cmake
+++ b/CMake/cdat_modules/gdal_external.cmake
@@ -17,7 +17,9 @@ ExternalProject_Add(gdal
   URL_MD5 ${GDAL_MD5}
   BUILD_IN_SOURCE 1
   PATCH_COMMAND ""
-  CONFIGURE_COMMAND sh configure --prefix=${cdat_EXTERNALS} --with-hdf5=${cdat_EXTERNALS} --with-netcdf=${cdat_EXTERNALS} --with-curl=${cdat_EXTERNALS} --with-geos=${cdat_EXTERNALS}/bin/geos-config --with-python=${PYTHON_EXECUTABLE} --with-jpeg=no --with-libtiff=internal --without-jpeg12 --with-geotiff=internal
+  CONFIGURE_COMMAND ${CMAKE_COMMAND} -DINSTALL_DIR=<INSTALL_DIR> -DWORKING_DIR=<SOURCE_DIR> -DCONFIGURE_ARGS=${gdal_configure_args} -P ${cdat_CMAKE_BINARY_DIR}/${configure_file}
+  BUILD_COMMAND ${CMAKE_COMMAND} -Dmake=$(MAKE) -DWORKING_DIR=<SOURCE_DIR> -P ${cdat_CMAKE_BINARY_DIR}/cdat_make_step.cmake
+  INSTALL_COMMAND ${CMAKE_COMMAND} -DWORKING_DIR=<SOURCE_DIR> -P ${cdat_CMAKE_BINARY_DIR}/cdat_install_step.cmake
   DEPENDS "${gdal_deps}"
   ${ep_log_options}
 )
diff --git a/CMake/cdat_modules/spyder_external.cmake b/CMake/cdat_modules/spyder_external.cmake
index 2f1b6631b..ef88a8338 100644
--- a/CMake/cdat_modules/spyder_external.cmake
+++ b/CMake/cdat_modules/spyder_external.cmake
@@ -2,6 +2,6 @@
 # and configure and build it
 
 set (nm spyder)
-
+set(OLD "")
 include(pipinstaller)
 
diff --git a/CMake/cdat_modules_extra/cdatmpi_configure_step.cmake.in b/CMake/cdat_modules_extra/cdatmpi_configure_step.cmake.in
index 826b0e209..b8dd0172d 100644
--- a/CMake/cdat_modules_extra/cdatmpi_configure_step.cmake.in
+++ b/CMake/cdat_modules_extra/cdatmpi_configure_step.cmake.in
@@ -4,6 +4,7 @@ set(ENV{PKG_CONFIG} "@cdat_PKG_CONFIG_EXECUTABLE@")
 include(@cdat_CMAKE_BINARY_DIR@/cdat_common_environment.cmake)
 
 set(ENV{CC} mpicc)
+set(ENV{CXX} mpicxx)
 
 message("CONFIGURE_ARGS IS ${CONFIGURE_ARGS}")
 message("LD_ARGS IS $ENV{@LIBRARY_PATH@}")
diff --git a/CMake/cmake_modules/pipinstaller.cmake b/CMake/cmake_modules/pipinstaller.cmake
index 09b797908..1060a0ca1 100644
--- a/CMake/cmake_modules/pipinstaller.cmake
+++ b/CMake/cmake_modules/pipinstaller.cmake
@@ -49,3 +49,5 @@ unset(GIT_CMD_STR )
 unset(USR_ENVS)
 unset(USER_BUILD_EXT_OPTS)
 unset(USER_INSTALL_OPTIONS)
+unset(OLDSTR)
+unset(OLD)
-- 
GitLab


From 89a2ec9489a6f70ad5c9ef5ad6ddd0c0cede44ed Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Wed, 6 Apr 2016 10:59:41 -0700
Subject: [PATCH 04/68] Made change to make labels better match levels, added
 precision-based rounding to labels

---
 Packages/vcs/Lib/utils.py                    | 51 ++++++++++++++------
 Packages/vcs/Lib/vcsvtk/boxfillpipeline.py   | 12 +++--
 testing/vcs/CMakeLists.txt                   |  6 ++-
 testing/vcs/test_fewer_colors_than_levels.py | 29 +++++++++++
 4 files changed, 76 insertions(+), 22 deletions(-)
 create mode 100644 testing/vcs/test_fewer_colors_than_levels.py

diff --git a/Packages/vcs/Lib/utils.py b/Packages/vcs/Lib/utils.py
index 2323200ae..91c2acc2d 100644
--- a/Packages/vcs/Lib/utils.py
+++ b/Packages/vcs/Lib/utils.py
@@ -937,7 +937,24 @@ def __split2contiguous(levels):
     return tmplevs
 
 
-def mklabels(vals, output='dict'):
+def guess_precision(num):
+    """
+    Rough guesstimate of the precision of a number. Don't use this for actual science.
+    """
+    if num == 0:
+        return 1
+    idigleft = int(float(numpy.ma.floor(numpy.ma.log10(num)))) + 1
+    aa = numpy.ma.power(10., -idigleft)
+
+    while abs(round(aa * num) - aa * num) > .000001:
+        aa = aa * 10.
+
+    total_digits = numpy.ma.floor(numpy.ma.log10(aa * numpy.ma.power(10., idigleft)))
+
+    return max(total_digits, idigleft)
+
+
+def mklabels(vals, output='dict', precision=None):
     '''
     Function : mklabels
 
@@ -957,6 +974,11 @@ def mklabels(vals, output='dict'):
     {2.0000000000000002e-05: '2E-5', 5.0000000000000002e-05: '5E-5'}
     >>> vcs.mklabels ( [.00002,.00005],output='list')
     ['2E-5', '5E-5']
+    >>> a = vcs.mkevenlevels(0, 100, nlev=9)
+    >>> vcs.mklabels(a)
+    {0.0: '  0.000000000000000', 11.11111111111111: ' 11.111111111111111', 22.22222222222222: ' 22.222222222222221', 33.33333333333333: ' 33.333333333333329', 44.44444444444444: ' 44.444444444444443', 55.55555555555556: ' 55.555555555555557', 66.66666666666666: ' 66.666666666666657', 77.77777777777777: ' 77.777777777777771', 88.88888888888889: ' 88.888888888888886', 100.0: '100.000000000000000'}
+    >>> vcs.mklabels(a, precision=4)
+    {0.0: '  0.0', 11.11111111111111: ' 11.1', 22.22222222222222: ' 22.2', 33.33333333333333: ' 33.3', 44.44444444444444: ' 44.4', 55.55555555555556: ' 55.6', 66.66666666666666: ' 66.7', 77.77777777777777: ' 77.8', 88.88888888888889: ' 88.9', 100.0: '100.0'}
     '''
     import string
     import numpy.ma
@@ -995,21 +1017,18 @@ def mklabels(vals, output='dict'):
         amax = float(numpy.ma.maximum(vals))
     #  Number of digit on the left of decimal point
     idigleft = int(numpy.ma.floor(numpy.ma.log10(amax))) + 1
-    # Now determine the number of significant figures
-    idig = 0
-    for i in range(nvals):
-        aa = numpy.ma.power(10., -idigleft)
-        while abs(round(aa * vals[i]) - aa * vals[i]) > .000001:
-            aa = aa * 10.
-        idig = numpy.ma.maximum(
-            idig,
-            numpy.ma.floor(
-                numpy.ma.log10(
-                    aa *
-                    numpy.ma.power(
-                        10.,
-                        idigleft))))
-    idig = int(idig)
+
+    if precision is None:
+        # Now determine the number of significant figures
+        idig = 0
+        for i in range(nvals):
+            aa = numpy.ma.power(10., -idigleft)
+            while abs(round(aa * vals[i]) - aa * vals[i]) > .000001:
+                aa = aa * 10.
+            idig = numpy.ma.maximum(idig, numpy.ma.floor(numpy.ma.log10(aa * numpy.ma.power(10., idigleft))))
+        idig = int(idig)
+    else:
+        idig = int(precision)
     # Now does the writing part
     lbls = []
     # First if we need an E format
diff --git a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
index 54d9b8a60..98f61794e 100644
--- a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
+++ b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
@@ -51,12 +51,13 @@ class BoxfillPipeline(Pipeline2D):
         nlev = (self._gm.color_2 - self._gm.color_1) + 1
         if numpy.allclose(self._gm.level_1, 1.e20) or \
            numpy.allclose(self._gm.level_2, 1.e20):
-            self._contourLevels = vcs.mkscale(self._scalarRange[0],
-                                              self._scalarRange[1], nc=min(nlev, 12))
+            self._contourLevels = vcs.mkevenlevels(self._scalarRange[0],
+                                              self._scalarRange[1], nlev=min(nlev, 12))
             if len(self._contourLevels) == 1:  # constant value ?
-                self._contourLevels = [self._contourLevels[0],
-                                       self._contourLevels[0] + .00001]
-            self._contourLabels = vcs.mklabels(self._contourLevels)
+                self._contourLevels = [self._contourLevels[0], self._contourLevels[0] + .00001]
+
+            max_precision = max(vcs.guess_precision(self._contourLevels[0]), vcs.guess_precision(self._contourLevels[-1]))
+            self._contourLabels = vcs.mklabels(self._contourLevels, precision=max_precision)
             dx = (self._contourLevels[-1] - self._contourLevels[0]) / nlev
             self._contourLevels = numpy.arange(self._contourLevels[0],
                                                self._contourLevels[-1] + dx,
@@ -282,6 +283,7 @@ class BoxfillPipeline(Pipeline2D):
 
         # Colortable bit
         # make sure length match
+        print self._contourLevels
         numLevels = len(self._contourLevels) - 1
         while len(self._contourColors) < numLevels:
             self._contourColors.append(self._contourColors[-1])
diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index 69df44d3e..2bb2cde28 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -928,7 +928,11 @@ cdat_add_test(vcs_test_configurator_resize
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_configurator_resize.py
   ${BASELINE_DIR}/test_vcs_configurator_resize.png
 )
-
+cdat_add_test(vcs_test_fewer_colors_than_levels
+  "${PYTHON_EXECUTABLE}"
+  ${cdat_SOURCE_DIR}/testing/vcs/test_fewer_colors_than_levels.py
+  ${BASELINE_DIR}/test_fewer_colors_than_levels.png
+)
 cdat_add_test(vcs_test_colorpicker_appearance
   "${PYTHON_EXECUTABLE}"
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_colorpicker_appearance.py
diff --git a/testing/vcs/test_fewer_colors_than_levels.py b/testing/vcs/test_fewer_colors_than_levels.py
new file mode 100644
index 000000000..2779d4b6d
--- /dev/null
+++ b/testing/vcs/test_fewer_colors_than_levels.py
@@ -0,0 +1,29 @@
+import vcs,cdms2,sys,os
+
+baselineImage = sys.argv[1]
+
+pth = os.path.join(os.path.dirname(__file__),"..")
+sys.path.append(pth)
+import checkimage
+
+dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+data = dataset("clt")
+
+canvas = vcs.init()
+canvas.setantialiasing(0)
+canvas.setbgoutputdimensions(1200, 1091, units="pixels")
+canvas.drawlogooff()
+
+boxfill = canvas.createboxfill()
+
+boxfill.color_1 = 242
+boxfill.color_2 = 250
+
+canvas.plot(data, boxfill, bg=1)
+
+testImage = os.path.abspath("test_fewer_colors_than_levels.png")
+canvas.png(testImage)
+
+ret = checkimage.check_result_image(testImage, baselineImage, checkimage.defaultThreshold)
+
+sys.exit(ret)
-- 
GitLab


From a75310d17ac964828703dcf63635b9812c5bb75d Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Wed, 6 Apr 2016 11:34:34 -0700
Subject: [PATCH 05/68] Update spyder_external.cmake

---
 CMake/cdat_modules/spyder_external.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMake/cdat_modules/spyder_external.cmake b/CMake/cdat_modules/spyder_external.cmake
index ef88a8338..dede73c00 100644
--- a/CMake/cdat_modules/spyder_external.cmake
+++ b/CMake/cdat_modules/spyder_external.cmake
@@ -2,6 +2,6 @@
 # and configure and build it
 
 set (nm spyder)
-set(OLD "")
+set(OLD "OFF")
 include(pipinstaller)
 
-- 
GitLab


From ad2fe28dafab39e92273010beeeb0766c73337d2 Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Wed, 6 Apr 2016 11:34:58 -0700
Subject: [PATCH 06/68] Update docutils_external.cmake

---
 CMake/cdat_modules/docutils_external.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CMake/cdat_modules/docutils_external.cmake b/CMake/cdat_modules/docutils_external.cmake
index 8e419bd00..36bdaedb1 100644
--- a/CMake/cdat_modules/docutils_external.cmake
+++ b/CMake/cdat_modules/docutils_external.cmake
@@ -2,5 +2,5 @@
 # and configure and build it
 
 set(nm docutils)
-set(OLD "")
+set(OLD "OFF")
 include(pipinstaller)
-- 
GitLab


From 6c7b637eff5f87bba2544f332642c4de30cdafd9 Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Tue, 12 Apr 2016 15:13:32 -0700
Subject: [PATCH 07/68] Added documentation of plot args, deprecated some old
 ones, removed broken ones

---
 Packages/vcs/vcs/Canvas.py | 51 ++++++++++++++++----------------------
 1 file changed, 21 insertions(+), 30 deletions(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 1032dba3c..25f8e731d 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -2264,13 +2264,13 @@ Options:::
     # Set alias for the secondary drawtextcombined.
     drawtext = drawtextcombined
 
-    _plot_keywords_ = ['variable', 'grid', 'xaxis', 'yaxis', 'xrev', 'yrev', 'continents', 'xarray', 'yarray',
-                       'name', 'time', 'units', 'ymd', 'file_comment',
-                       'xbounds', 'ybounds', 'xname', 'yname', 'xunits', 'yunits', 'xweights', 'yweights',
-                       'comment1', 'comment2', 'comment3', 'comment4', 'hms', 'long_name', 'zaxis',
-                       'zarray', 'zname', 'zunits', 'taxis', 'tarray', 'tname', 'tunits', 'waxis', 'warray',
-                       'wname', 'wunits', 'bg', 'ratio', 'donotstoredisplay', 'render', 'continents_line', "display_name"]
+    _plot_keywords_ = ['variable', 'grid', 'xaxis', 'xarray',  'xrev', 'yaxis', 'yarray', 'yrev', 'continents',
+                       'xbounds', 'ybounds', 'zaxis', 'zarray', 'taxis', 'tarray', 'waxis', 'warray', 'bg', 'ratio',
+                       'donotstoredisplay', 'render', 'continents_line', "display_name"]
 
+    _deprecated_plot_keywords_ = ["time", "units", "file_comment", "xname", "yname", "zname", "tname", "wname",
+                                  "xunits", "yunits", "zunits", "tunits", "wunits", "comment1", "comment2", "comment3",
+                                  "comment4", "long_name"]
     # def replot(self):
     #    """ Clears and plots with last used plot arguments
     #    """
@@ -2317,28 +2317,10 @@ Options:::
             '3',3: y dim will be 3 times bigger than x dim (restricted to original tempalte.data area
             Adding a 't' at the end of the ratio, makes the tickmarks and boxes move along.
 
-    Variable attribute keys:
-       comment1         = string   #Comment plotted above file_comment
-       comment2         = string   #Comment plotted above comment1
-       comment3         = string   #Comment plotted above comment2
-       comment4         = string   #Comment plotted above comment4
-       file_comment     = string   #Comment (defaults to file.comment)
-       hms              = string (hh:mm:ss) #Hour, minute, second
-       long_name        = string   #Descriptive variable name
-       name             = string   #Variable name (defaults to var.id)
-       time             = cdtime   #instance (relative or absolute),
-                                    cdtime, reltime or abstime value
-       units            = string   #Variable units
-       ymd              = string (yy/mm/dd) #Year, month, day
-
     Dimension attribute keys (dimension length=n):
        [x|y|z|t|w]array = NumPy array of length n    # x or y Dimension values
        [x|y|z|t|w]array = NumPy array of length n    # x or y Dimension values
        [x|y]bounds       = NumPy array of shape (n,2) # x or y Dimension boundaries
-       [x|y|z|t|w]name   = string                     # x or y Dimension name
-       [x|y|z|t|w]units  = string                     # x or y Dimension units
-       [x|y]weights      = NumPy array of length n    # x or y Dimension weights (used to
-                                                        calculate area-weighted mean)
 
     CDMS object:
        [x|y|z|t|w]axis   = CDMS axis object           # x or y Axis
@@ -2365,7 +2347,13 @@ Options:::
                                                       # Values 6 through 11 signify the line type
                                                       # defined by the files data_continent_other7
                                                       # through data_continent_other12.
-
+        continents_line = vcs.getline("default")    # VCS line object to define continent appearance
+        donotstoredisplay = True|False              # Whether the displayplot object generated by this plot are stored
+        render = True|False                         # Whether to actually render the plot or not (useful for doing a
+                                                    # bunch of plots in a row)
+        display_name = "__display_123"                # VCS Display plot name (used to prevent duplicate display plots)
+        ratio = 1.5|"autot"|"auto"                   # Ratio of height/width for the plot; autot and auto will choose a
+                                                    # "good" ratio for you.
     Graphics Output in Background Mode:
        bg                 = 0|1   # if ==1, create images in the background
                                                              (Don't display the VCS Canvas)
@@ -3526,11 +3514,14 @@ Options:::
                     doratio == "0" or doratio[:4] == "auto"):
                 doratio = "1t"
             for keyarg in keyargs.keys():
-                if keyarg not in self.__class__._plot_keywords_ + \
-                        self.backend._plot_keywords:
-                    warnings.warn(
-                        'Unrecognized vcs plot keyword: %s, assuming backend (%s) keyword' %
-                        (keyarg, self.backend.type))
+                if keyarg not in self.__class__._plot_keywords_ + self.backend._plot_keywords:
+                    if keyarg in self.__class__._deprecated_plot_keywords_:
+                        warnings.warn("Deprecation Warning: Keyword '%s' will be removed in the next version"
+                                      "of UV-CDAT." % keyarg)
+                    else:
+                        warnings.warn(
+                            'Unrecognized vcs plot keyword: %s, assuming backend (%s) keyword' %
+                            (keyarg, self.backend.type))
 
             if arglist[0] is not None or 'variable' in keyargs:
                 arglist[0] = self._reconstruct_tv(arglist, keyargs)
-- 
GitLab


From a82437bfa57add72c02fce63ad3c3224c67d7e3a Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Tue, 12 Apr 2016 15:15:40 -0700
Subject: [PATCH 08/68] Added documentation to clear's preserve_display arg

---
 Packages/vcs/vcs/Canvas.py   | 3 +++
 Packages/vcs/vcs/VTKPlots.py | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 25f8e731d..bd8c82310 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -3891,6 +3891,9 @@ Options:::
     a.plot(array,'default','isofill','quick')
     a.clear()
 
+  Internally, update() calls clear() to assist in removing plots. The preserve_display argument is used to
+  make sure that the display plots that are associated with the current canvas are not eliminated, and
+  are still able to be used to regenerate the plots.
 """
         if self.animate.created():
             self.animate.close()
diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index d4a8241fa..4d870cd15 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -306,7 +306,7 @@ class VTKVCSBackend(object):
             key["continents_line"] = d.continents_line
             key_args.append(key)
 
-        # Have to pull out the UI layer so it doesn't get borked by the clear
+        # Have to pull out the UI layer so it doesn't get borked by the z
         self.hideGUI()
 
         if self.canvas.configurator is not None:
-- 
GitLab


From 88d77458579cf71437f4808b26547d1aa6dbda03 Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Fri, 15 Apr 2016 11:37:57 -0700
Subject: [PATCH 09/68] Fix bug in template's drawColorBox function that could
 prevent some labels from being drawn

---
 Packages/vcs/Lib/template.py | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/Packages/vcs/Lib/template.py b/Packages/vcs/Lib/template.py
index 7d5869eee..2fd255525 100644
--- a/Packages/vcs/Lib/template.py
+++ b/Packages/vcs/Lib/template.py
@@ -1844,7 +1844,7 @@ class P(object):
                    startlong])
         # Now make sure we have a legend
         if isinstance(levels[0], list):
-            # Ok these are nono contiguous levels, we will use legend only if
+            # Ok these are non-contiguous levels, we will use legend only if
             # it's a perfect match
             for i, l in enumerate(levels):
                 lt = l[0]
@@ -1869,29 +1869,30 @@ class P(object):
         else:
             if legend is None:
                 legend = vcs.mklabels(levels)
+            float_epsilon = numpy.finfo(float).eps
             if levels[0] < levels[1]:
-                ecompfunc = numpy.less_equal
-                compfunc = numpy.less
+                ecompfunc = lambda x, y: float_epsilon > x - y
+                compfunc = lambda x, y: -float_epsilon > x - y
             else:
-                ecompfunc = numpy.greater_equal
-                compfunc = numpy.greater
+                ecompfunc = lambda x, y: -float_epsilon < x - y
+                compfunc = lambda x, y: float_epsilon < x - y
             dlong = dD / (len(levels) - 1)
+
             for l in legend.keys():
+                # if legend key is between levels[0] and levels[-1]
                 if not compfunc(l, levels[0]) and not compfunc(levels[-1], l):
                     for i in range(len(levels) - 1):
-                        if ecompfunc(levels[i], l) and ecompfunc(
-                                l, levels[i + 1]):
-                            # Ok we're between 2 levels, let's add the legend
-                            # first let's figure out where to put it
-                            loc = i * dlong  # position at beginnig of level
-                            # Adds the distance from beginnig of level box
-                            loc += (l - levels[i]) / \
-                                (levels[i + 1] - levels[i]) * dlong
-                            loc += startlong  # Figures out the begining
-    # loc=((l-levels[0])/(levels[-1]-levels[0]))*dD+startlong
-                            Ll.append([loc, loc])
+                        # if legend key is (inclusive) between levels[i] and levels[i+1]
+                        if ecompfunc(levels[i], l) and ecompfunc(l, levels[i + 1]):
+                            # first let's figure out where to put the legend label
+                            location = i * dlong  # position at beginning of level
+                            # Adds the distance from beginning of level box
+                            location += (l - levels[i]) / (levels[i + 1] - levels[i]) * dlong
+                            location += startlong  # Figures out the beginning
+
+                            Ll.append([location, location])
                             Sl.append([startshrt, startshrt + dshrt])
-                            Lt.append(loc)
+                            Lt.append(location)
                             St.append(startshrt + dshrt * 1.4)
                             Tt.append(legend[l])
                             break
-- 
GitLab


From 5ab070a1b4b68eb7ccd94808638b1bfd7ed50784 Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Fri, 15 Apr 2016 11:38:36 -0700
Subject: [PATCH 10/68] Refactored legend/label logic to be in boxfill, fixed
 label generation, eliminated "guess_precision"

---
 Packages/vcs/Lib/boxfill.py                | 44 ++++++++++++++++++++
 Packages/vcs/Lib/utils.py                  | 44 +++++---------------
 Packages/vcs/Lib/vcsvtk/boxfillpipeline.py | 47 +---------------------
 3 files changed, 56 insertions(+), 79 deletions(-)

diff --git a/Packages/vcs/Lib/boxfill.py b/Packages/vcs/Lib/boxfill.py
index 231b22839..76de13e04 100755
--- a/Packages/vcs/Lib/boxfill.py
+++ b/Packages/vcs/Lib/boxfill.py
@@ -24,6 +24,7 @@ import vcs
 import cdtime
 import VCS_validation_functions
 import xmldocs
+import numpy
 import warnings
 
 
@@ -734,6 +735,49 @@ class Gfb(object):
         self.yaxisconvert = yat
     xyscale.__doc__ = xmldocs.xyscaledoc
 
+    def getlevels(self, varmin, varmax):
+        if self.boxfill_type == "custom":
+            return self.levels
+
+        if numpy.allclose(self.level_1, 1.e20) or \
+           numpy.allclose(self.level_2, 1.e20):
+            low_end = varmin
+            high_end = varmax
+        else:
+            low_end = self.level_1
+            high_end = self.level_2
+
+        if self.boxfill_type == "log10":
+            low_end = numpy.ma.log10(low_end)
+            high_end = numpy.ma.log10(high_end)
+
+        nlev = float(self.color_2 - self.color_1 + 1)
+        scale = vcs.mkscale(low_end, high_end)
+
+        low_end = scale[0]
+        high_end = scale[-1]
+
+        dx = (high_end - low_end) / nlev
+
+        contourLevels = numpy.arange(low_end, high_end + dx / 2., dx)
+        return contourLevels
+
+    def getlegendlabels(self, levels):
+        if self.legend:
+            return self.legend
+        nlev = self.color_2 - self.color_1 + 1
+        if nlev >= 12:
+            label_scale = vcs.mkscale(levels[0], levels[-1])
+            return vcs.mklabels(label_scale)
+        else:
+            # Need to line up the levels and the labels, so we'll massage the label positions
+            dx = levels[1] - levels[0]
+            # Determine what decimal place we should round the label to to "see a difference"
+            round_pos = -1 * int(numpy.ma.log10(dx))
+            round_values = [numpy.round(l, round_pos) for l in levels]
+            round_labels = vcs.mklabels(round_values, "list")
+            return {lev: label for lev, label in zip(levels, round_labels)}
+
     ###########################################################################
     #                                                                         #
     # List out boxfill graphics method members (attributes).                  #
diff --git a/Packages/vcs/Lib/utils.py b/Packages/vcs/Lib/utils.py
index 91c2acc2d..5550ae771 100644
--- a/Packages/vcs/Lib/utils.py
+++ b/Packages/vcs/Lib/utils.py
@@ -937,24 +937,7 @@ def __split2contiguous(levels):
     return tmplevs
 
 
-def guess_precision(num):
-    """
-    Rough guesstimate of the precision of a number. Don't use this for actual science.
-    """
-    if num == 0:
-        return 1
-    idigleft = int(float(numpy.ma.floor(numpy.ma.log10(num)))) + 1
-    aa = numpy.ma.power(10., -idigleft)
-
-    while abs(round(aa * num) - aa * num) > .000001:
-        aa = aa * 10.
-
-    total_digits = numpy.ma.floor(numpy.ma.log10(aa * numpy.ma.power(10., idigleft)))
-
-    return max(total_digits, idigleft)
-
-
-def mklabels(vals, output='dict', precision=None):
+def mklabels(vals, output='dict'):
     '''
     Function : mklabels
 
@@ -974,11 +957,6 @@ def mklabels(vals, output='dict', precision=None):
     {2.0000000000000002e-05: '2E-5', 5.0000000000000002e-05: '5E-5'}
     >>> vcs.mklabels ( [.00002,.00005],output='list')
     ['2E-5', '5E-5']
-    >>> a = vcs.mkevenlevels(0, 100, nlev=9)
-    >>> vcs.mklabels(a)
-    {0.0: '  0.000000000000000', 11.11111111111111: ' 11.111111111111111', 22.22222222222222: ' 22.222222222222221', 33.33333333333333: ' 33.333333333333329', 44.44444444444444: ' 44.444444444444443', 55.55555555555556: ' 55.555555555555557', 66.66666666666666: ' 66.666666666666657', 77.77777777777777: ' 77.777777777777771', 88.88888888888889: ' 88.888888888888886', 100.0: '100.000000000000000'}
-    >>> vcs.mklabels(a, precision=4)
-    {0.0: '  0.0', 11.11111111111111: ' 11.1', 22.22222222222222: ' 22.2', 33.33333333333333: ' 33.3', 44.44444444444444: ' 44.4', 55.55555555555556: ' 55.6', 66.66666666666666: ' 66.7', 77.77777777777777: ' 77.8', 88.88888888888889: ' 88.9', 100.0: '100.0'}
     '''
     import string
     import numpy.ma
@@ -1018,17 +996,15 @@ def mklabels(vals, output='dict', precision=None):
     #  Number of digit on the left of decimal point
     idigleft = int(numpy.ma.floor(numpy.ma.log10(amax))) + 1
 
-    if precision is None:
-        # Now determine the number of significant figures
-        idig = 0
-        for i in range(nvals):
-            aa = numpy.ma.power(10., -idigleft)
-            while abs(round(aa * vals[i]) - aa * vals[i]) > .000001:
-                aa = aa * 10.
-            idig = numpy.ma.maximum(idig, numpy.ma.floor(numpy.ma.log10(aa * numpy.ma.power(10., idigleft))))
-        idig = int(idig)
-    else:
-        idig = int(precision)
+    # Now determine the number of significant figures
+    idig = 0
+    for i in range(nvals):
+        aa = numpy.ma.power(10., -idigleft)
+        while abs(round(aa * vals[i]) - aa * vals[i]) > .000001:
+            aa = aa * 10.
+        idig = numpy.ma.maximum(idig, numpy.ma.floor(numpy.ma.log10(aa * numpy.ma.power(10., idigleft))))
+    idig = int(idig)
+
     # Now does the writing part
     lbls = []
     # First if we need an E format
diff --git a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
index 98f61794e..a27c724cc 100644
--- a/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
+++ b/Packages/vcs/Lib/vcsvtk/boxfillpipeline.py
@@ -47,50 +47,8 @@ class BoxfillPipeline(Pipeline2D):
 
     def _updateContourLevelsAndColorsForBoxfill(self):
         """Set contour information for a standard boxfill."""
-        # Compute levels
-        nlev = (self._gm.color_2 - self._gm.color_1) + 1
-        if numpy.allclose(self._gm.level_1, 1.e20) or \
-           numpy.allclose(self._gm.level_2, 1.e20):
-            self._contourLevels = vcs.mkevenlevels(self._scalarRange[0],
-                                              self._scalarRange[1], nlev=min(nlev, 12))
-            if len(self._contourLevels) == 1:  # constant value ?
-                self._contourLevels = [self._contourLevels[0], self._contourLevels[0] + .00001]
-
-            max_precision = max(vcs.guess_precision(self._contourLevels[0]), vcs.guess_precision(self._contourLevels[-1]))
-            self._contourLabels = vcs.mklabels(self._contourLevels, precision=max_precision)
-            dx = (self._contourLevels[-1] - self._contourLevels[0]) / nlev
-            self._contourLevels = numpy.arange(self._contourLevels[0],
-                                               self._contourLevels[-1] + dx,
-                                               dx)
-        else:
-            if self._gm.boxfill_type == "log10":
-                levslbls = vcs.mkscale(numpy.ma.log10(self._gm.level_1),
-                                       numpy.ma.log10(self._gm.level_2))
-                self._contourLevels = vcs.mkevenlevels(
-                    numpy.ma.log10(self._gm.level_1),
-                    numpy.ma.log10(self._gm.level_2), nlev=nlev)
-            else:
-                levslbls = vcs.mkscale(self._gm.level_1, self._gm.level_2)
-                self._contourLevels = vcs.mkevenlevels(self._gm.level_1,
-                                                       self._gm.level_2,
-                                                       nlev=nlev)
-            if len(self._contourLevels) > 25:
-                # Too many colors/levels need to prettyfy this for legend
-                self._contourLabels = vcs.mklabels(levslbls)
-                # Make sure extremes are in
-                legd2 = vcs.mklabels([self._contourLevels[0],
-                                      self._contourLevels[-1]])
-                self._contourLabels.update(legd2)
-            else:
-                self._contourLabels = vcs.mklabels(self._contourLevels)
-            if self._gm.boxfill_type == "log10":
-                logLabels = {}
-                for key in self._contourLabels.keys():
-                    value = self._contourLabels[key]
-                    newKey = float(numpy.ma.log10(value))
-                    logLabels[newKey] = value
-                self._contourLabels = logLabels
-
+        self._contourLevels = self._gm.getlevels(self._scalarRange[0], self._scalarRange[1])
+        self._contourLabels = self._gm.getlegendlabels(self._contourLevels)
         # Use consecutive colors:
         self._contourColors = range(self._gm.color_1, self._gm.color_2 + 1)
 
@@ -283,7 +241,6 @@ class BoxfillPipeline(Pipeline2D):
 
         # Colortable bit
         # make sure length match
-        print self._contourLevels
         numLevels = len(self._contourLevels) - 1
         while len(self._contourColors) < numLevels:
             self._contourColors.append(self._contourColors[-1])
-- 
GitLab


From 602bba871669b09b6e4622ea18d35baafa62ce42 Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Mon, 18 Apr 2016 15:00:09 -0700
Subject: [PATCH 11/68] Tweaks to get tests to pass

---
 Packages/vcs/vcs/boxfill.py  | 61 ++++++++++++++++++++++++++----------
 Packages/vcs/vcs/template.py | 18 ++++++-----
 2 files changed, 55 insertions(+), 24 deletions(-)

diff --git a/Packages/vcs/vcs/boxfill.py b/Packages/vcs/vcs/boxfill.py
index 76de13e04..e17145437 100755
--- a/Packages/vcs/vcs/boxfill.py
+++ b/Packages/vcs/vcs/boxfill.py
@@ -739,8 +739,12 @@ class Gfb(object):
         if self.boxfill_type == "custom":
             return self.levels
 
+        nlev = float(self.color_2 - self.color_1 + 1)
+        autolevels = False
+
         if numpy.allclose(self.level_1, 1.e20) or \
            numpy.allclose(self.level_2, 1.e20):
+            autolevels = True
             low_end = varmin
             high_end = varmax
         else:
@@ -751,32 +755,57 @@ class Gfb(object):
             low_end = numpy.ma.log10(low_end)
             high_end = numpy.ma.log10(high_end)
 
-        nlev = float(self.color_2 - self.color_1 + 1)
-        scale = vcs.mkscale(low_end, high_end)
 
-        low_end = scale[0]
-        high_end = scale[-1]
+        if autolevels:
+            # Use nice values for the scale
+            scale = vcs.mkscale(low_end, high_end)
+            low_end = scale[0]
+            high_end = scale[-1]
 
         dx = (high_end - low_end) / nlev
 
-        contourLevels = numpy.arange(low_end, high_end + dx / 2., dx)
+        if dx == 0:
+            high_end += .00001
+            return [low_end, high_end]
+
+        contourLevels = numpy.arange(low_end, high_end + dx, dx)
+
         return contourLevels
 
     def getlegendlabels(self, levels):
         if self.legend:
             return self.legend
-        nlev = self.color_2 - self.color_1 + 1
-        if nlev >= 12:
-            label_scale = vcs.mkscale(levels[0], levels[-1])
-            return vcs.mklabels(label_scale)
+
+        if numpy.allclose(self.level_1, 1.e20) or \
+           numpy.allclose(self.level_2, 1.e20):
+            autolevels = True
+        else:
+            autolevels = False
+
+        if len(levels) > 12:
+            scale = vcs.mkscale(levels[0], levels[-1])
+            if autolevels:
+                return vcs.mklabels(scale)
+            else:
+                # Create our own scale
+                dx = (self.level_2 - self.level_1) / float(len(scale))
+                real_values = [self.level_1, self.level_2]
+                levels = numpy.arange(levels[0], levels[-1] + dx, dx)
         else:
-            # Need to line up the levels and the labels, so we'll massage the label positions
-            dx = levels[1] - levels[0]
-            # Determine what decimal place we should round the label to to "see a difference"
-            round_pos = -1 * int(numpy.ma.log10(dx))
-            round_values = [numpy.round(l, round_pos) for l in levels]
-            round_labels = vcs.mklabels(round_values, "list")
-            return {lev: label for lev, label in zip(levels, round_labels)}
+            real_values = levels
+
+        # Need to line up the levels and the labels, so we'll massage the label positions
+        max_round = 0
+        for l in real_values:
+            round_pos = 0
+            while numpy.round(l, round_pos) != l:
+                round_pos += 1
+            max_round = max(max_round, round_pos)
+
+        round_values = [numpy.round(l, round_pos) for l in levels]
+        round_labels = vcs.mklabels(round_values, "list")
+
+        return {lev: label for lev, label in zip(levels, round_labels)}
 
     ###########################################################################
     #                                                                         #
diff --git a/Packages/vcs/vcs/template.py b/Packages/vcs/vcs/template.py
index cb1c0217f..3eaac046b 100644
--- a/Packages/vcs/vcs/template.py
+++ b/Packages/vcs/vcs/template.py
@@ -1873,21 +1873,23 @@ class P(object):
         else:
             if legend is None:
                 legend = vcs.mklabels(levels)
-            float_epsilon = numpy.finfo(float).eps
+            # We'll use the less precise float epsilon since this is just for labels
+            float_epsilon = numpy.finfo(numpy.float32).eps
             if levels[0] < levels[1]:
-                ecompfunc = lambda x, y: float_epsilon > x - y
-                compfunc = lambda x, y: -float_epsilon > x - y
+                # <=
+                comparison = lambda a, b: float_epsilon > a - b
             else:
-                ecompfunc = lambda x, y: -float_epsilon < x - y
-                compfunc = lambda x, y: float_epsilon < x - y
+                # >=
+                comparison = lambda a, b: -float_epsilon < a - b
+
+            in_bounds = lambda x: comparison(levels[0], x) and comparison(x, levels[-1])
             dlong = dD / (len(levels) - 1)
 
             for l in legend.keys():
-                # if legend key is between levels[0] and levels[-1]
-                if not compfunc(l, levels[0]) and not compfunc(levels[-1], l):
+                if in_bounds(l):
                     for i in range(len(levels) - 1):
                         # if legend key is (inclusive) between levels[i] and levels[i+1]
-                        if ecompfunc(levels[i], l) and ecompfunc(l, levels[i + 1]):
+                        if comparison(levels[i], l) and comparison(l, levels[i + 1]):
                             # first let's figure out where to put the legend label
                             location = i * dlong  # position at beginning of level
                             # Adds the distance from beginning of level box
-- 
GitLab


From de21dafb8092fb258f0053edd9b732e806ff213a Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Tue, 19 Apr 2016 13:20:50 -0700
Subject: [PATCH 12/68] readme edits

---
 README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index f79ed08fb..f1747bb98 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
 uvcdat
 ======
 [![build status](https://travis-ci.org/UV-CDAT/uvcdat.svg?branch=master)](https://travis-ci.org/UV-CDAT/uvcdat/builds)
-[![stable version](http://img.shields.io/badge/stable version-2.4.0-brightgreen.svg)](https://github.com/UV-CDAT/uvcdat/releases/tag/2.4.0)
+[![stable version](http://img.shields.io/badge/stable version-2.4.1-brightgreen.svg)](https://github.com/UV-CDAT/uvcdat/releases/tag/2.4.1)
 ![platforms](http://img.shields.io/badge/platforms-linux | osx-lightgrey.svg)
-[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.45136.svg)](http://dx.doi.org/10.5281/zenodo.45136)
+[![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.50101.svg)](http://dx.doi.org/10.5281/zenodo.50101)
 
 Developed by partnering with ESGF and the community to create a larger problem-solving environment, UV-CDAT is an open source, easy-to-use application that links together disparate software subsystems and packages to form an integrated environment for analysis and visualization. This project seeks to advance climate science by fulfilling computational and diagnostic/visualization capabilities needed for DOE's climate research.
 
@@ -13,4 +13,4 @@ Developing and Contributing
 ------
 We'd love to get contributions from you! Please take a look at the
 [Contribution Documents](CONTRIBUTING.md) to see how to get your changes merged
-in.
\ No newline at end of file
+in.
-- 
GitLab


From 585e4385fa2f517a580244b9cb3755b2ec8537ac Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Wed, 20 Apr 2016 16:31:34 -0400
Subject: [PATCH 13/68] Allow unicode strings for subsetting.

This is how they come from the web.
---
 Packages/cdms2/Lib/axis.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Packages/cdms2/Lib/axis.py b/Packages/cdms2/Lib/axis.py
index df2778854..703c0e938 100644
--- a/Packages/cdms2/Lib/axis.py
+++ b/Packages/cdms2/Lib/axis.py
@@ -2250,7 +2250,7 @@ def axisMatches(axis, specification):
 
        3. an axis object; will match if it is the same object as axis.
     """   
-    if isinstance(specification, types.StringType):
+    if isinstance(specification, basestring):
         s = string.lower(specification)
         s = s.strip()
         while s[0] == '(':
-- 
GitLab


From aa680fd6f24450f4157978745372cd266df839b0 Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Thu, 21 Apr 2016 22:45:35 -0700
Subject: [PATCH 14/68] Update README.md

Adding badges for Conda
---
 README.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/README.md b/README.md
index f1747bb98..5968858fe 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,9 @@ uvcdat
 ![platforms](http://img.shields.io/badge/platforms-linux | osx-lightgrey.svg)
 [![DOI](https://zenodo.org/badge/doi/10.5281/zenodo.50101.svg)](http://dx.doi.org/10.5281/zenodo.50101)
 
+[![Anaconda-Server Badge](https://anaconda.org/uvcdat/uvcdat/badges/installer/conda.svg)](https://conda.anaconda.org/uvcdat)
+[![Anaconda-Server Badge](https://anaconda.org/uvcdat/uvcdat/badges/downloads.svg)](https://anaconda.org/uvcdat/uvcdat)
+
 Developed by partnering with ESGF and the community to create a larger problem-solving environment, UV-CDAT is an open source, easy-to-use application that links together disparate software subsystems and packages to form an integrated environment for analysis and visualization. This project seeks to advance climate science by fulfilling computational and diagnostic/visualization capabilities needed for DOE's climate research.
 
 Led by Lawrence Livermore National Laboratory (LLNL), the consortium consists of four DOE laboratories (Los Alamos, Lawrence Berkeley, LLNL, and Oak Ridge), two universities (University of Utah and the Polytechnic Institute of New York University), NASA, and two private companies (Kitware and tech-X) that will develop reusable software and workflow analysis and visualization applications for large-scale DOE climate modeling and measurements archives. The UV-CDAT concept is simple and flexible enough to interchange parts to expand for future DOE activities.
-- 
GitLab


From 6e372a536414695f0ecf32c240374efb063d6d1e Mon Sep 17 00:00:00 2001
From: McEnerney <mcenerney1@llnl.gov>
Date: Mon, 25 Apr 2016 10:20:54 -0700
Subject: [PATCH 15/68] change diags test 01

---
 CMake/cdat_modules/uvcmetrics_pkg.cmake | 2 +-
 testing/metrics/diagtest01.py           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMake/cdat_modules/uvcmetrics_pkg.cmake b/CMake/cdat_modules/uvcmetrics_pkg.cmake
index 7024a9580..2f8294042 100644
--- a/CMake/cdat_modules/uvcmetrics_pkg.cmake
+++ b/CMake/cdat_modules/uvcmetrics_pkg.cmake
@@ -6,7 +6,7 @@ set(UVCMETRICS_ZIP uvcmetrics-${UVCMETRICS_VERSION}.zip)
 #set(UVCMETRICS_SOURCE ${UVCMETRICS_URL}/${UVCMETRICS_ZIP})
 set(UVCMETRICS_SOURCE ${GIT_PROTOCOL}github.com/UV-CDAT/uvcmetrics.git )
 set(UVCMETRICS_MD5)
-set(UVCMETRICS_BRANCH uvcdat-2.4.1)
+set(UVCMETRICS_BRANCH master)
 
 if (NOT CDAT_BUILD_LEAN)
   add_cdat_package(UVCMETRICS "" "" ON)
diff --git a/testing/metrics/diagtest01.py b/testing/metrics/diagtest01.py
index b8cf415f0..09197a1e3 100755
--- a/testing/metrics/diagtest01.py
+++ b/testing/metrics/diagtest01.py
@@ -58,7 +58,7 @@ varid = 'T'
 vard = package.all_variables( filetable1, filetable2, sname )
 var = vard[varid]
 
-plot = sclass( [filetable1], [filetable2], varid, seasonid )
+plot = sclass( [filetable1], [filetable2], varid, seasonid, plotparms = { 'model':{}, 'obs':{}, 'diff':{} } )
 res = plot.compute()
 if res is not None:
     if res.__class__.__name__ is 'uvc_composite_plotspec':
-- 
GitLab


From 0bc3f4d47b9c21175d4cfa651640f92a4c6215d2 Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Thu, 21 Apr 2016 11:52:28 -0400
Subject: [PATCH 16/68] ENH #1854: Tests will check for alternate baselines
 using basename_[1-9].ext

Previously the pattern used was baseline.*\.ext
---
 testing/checkimage.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testing/checkimage.py b/testing/checkimage.py
index e0ad9db82..9871f3557 100644
--- a/testing/checkimage.py
+++ b/testing/checkimage.py
@@ -9,6 +9,7 @@ import numpy
 import vtk
 import os
 import os.path
+import re
 import sys
 import logging
 
@@ -40,13 +41,15 @@ def image_from_file(fname):
         print "Problem opening file '%s': %s"%(fname,err)
         return None
 
+# find alternate baselines for fname of the form basename_d.ext
+# where fname = basename.ext and d is a digit between 1 and 9
 def find_alternates(fname):
     dirname = os.path.dirname(fname)
     prefix, ext = os.path.splitext(os.path.split(fname)[1])
     files = os.listdir(dirname)
     results = [fname]
     for i in files:
-        if i.startswith(prefix) and i.endswith(ext) and i != prefix+ext:
+        if (re.match(prefix + '_[1-9]' + ext, i)):
             results.append(os.path.join(dirname, i))
     return results
 
-- 
GitLab


From 2bc8a27233063bbca4c0c5ec23d8e3a4894cfd19 Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Tue, 26 Apr 2016 14:34:37 -0700
Subject: [PATCH 17/68] moved cdscan to lib dir so that we can import it

---
 Packages/cdms2/{Script/cdscan => Lib/cdscan.py} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Packages/cdms2/{Script/cdscan => Lib/cdscan.py} (100%)

diff --git a/Packages/cdms2/Script/cdscan b/Packages/cdms2/Lib/cdscan.py
similarity index 100%
rename from Packages/cdms2/Script/cdscan
rename to Packages/cdms2/Lib/cdscan.py
-- 
GitLab


From 50a55c122e0509915a91a7b525359dffc9475ba5 Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Tue, 26 Apr 2016 14:37:29 -0700
Subject: [PATCH 18/68] symlinked cdscan so that script is still installed

---
 Packages/cdms2/Script/cdscan | 1 +
 1 file changed, 1 insertion(+)
 create mode 120000 Packages/cdms2/Script/cdscan

diff --git a/Packages/cdms2/Script/cdscan b/Packages/cdms2/Script/cdscan
new file mode 120000
index 000000000..11d1e0bf9
--- /dev/null
+++ b/Packages/cdms2/Script/cdscan
@@ -0,0 +1 @@
+../Lib/cdscan.py
\ No newline at end of file
-- 
GitLab


From 995fa79e87d50986eb3bc5a976d0c47d3186239a Mon Sep 17 00:00:00 2001
From: Sam Fries <samuelbfries@gmail.com>
Date: Thu, 28 Apr 2016 10:08:15 -0700
Subject: [PATCH 19/68] Update VTKPlots.py

---
 Packages/vcs/vcs/VTKPlots.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index 4d870cd15..8cfe83a28 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -755,7 +755,10 @@ class VTKVCSBackend(object):
                 plot.onClosing(cell)
 
     def plotContinents(self, wc, projection, wrap, vp, priority, **kargs):
-        contData = vcs2vtk.prepContinents(self.canvas._continentspath())
+        continents_path = self.canvas._continentspath()
+        if continents_path is None:
+            return (None, 1, 1)
+        contData = vcs2vtk.prepContinents(continents_path)
         contMapper = vtk.vtkPolyDataMapper()
         contMapper.SetInputData(contData)
         contActor = vtk.vtkActor()
-- 
GitLab


From 6ad67a3f9dcfa3b10cb1579b9a17087a1fbf55fe Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Thu, 28 Apr 2016 14:14:37 -0700
Subject: [PATCH 20/68] Added test

---
 testing/vcs/CMakeLists.txt            |  8 +++++-
 testing/vcs/test_vcs_no_continents.py | 38 +++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 testing/vcs/test_vcs_no_continents.py

diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index a5faf6e24..7024dd66a 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -1016,13 +1016,19 @@ cdat_add_test(test_vcs_init_open_sizing
   "${PYTHON_EXECUTABLE}"
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_init_open_sizing.py
 )
-# Rename baseline
+## Rename baseline
 cdat_add_test(test_vcs_matplotlib_colormap
   "${PYTHON_EXECUTABLE}"
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_matplotlib_colormap.py
   ${BASELINE_DIR}/test_vcs_matplotlib_colormap.png
 )
 
+cdat_add_test(test_vcs_no_continents
+  "${PYTHON_EXECUTABLE}"
+  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_no_continents.py
+  ${BASELINE_DIR}/test_vcs_no_continents.png
+)
+
 
 add_subdirectory(vtk_ui)
 add_subdirectory(editors)
diff --git a/testing/vcs/test_vcs_no_continents.py b/testing/vcs/test_vcs_no_continents.py
new file mode 100644
index 000000000..03630d457
--- /dev/null
+++ b/testing/vcs/test_vcs_no_continents.py
@@ -0,0 +1,38 @@
+import cdms2
+import os
+import sys
+import vcs
+
+# Load the clt data:
+dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
+clt = dataFile("clt")
+clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
+          time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
+
+# Initialize canvas:
+canvas = vcs.init()
+canvas.setantialiasing(0)
+canvas.setbgoutputdimensions(1200,1091,units="pixels")
+canvas.drawlogooff()
+
+t1 = vcs.createtemplate()
+t1.scale(.5, "y")
+t1.move(-.15, "y")
+t2 = vcs.createtemplate(source=t1.name)
+t2.move(.5, 'y')
+
+canvas.plot(clt, t1, continents=0, bg=True)
+canvas.plot(clt, t2, continents=1, bg=True)
+
+# Load the image testing module:
+testingDir = os.path.join(os.path.dirname(__file__), "..")
+sys.path.append(testingDir)
+import checkimage
+
+# Create the test image and compare:
+baseline = sys.argv[1]
+testFile = "test_vcs_no_continents.png"
+canvas.png(testFile)
+ret = checkimage.check_result_image(testFile, baseline,
+                                    checkimage.defaultThreshold)
+sys.exit(ret)
-- 
GitLab


From 9e3f9eeed01503090890e4ee9f3b9a3e52768a4d Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Mon, 9 May 2016 15:42:19 -0700
Subject: [PATCH 21/68] Fixed failing baselines

---
 Packages/vcs/vcs/boxfill.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Packages/vcs/vcs/boxfill.py b/Packages/vcs/vcs/boxfill.py
index e17145437..4003606c9 100755
--- a/Packages/vcs/vcs/boxfill.py
+++ b/Packages/vcs/vcs/boxfill.py
@@ -767,8 +767,8 @@ class Gfb(object):
         if dx == 0:
             high_end += .00001
             return [low_end, high_end]
-
-        contourLevels = numpy.arange(low_end, high_end + dx, dx)
+        float_epsilon = numpy.finfo(numpy.float32).eps
+        contourLevels = numpy.arange(low_end, high_end + float_epsilon, dx)
 
         return contourLevels
 
@@ -788,9 +788,10 @@ class Gfb(object):
                 return vcs.mklabels(scale)
             else:
                 # Create our own scale
-                dx = (self.level_2 - self.level_1) / float(len(scale))
+                dx = (self.level_2 - self.level_1) / float(len(scale) - 1)
                 real_values = [self.level_1, self.level_2]
-                levels = numpy.arange(levels[0], levels[-1] + dx, dx)
+                float_epsilon = numpy.finfo(numpy.float32).eps
+                levels = numpy.arange(levels[0], levels[-1] + float_epsilon, dx)
         else:
             real_values = levels
 
-- 
GitLab


From 08d3eba0f2ae9230343f4838ec8db1ab09a67c4b Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Fri, 22 Apr 2016 11:52:46 -0400
Subject: [PATCH 22/68] ENH #1881: Add plot_based_dual_grid option to plot().

Traditionally, we created a point or cell dataset based on the plot requested.
For isofill, isoline and vector we created point datasets, for boxfill and meshfill we
created cell datasets. We keep this behavior for backward compatibility but we
add a parameter plot_based_dual_grid to plot(). If this parameter is missing or it is
True, we have the traditional behavior. If this parameter is False, we create the
dataset that is specified in the file, regardless of the plot requested.
---
 Packages/cdms2/Lib/avariable.py             |  15 +-
 Packages/cdms2/Lib/axis.py                  |  97 +++++--
 Packages/cdms2/Lib/tvariable.py             |   5 +-
 Packages/vcs/vcs/Canvas.py                  |   6 +-
 Packages/vcs/vcs/vcs2vtk.py                 | 274 +++++++-------------
 Packages/vcs/vcs/vcsvtk/boxfillpipeline.py  |   6 +-
 Packages/vcs/vcs/vcsvtk/isofillpipeline.py  |  27 +-
 Packages/vcs/vcs/vcsvtk/isolinepipeline.py  |  32 +--
 Packages/vcs/vcs/vcsvtk/meshfillpipeline.py |  11 +-
 Packages/vcs/vcs/vcsvtk/pipeline2d.py       |  55 +++-
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py   |  33 ++-
 11 files changed, 260 insertions(+), 301 deletions(-)

diff --git a/Packages/cdms2/Lib/avariable.py b/Packages/cdms2/Lib/avariable.py
index dd2a2792d..f15d7a069 100644
--- a/Packages/cdms2/Lib/avariable.py
+++ b/Packages/cdms2/Lib/avariable.py
@@ -363,6 +363,16 @@ class AbstractVariable(CdmsObj, Slab):
             if axisMatches(self.getAxis(i), axis_spec):
                 return i
         return -1
+    
+    def hasCellData(self):
+        '''
+        If any of the variable's axis has explicit bounds, we have cell data
+        otherwise we have point data.
+        '''
+        for axis in self.getAxisList():
+            if (axis.getExplicitBounds() is not None):
+                return True
+        return False
 
     def getAxisListIndex (self, axes=None, omit=None, order=None):
         """Return a list of indices of axis objects;
@@ -511,7 +521,6 @@ class AbstractVariable(CdmsObj, Slab):
                 
         return result
 
-
     # Get an order string, such as "tzyx"
     def getOrder(self, ids=0):
         """getOrder(ids=0) returns the order string, such as tzyx.
@@ -915,7 +924,9 @@ class AbstractVariable(CdmsObj, Slab):
                 else:
                     delta_beg_wrap_dimvalue = ncyclesrev*cycle
 
-                axis.setBounds(axis.getBounds() - delta_beg_wrap_dimvalue)
+                isGeneric = [False]
+                b = axis.getBounds(isGeneric) - delta_beg_wrap_dimvalue
+                axis.setBounds(b, isGeneric=isGeneric[0])
                 
                 axis[:]= (axis[:] - delta_beg_wrap_dimvalue).astype(axis.typecode())
 
diff --git a/Packages/cdms2/Lib/axis.py b/Packages/cdms2/Lib/axis.py
index 703c0e938..209fbda42 100644
--- a/Packages/cdms2/Lib/axis.py
+++ b/Packages/cdms2/Lib/axis.py
@@ -105,8 +105,8 @@ def getAutoBounds():
     return _autobounds
 
 # Create a transient axis
-def createAxis(data, bounds=None, id=None, copy=0):
-    return TransientAxis(data, bounds, id, copy=copy)
+def createAxis(data, bounds=None, id=None, copy=0, genericBounds=False):
+    return TransientAxis(data, bounds=bounds, id=id, copy=copy, genericBounds=genericBounds)
 
 # Generate a Gaussian latitude axis, north-to-south
 def createGaussianAxis(nlat):
@@ -959,13 +959,41 @@ class AbstractAxis(CdmsObj):
     def isLinear(self):
         raise CDMSError, MethodNotImplemented
 
-    def getBounds(self):
+    def getBounds(self, isGeneric=None):
+        '''
+        isGeneric is a list with one boolean which says if the bounds
+        are read from file (False) or generated (True)
+        '''
         raise CDMSError, MethodNotImplemented
 
-    # Return None if not explicitly defined
     def getExplicitBounds(self):
+        '''
+        Return None if not explicitly defined
+        This is a way to determine if attributes are defined at cell
+        or at point level. If this function returns None attributes are
+        defined at points, otherwise they are defined at cells
+        '''
         raise CDMSError, MethodNotImplemented
 
+    def getBoundsForDualGrid(self, dualGrid):
+        '''
+        dualGrid changes the type of dataset from the current type to the dual.
+        So, if we have a point dataset we switch to a cell dataset and viceversa.
+        '''
+        explicitBounds = self.getExplicitBounds()
+        if (explicitBounds is None):
+            # point data
+            if (dualGrid):
+                return self.getBounds()
+            else:
+                return None
+        else:
+            # cell data
+            if (dualGrid):
+                return None
+            else:
+                return explicitBounds
+
     def setBounds(self, bounds):
         raise CDMSError, MethodNotImplemented
 
@@ -1279,7 +1307,8 @@ class AbstractAxis(CdmsObj):
         The stride k can be positive or negative. Wraparound is
         supported for longitude dimensions or those with a modulus attribute.
         """
-        fullBounds = self.getBounds()
+        isGeneric = [False]
+        fullBounds = self.getBounds(isGeneric)
         _debug=0
         _debugprefix="SS__XX subaxis "
         
@@ -1359,7 +1388,7 @@ class AbstractAxis(CdmsObj):
             else:
                 bounds = None
         
-        newaxis = TransientAxis(data, bounds, id=self.id, copy=1)
+        newaxis = TransientAxis(data, bounds, id=self.id, copy=1, genericBounds=isGeneric[0])
 
         if self.isLatitude(): newaxis.designateLatitude()
         if self.isLongitude(): newaxis.designateLongitude()
@@ -1440,17 +1469,18 @@ class AbstractAxis(CdmsObj):
         """clone (self, copyData=1)
         Return a copy of self as a transient axis.
         If copyData is 1, make a separate copy of the data."""
-        b = self.getBounds()
+        isGeneric = [False]
+        b = self.getBounds(isGeneric)
         if copyData==1:
             mycopy = createAxis(copy.copy(self[:]))
         else:
             mycopy = createAxis(self[:])
         mycopy.id = self.id
         try:
-            mycopy.setBounds(b)
+            mycopy.setBounds(b, isGeneric=isGeneric[0])
         except CDMSError:
             b = mycopy.genGenericBounds()
-            mycopy.setBounds(b)
+            mycopy.setBounds(b, isGeneric=False)
         for k, v in self.attributes.items():
            setattr(mycopy, k, v)
         return mycopy
@@ -1570,7 +1600,13 @@ class Axis(AbstractAxis):
         return self._node_.dataRepresent==cdmsNode.CdLinear
 
     # Return the bounds array, or generate a default if autoBounds mode is on
-    def getBounds(self):
+    def getBounds(self, isGeneric=None):
+        '''
+        If isGeneric is a list with one element, we set its element to True if the
+        bounds were generated and False if bounds were read from the file.
+        '''
+        if (isGeneric):
+            isGeneric[0] = False
         boundsArray = self.getExplicitBounds()
         try:
             self.validateBounds(boundsArray)
@@ -1578,6 +1614,8 @@ class Axis(AbstractAxis):
             boundsArray = None
         abopt = getAutoBounds()
         if boundsArray is None and (abopt==1 or (abopt==2 and (self.isLatitude() or self.isLongitude()))) :
+            if (isGeneric):
+                isGeneric[0] = True
             boundsArray = self.genGenericBounds()
             
         return boundsArray
@@ -1609,7 +1647,10 @@ class Axis(AbstractAxis):
 # In-memory coordinate axis
 class TransientAxis(AbstractAxis):
     axis_count = 0
-    def __init__(self, data, bounds=None, id=None, attributes=None, copy=0):
+    def __init__(self, data, bounds=None, id=None, attributes=None, copy=0, genericBounds=False):
+        '''
+        genericBounds specify if bounds were generated (True) or read from a file (False)
+        '''
         AbstractAxis.__init__(self, None, None)
         if id is None:
             TransientAxis.axis_count = TransientAxis.axis_count + 1
@@ -1646,7 +1687,8 @@ class TransientAxis(AbstractAxis):
             self._data_ = numpy.array(data)
 
         self._doubledata_ = None
-        self.setBounds(bounds)
+        self._genericBounds_ = genericBounds
+        self.setBounds(bounds, isGeneric=genericBounds)
 
     def __getitem__(self, key):
         return self._data_[key]
@@ -1663,10 +1705,15 @@ class TransientAxis(AbstractAxis):
     def __len__(self):
         return len(self._data_)
 
-    def getBounds(self):
+    def getBounds(self, isGeneric=None):
+        if (isGeneric):
+            isGeneric[0] = self._genericBounds_
         if self._bounds_ is not None:
             return copy.copy(self._bounds_)
         elif (getAutoBounds()==1 or (getAutoBounds()==2 and (self.isLatitude() or self.isLongitude()))):
+            if (isGeneric):
+                isGeneric[0] = True
+            self._genericBounds_ = True
             return self.genGenericBounds()
         else:
             return None
@@ -1675,14 +1722,17 @@ class TransientAxis(AbstractAxis):
         return self._data_
 
     def getExplicitBounds(self):
-        return copy.copy(self._bounds_)
+        if (self._genericBounds_):
+            return None
+        else:
+            return copy.copy(self._bounds_)
 
     # Set bounds. The persistent argument is for compatibility with
     # persistent versions, is ignored. Same for boundsid and index.
     #
     # mf 20010308 - add validate key word, by default do not validate
-    #
-    def setBounds(self, bounds, persistent=0, validate=0, index=None, boundsid=None):
+    # isGeneric is False if bounds were generated, True if they were read from a file
+    def setBounds(self, bounds, persistent=0, validate=0, index=None, boundsid=None, isGeneric=False):
         if bounds is not None:
             if isinstance(bounds, numpy.ma.MaskedArray):
                 bounds = numpy.ma.filled(bounds)
@@ -1700,9 +1750,11 @@ class TransientAxis(AbstractAxis):
                     bounds2[:,1]=bounds[1::]
                     bounds=bounds2
             self._bounds_ = copy.copy(bounds)
+            self._genericBounds_ = isGeneric
         else:
             if (getAutoBounds()==1 or (getAutoBounds()==2 and (self.isLatitude() or self.isLongitude()))):
                 self._bounds_ = self.genGenericBounds()
+                self._genericBounds_ = True
             else:
                 self._bounds_ = None
 
@@ -1745,7 +1797,7 @@ class TransientVirtualAxis(TransientAxis):
         "Return true iff coordinate values are implicitly defined."
         return 1
 
-    def setBounds(self, bounds):
+    def setBounds(self, bounds, isGeneric=False):
         "No boundaries on virtual axes"
         self._bounds_ = None
 
@@ -1953,13 +2005,19 @@ class FileAxis(AbstractAxis):
         return 0                        # All file axes are vector representation
 
     # Return the bounds array, or generate a default if autobounds mode is set
-    def getBounds(self):
+    # If isGeneric is a list with one element, we set its element to True if the
+    # bounds were generated and False if bounds were read from the file.
+    def getBounds(self, isGeneric=None):
+        if (isGeneric):
+            isGeneric[0] = False
         boundsArray = self.getExplicitBounds()
         try:
             boundsArray = self.validateBounds(boundsArray)
         except Exception,err:
             boundsArray = None
         if boundsArray is None and (getAutoBounds()==1 or (getAutoBounds()==2 and (self.isLatitude() or self.isLongitude()))):
+            if (isGeneric):
+                isGeneric[0] = True
             boundsArray = self.genGenericBounds()
             
         return boundsArray
@@ -1989,7 +2047,8 @@ class FileAxis(AbstractAxis):
     # index in the extended dimension (default is index=0).
     # If the bounds variable is new, use the name boundsid, or 'bounds_<varid>'
     # if unspecified.
-    def setBounds(self, bounds, persistent=0, validate=0, index=None, boundsid=None):
+    # isGeneric is only used for TransientAxis
+    def setBounds(self, bounds, persistent=0, validate=0, index=None, boundsid=None, isGeneric=False):
         if persistent:
             if index is None:
                 if validate:
diff --git a/Packages/cdms2/Lib/tvariable.py b/Packages/cdms2/Lib/tvariable.py
index 27cab8156..152875adf 100644
--- a/Packages/cdms2/Lib/tvariable.py
+++ b/Packages/cdms2/Lib/tvariable.py
@@ -384,8 +384,9 @@ class TransientVariable(AbstractVariable,numpy.ma.MaskedArray):
         if n < 0: n = n + self.rank()
         if not isinstance(axis, AbstractAxis):
             raise CDMSError,"copydimension, other not an axis."
-        b = axis.getBounds()
-        mycopy = createAxis(axis[:], b)
+        isGeneric = [False]
+        b = axis.getBounds(isGeneric)
+        mycopy = createAxis(axis[:], b, genericBounds=isGeneric[0])
         mycopy.id = axis.id
         for k, v in axis.attributes.items():
            setattr(mycopy, k, v)
diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index d98270c55..cee91f99d 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -2333,7 +2333,11 @@ Options:::
                                                     # bunch of plots in a row)
         display_name = "__display_123"                # VCS Display plot name (used to prevent duplicate display plots)
         ratio = 1.5|"autot"|"auto"                   # Ratio of height/width for the plot; autot and auto will choose a
-                                                    # "good" ratio for you.
+                                                     # "good" ratio for you.
+        plot_based_dual_grid = True | False          # Plot the actual grid or the dual grid based on what is
+                                                     # needed by the plot: isofill, isoline, vector need
+                                                     # point attributes, boxfill and meshfill need cell attributes
+                                                     # The default is True (if the parameter is not specified).
     Graphics Output in Background Mode:
        bg                 = 0|1   # if ==1, create images in the background
                                                              (Don't display the VCS Canvas)
diff --git a/Packages/vcs/vcs/vcs2vtk.py b/Packages/vcs/vcs/vcs2vtk.py
index d6c449b05..86cfcfd0a 100644
--- a/Packages/vcs/vcs/vcs2vtk.py
+++ b/Packages/vcs/vcs/vcs2vtk.py
@@ -180,142 +180,48 @@ def handleProjectionEdgeCases(projection, data):
     return data
 
 
-def genGridOnPoints(data1, gm, deep=True, grid=None, geo=None,
-                    data2=None):
-    continents = False
-    projection = vcs.elements["projection"][gm.projection]
-    xm, xM, ym, yM = None, None, None, None
-    useStructuredGrid = True
-
-    data1 = handleProjectionEdgeCases(projection, data1)
-    if data2 is not None:
-        data2 = handleProjectionEdgeCases(projection, data2)
-
-    try:
-        g = data1.getGrid()
-        if grid is None:
-            x = g.getLongitude()[:]
-            y = g.getLatitude()[:]
-            xm = x[0]
-            xM = x[-1]
-            ym = y[0]
-            yM = y[-1]
-        continents = True
-        wrap = [0, 360]
-        # Ok need unstrctured grid
-        if isinstance(g, cdms2.gengrid.AbstractGenericGrid):
-            useStructuredGrid = False
-    except:
-        # hum no grid that's much easier
-        wrap = None
-        if grid is None:
-            x = data1.getAxis(-1)[:]
-            y = data1.getAxis(-2)[:]
-            xm = x[0]
-            xM = x[-1]
-            ym = y[0]
-            yM = y[-1]
-
-    if grid is None:
-        if x.ndim == 1:
-            y = y[:, numpy.newaxis] * numpy.ones(x.shape)[numpy.newaxis, :]
-            x = x[numpy.newaxis, :] * numpy.ones(y.shape)
-        x = x.flatten()
-        y = y.flatten()
-        sh = list(x.shape)
-        sh.append(1)
-        x = numpy.reshape(x, sh)
-        y = numpy.reshape(y, sh)
-        # Ok we have our points in 2D let's create unstructured points grid
-        if xm is None:
-            xm = x.min()
-        if xM is None:
-            xM = x.max()
-        if ym is None:
-            ym = y.min()
-        if yM is None:
-            yM = y.max()
-        z = numpy.zeros(x.shape)
-        m3 = numpy.concatenate((x, y), axis=1)
-        m3 = numpy.concatenate((m3, z), axis=1)
-        deep = True
-        pts = vtk.vtkPoints()
-        # Convert nupmy array to vtk ones
-        ppV = numpy_to_vtk_wrapper(m3, deep=deep)
-        pts.SetData(ppV)
-        xm, xM, ym, yM, tmp, tmp2 = pts.GetBounds()
-    else:
-        xm, xM, ym, yM, tmp, tmp2 = grid.GetPoints().GetBounds()
-        vg = grid
-    oldpts = pts
-    if geo is None:
-        bounds = pts.GetBounds()
-        xm, xM, ym, yM = [bounds[0], bounds[1], bounds[2], bounds[3]]
-        # We use zooming feature (gm.datawc) for linear and polar projections.
-        # We use wrapped coordinates for doing the projection
-        # such that parameters like the central meridian are set correctly.
-        if (gm.g_name == 'Gfm'):
-            # axes are not lon/lat for meshfill
-            wc = [gm.datawc_x1, gm.datawc_x2, gm.datawc_y1, gm.datawc_y2]
-        else:
-            wc = vcs.utils.getworldcoordinates(gm,
-                                               data1.getAxis(-1),
-                                               data1.getAxis(-2))
-        geo, geopts = project(pts, projection, getWrappedBounds(
-            wc, [xm, xM, ym, yM], wrap))
-        pts = geopts
-    # Sets the vertices into the grid
-    if grid is None:
-        if useStructuredGrid:
-            vg = vtk.vtkStructuredGrid()
-            vg.SetDimensions(data1.shape[1], data1.shape[0], 1)
-        else:
-            vg = vtk.vtkUnstructuredGrid()
-        vg.SetPoints(oldpts)
-        vg.SetPoints(pts)
-    else:
-        vg = grid
-    scalar = numpy_to_vtk_wrapper(data1.filled(0.).flat,
-                                  deep=False)
-    scalar.SetName("scalar")
-    vg.GetPointData().SetScalars(scalar)
-    out = {"vtk_backend_grid": vg,
-           "xm": xm,
-           "xM": xM,
-           "ym": ym,
-           "yM": yM,
-           "continents": continents,
-           "wrap": wrap,
-           "geo": geo,
-           "data": data1,
-           "data2": data2
-           }
-    return out
-
-
-# Returns the bounds list for 'axis'. If axis has n elements the
-# bounds list will have n+1 elements
-def getBoundsList(axis):
-    bounds = numpy.zeros(len(axis) + 1)
-    try:
-        axisBounds = axis.getBounds()
+def getBoundsList(axis, hasCellData, dualGrid):
+    '''
+    Returns the bounds list for 'axis'. If axis has n elements the
+    bounds list will have n+1 elements
+    If there are not explicit bounds in the file we return None
+    '''
+    needsCellData = (hasCellData != dualGrid)
+    axisBounds = axis.getBoundsForDualGrid(dualGrid)
+    # we still have to generate bounds for non lon-lat axes, because
+    # the default in axis.py is 2 (generate bounds only for lat/lon axis)
+    # this is used for non lon-lat plots - by default numpy arrays are POINT data
+    if (not axis.isLatitude() and not axis.isLongitude() and needsCellData):
+        axisBounds = axis.genGenericBounds()
+    if (axisBounds is not None):
+        bounds = numpy.zeros(len(axis) + 1)
         if (axis[0] < axis[-1]):
             # axis is increasing
-            bounds[:len(axis)] = axisBounds[:, 0]
-            bounds[len(axis)] = axisBounds[-1, 1]
+            if (axisBounds[0][0] < axisBounds[0][1]):
+                # interval is increasing
+                bounds[:len(axis)] = axisBounds[:, 0]
+                bounds[len(axis)] = axisBounds[-1, 1]
+            else:
+                # interval is decreasing
+                bounds[:len(axis)] = axisBounds[:, 1]
+                bounds[len(axis)] = axisBounds[-1, 0]
         else:
             # axis is decreasing
-            bounds[:len(axis)] = axisBounds[:, 1]
-            bounds[len(axis)] = axisBounds[-1, 0]
-    except Exception:
-        # No luck we have to generate bounds ourselves
-        bounds[1:-1] = (axis[:-1] + axis[1:]) / 2.
-        bounds[0] = axis[0] - (axis[1] - axis[0]) / 2.
-        bounds[-1] = axis[-1] + (axis[-1] - axis[-2]) / 2.
-    return bounds
+            if (axisBounds[0][0] < axisBounds[0][1]):
+                # interval is increasing
+                bounds[:len(axis)] = axisBounds[:, 1]
+                bounds[len(axis)] = axisBounds[-1, 0]
+            else:
+                # interval is decreasing
+                bounds[:len(axis)] = axisBounds[:, 0]
+                bounds[len(axis)] = axisBounds[-1, 1]
+        return bounds
+    else:
+        return None
 
 
-def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
+def genGrid(data1, data2, gm, deep=True, grid=None, geo=None, genVectors=False,
+            dualGrid=False):
     continents = False
     wrap = None
     m3 = None
@@ -325,6 +231,8 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
     projection = vcs.elements["projection"][gm.projection]
 
     data1 = handleProjectionEdgeCases(projection, data1)
+    if data2 is not None:
+        data2 = handleProjectionEdgeCases(projection, data2)
 
     try:  # First try to see if we can get a mesh out of this
         g = data1.getGrid()
@@ -388,6 +296,7 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
         # Ok a simple structured grid is enough
         if grid is None:
             vg = vtk.vtkStructuredGrid()
+        hasCellData = data1.hasCellData()
         if g is not None:
             # Ok we have grid
             continents = True
@@ -406,38 +315,49 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
                 lon = data1.getAxis(-1)
                 lat = data1.getAxis(-2)
                 # Ok let's try to get the bounds
-                lon2 = getBoundsList(lon)
-                lat2 = getBoundsList(lat)
+                lon2 = getBoundsList(lon, hasCellData, dualGrid)
+                lat2 = getBoundsList(lat, hasCellData, dualGrid)
+                if (lon2 is not None and lat2 is not None):
+                    lon3 = lon2
+                    lat3 = lat2
+                else:
+                    lon3 = lon
+                    lat3 = lat
+                    cellData = False
                 # Note that m,M is min,max for an increasing list
                 # and max,min for a decreasing list
-                xm = lon2[0]
-                xM = lon2[-1]
-                ym = lat2[0]
-                yM = lat2[-1]
-
-                lat = lat2[:, numpy.newaxis] * \
-                    numpy.ones(lon2.shape)[numpy.newaxis, :]
-                lon = lon2[numpy.newaxis,
-                           :] * numpy.ones(lat2.shape)[:,
-                                                       numpy.newaxis]
+                xm = lon3[0]
+                xM = lon3[-1]
+                ym = lat3[0]
+                yM = lat3[-1]
+
+                lat = lat3[:, numpy.newaxis] * numpy.ones(lon3.shape)[numpy.newaxis, :]
+                lon = lon3[numpy.newaxis, :] * numpy.ones(lat3.shape)[:, numpy.newaxis]
         elif grid is None:
             # No grid info from data, making one up
             data1 = cdms2.asVariable(data1)
             lon = data1.getAxis(-1)
             lat = data1.getAxis(-2)
             # Ok let's try to get the bounds
-            lon2 = getBoundsList(lon)
-            lat2 = getBoundsList(lat)
+            lon2 = getBoundsList(lon, hasCellData, dualGrid)
+            lat2 = getBoundsList(lat, hasCellData, dualGrid)
+            if (lon2 is not None and lat2 is not None):
+                lon3 = lon2
+                lat3 = lat2
+            else:
+                lon3 = lon
+                lat3 = lat
+                cellData = False
             # Note that m,M is min,max for an increasing list
             # and max,min for a decreasing list
-            xm = lon2[0]
-            xM = lon2[-1]
-            ym = lat2[0]
-            yM = lat2[-1]
-            lat = lat2[:, numpy.newaxis] * \
-                numpy.ones(lon2.shape)[numpy.newaxis, :]
-            lon = lon2[numpy.newaxis, :] * \
-                numpy.ones(lat2.shape)[:, numpy.newaxis]
+            xm = lon3[0]
+            xM = lon3[-1]
+            ym = lat3[0]
+            yM = lat3[-1]
+            lat = lat3[:, numpy.newaxis] * \
+                numpy.ones(lon3.shape)[numpy.newaxis, :]
+            lon = lon3[numpy.newaxis, :] * \
+                numpy.ones(lat3.shape)[:, numpy.newaxis]
         if grid is None:
             vg.SetDimensions(lat.shape[1], lat.shape[0], 1)
             lon = numpy.ma.ravel(lon)
@@ -461,15 +381,23 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
                     ym = lat.min()
                     yM = lat.max()
 
-    # scalar data
-    scalar = numpy_to_vtk_wrapper(data1.filled(0.).flat,
-                                  deep=False)
-    scalar.SetName("scalar")
-    gridForScalar = grid if grid else vg
+    # attribute data
+    gridForAttribute = grid if grid else vg
+    if genVectors:
+        attribute = generateVectorArray(data1, data2, gridForAttribute)
+    else:
+        attribute = numpy_to_vtk_wrapper(data1.filled(0.).flat,
+                                         deep=False)
+        attribute.SetName("scalar")
     if cellData:
-        gridForScalar.GetCellData().SetScalars(scalar)
+        attributes = gridForAttribute.GetCellData()
+    else:
+        attributes = gridForAttribute.GetPointData()
+    if genVectors:
+        attributes.SetVectors(attribute)
     else:
-        gridForScalar.GetPointData().SetScalars(scalar)
+        attributes.SetScalars(attribute)
+
     if grid is None:
         # First create the points/vertices (in vcs terms)
         pts = vtk.vtkPoints()
@@ -489,8 +417,8 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
             # wrapping
             pedigreeId = vtk.vtkIntArray()
             pedigreeId.SetName("PedigreeIds")
-            pedigreeId.SetNumberOfTuples(scalar.GetNumberOfTuples())
-            for i in range(0, scalar.GetNumberOfTuples()):
+            pedigreeId.SetNumberOfTuples(attribute.GetNumberOfTuples())
+            for i in range(0, attribute.GetNumberOfTuples()):
                 pedigreeId.SetValue(i, i)
             if cellData:
                 vg.GetCellData().SetPedigreeIds(pedigreeId)
@@ -533,7 +461,8 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None):
            "wrap": wrap,
            "geo": geo,
            "cellData": cellData,
-           "data": data1
+           "data": data1,
+           "data2": data2
            }
     return out
 
@@ -1853,27 +1782,8 @@ def generateVectorArray(data1, data2, vtk_grid):
     w = numpy.concatenate((u, v), axis=1)
     w = numpy.concatenate((w, z), axis=1)
 
-    # HACK The grid returned by vtk2vcs.genGrid is not the same size as the
-    # data array. I'm not sure where the issue is...for now let's just zero-pad
-    # data array so that we can at least test rendering until Charles gets
-    # back from vacation:
-    wLen = len(w)
-    numPts = vtk_grid.GetNumberOfPoints()
-    if wLen != numPts:
-        warnings.warn("!!! Warning during vector plotting: "
-                      "Number of points does not "
-                      "match the number of vectors to be "
-                      "glyphed (%s points vs %s "
-                      "vectors). The vectors will be "
-                      "padded/truncated to match for "
-                      "rendering purposes, but the resulting "
-                      "image should not be "
-                      "trusted." % (numPts, wLen))
-        newShape = (numPts,) + w.shape[1:]
-        w = numpy.ma.resize(w, newShape)
-
     w = numpy_to_vtk_wrapper(w, deep=False)
-    w.SetName("vectors")
+    w.SetName("vector")
     return w
 
 
diff --git a/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py b/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py
index 772652172..1eb39085c 100644
--- a/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py
@@ -24,6 +24,7 @@ class BoxfillPipeline(Pipeline2D):
         self._contourLabels = None
         self._mappers = None
         self._customBoxfillArgs = {}
+        self._needsCellData = True
 
     def _updateScalarData(self):
         """Overrides baseclass implementation."""
@@ -93,11 +94,6 @@ class BoxfillPipeline(Pipeline2D):
         # Use consecutive colors:
         self._contourColors = range(self._gm.color_1, self._gm.color_2 + 1)
 
-    def _createPolyDataFilter(self):
-        """Overrides baseclass implementation."""
-        self._vtkPolyDataFilter = vtk.vtkDataSetSurfaceFilter()
-        self._vtkPolyDataFilter.SetInputData(self._vtkDataSet)
-
     def _plotInternal(self):
         """Overrides baseclass implementation."""
         # Special case for custom boxfills:
diff --git a/Packages/vcs/vcs/vcsvtk/isofillpipeline.py b/Packages/vcs/vcs/vcsvtk/isofillpipeline.py
index e2ee5360e..8f46aa5bd 100644
--- a/Packages/vcs/vcs/vcsvtk/isofillpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/isofillpipeline.py
@@ -13,36 +13,11 @@ class IsofillPipeline(Pipeline2D):
 
     def __init__(self, gm, context_):
         super(IsofillPipeline, self).__init__(gm, context_)
-
-    def _updateVTKDataSet(self):
-        """Overrides baseclass implementation."""
-        # Force point data for isoline/isofill
-        genGridDict = vcs2vtk.genGridOnPoints(self._data1, self._gm,
-                                              deep=False,
-                                              grid=self._vtkDataSet,
-                                              geo=self._vtkGeoTransform)
-        genGridDict["cellData"] = False
-        self._data1 = genGridDict["data"]
-        self._updateFromGenGridDict(genGridDict)
+        self._needsCellData = False
 
     def _updateContourLevelsAndColors(self):
         self._updateContourLevelsAndColorsGeneric()
 
-    def _createPolyDataFilter(self):
-        """Overrides baseclass implementation."""
-        self._vtkPolyDataFilter = vtk.vtkDataSetSurfaceFilter()
-        if self._useCellScalars:
-            # Sets data to point instead of just cells
-            c2p = vtk.vtkCellDataToPointData()
-            c2p.SetInputData(self._vtkDataSet)
-            c2p.Update()
-            # For contouring duplicate points seem to confuse it
-            self._vtkPolyDataFilter.SetInputConnection(c2p.GetOutputPort())
-        else:
-            self._vtkPolyDataFilter.SetInputData(self._vtkDataSet)
-        self._vtkPolyDataFilter.Update()
-        self._resultDict["vtk_backend_filter"] = self._vtkPolyDataFilter
-
     def _plotInternal(self):
         """Overrides baseclass implementation."""
 
diff --git a/Packages/vcs/vcs/vcsvtk/isolinepipeline.py b/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
index af79a45b8..2d9b66472 100644
--- a/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
@@ -12,21 +12,7 @@ class IsolinePipeline(Pipeline2D):
 
     def __init__(self, gm, context_):
         super(IsolinePipeline, self).__init__(gm, context_)
-
-    def _updateVTKDataSet(self):
-        """Overrides baseclass implementation."""
-        # Force point data for isoline/isofill
-        genGridDict = vcs2vtk.genGridOnPoints(self._data1, self._gm,
-                                              deep=False,
-                                              grid=self._vtkDataSet,
-                                              geo=self._vtkGeoTransform)
-        genGridDict["cellData"] = False
-        self._data1 = genGridDict["data"]
-        self._updateFromGenGridDict(genGridDict)
-
-        data = vcs2vtk.numpy_to_vtk_wrapper(self._data1.filled(0.).flat,
-                                            deep=False)
-        self._vtkDataSet.GetPointData().SetScalars(data)
+        self._needsCellData = False
 
     def _updateContourLevelsAndColors(self):
         """Overrides baseclass implementation."""
@@ -49,20 +35,6 @@ class IsolinePipeline(Pipeline2D):
         # Contour colors:
         self._contourColors = self._gm.linecolors
 
-    def _createPolyDataFilter(self):
-        """Overrides baseclass implementation."""
-        self._vtkPolyDataFilter = vtk.vtkDataSetSurfaceFilter()
-        if self._useCellScalars:
-            # Sets data to point instead of just cells
-            c2p = vtk.vtkCellDataToPointData()
-            c2p.SetInputData(self._vtkDataSet)
-            c2p.Update()
-            # For contouring duplicate points seem to confuse it
-            self._vtkPolyDataFilter.SetInputConnection(c2p.GetOutputPort())
-        else:
-            self._vtkPolyDataFilter.SetInputData(self._vtkDataSet)
-        self._resultDict["vtk_backend_filter"] = self._vtkPolyDataFilter
-
     def _plotInternal(self):
         """Overrides baseclass implementation."""
         tmpLevels = []
@@ -164,7 +136,7 @@ class IsolinePipeline(Pipeline2D):
             numLevels = len(l)
 
             cot = vtk.vtkContourFilter()
-            if self._useCellScalars:
+            if self._hasCellData:
                 cot.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
             else:
                 cot.SetInputData(self._vtkDataSet)
diff --git a/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py b/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
index 90c06718d..7101a4729 100644
--- a/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
@@ -15,6 +15,7 @@ class MeshfillPipeline(Pipeline2D):
         super(MeshfillPipeline, self).__init__(gm, context_)
 
         self._patternActors = []
+        self._needsCellData = True
 
     def _updateScalarData(self):
         """Overrides baseclass implementation."""
@@ -25,16 +26,6 @@ class MeshfillPipeline(Pipeline2D):
     def _updateContourLevelsAndColors(self):
         self._updateContourLevelsAndColorsGeneric()
 
-    def _createPolyDataFilter(self):
-        """Overrides baseclass implementation."""
-        self._vtkPolyDataFilter = vtk.vtkDataSetSurfaceFilter()
-        if self._useCellScalars:
-            self._vtkPolyDataFilter.SetInputData(self._vtkDataSet)
-        else:
-            p2c = vtk.vtkPointDataToCellData()
-            p2c.SetInputData(self._vtkDataSet)
-            self._vtkPolyDataFilter.SetInputConnection(p2c.GetOutputPort())
-
     def _plotInternal(self):
 
         prepedContours = self._prepContours()
diff --git a/Packages/vcs/vcs/vcsvtk/pipeline2d.py b/Packages/vcs/vcs/vcsvtk/pipeline2d.py
index 4d370db8a..baa2f8915 100644
--- a/Packages/vcs/vcs/vcsvtk/pipeline2d.py
+++ b/Packages/vcs/vcs/vcsvtk/pipeline2d.py
@@ -1,9 +1,10 @@
 from .pipeline import Pipeline
 from .. import vcs2vtk
 
-import vcs
-import numpy
 import fillareautils
+import numpy
+import vcs
+import vtk
 import warnings
 
 
@@ -45,8 +46,10 @@ class IPipeline2D(Pipeline):
         - _useContinents: Whether or not to plot continents.
         - _dataWrapModulo: Wrap modulo as [YMax, XMax], in degrees. 0 means
             'no wrapping'.
-        - _useCellScalars: True if data is applied to cell, false if data is
+        - _hasCellData: True if data is applied to cell, false if data is
             applied to points.
+        - _needsCellData: True if the plot needs cell scalars, false if
+            the plot needs point scalars
         - _scalarRange: The range of _data1 as tuple(float min, float max)
         - _maskedDataMapper: The mapper used to render masked data.
     """
@@ -74,7 +77,8 @@ class IPipeline2D(Pipeline):
         self._colorMap = None
         self._useContinents = None
         self._dataWrapModulo = None
-        self._useCellScalars = None
+        self._hasCellData = None
+        self._needsCellData = None
         self._scalarRange = None
         self._maskedDataMapper = None
 
@@ -82,7 +86,7 @@ class IPipeline2D(Pipeline):
         """Create _data1 and _data2 from _originalData1 and _originalData2."""
         raise NotImplementedError("Missing override.")
 
-    def _updateVTKDataSet(self):
+    def _updateVTKDataSet(self, plotBasedDualGrid):
         """Apply the vcs data to _vtkDataSet, creating it if necessary."""
         raise NotImplementedError("Missing override.")
 
@@ -275,7 +279,8 @@ class Pipeline2D(IPipeline2D):
         self._scalarRange = vcs.minmax(self._data1)
 
         # Create/update the VTK dataset.
-        self._updateVTKDataSet()
+        plotBasedDualGrid = kargs.get('plot_based_dual_grid', True)
+        self._updateVTKDataSet(plotBasedDualGrid)
 
         # Update the results:
         self._resultDict["vtk_backend_grid"] = self._vtkDataSet
@@ -311,16 +316,40 @@ class Pipeline2D(IPipeline2D):
         self._min = self._data1.min()
         self._max = self._data1.max()
 
-    def _updateVTKDataSet(self):
-        """Overrides baseclass implementation."""
+    def _updateVTKDataSet(self, plotBasedDualGrid):
+        """
+        """
+        if (plotBasedDualGrid):
+            hasCellData = self._data1.hasCellData()
+            dualGrid = (hasCellData != self._needsCellData)
+        else:
+            dualGrid = False
         genGridDict = vcs2vtk.genGrid(self._data1, self._data2, self._gm,
                                       deep=False,
                                       grid=self._vtkDataSet,
-                                      geo=self._vtkGeoTransform)
-
+                                      geo=self._vtkGeoTransform, dualGrid=dualGrid)
         self._data1 = genGridDict["data"]
         self._updateFromGenGridDict(genGridDict)
 
+    def _createPolyDataFilter(self):
+        """This is only used when we use the grid stored in the file for all plots."""
+        self._vtkPolyDataFilter = vtk.vtkDataSetSurfaceFilter()
+        if self._hasCellData == self._needsCellData:
+            self._vtkPolyDataFilter.SetInputData(self._vtkDataSet)
+        elif self._hasCellData:
+            # use cells but needs points
+            c2p = vtk.vtkCellDataToPointData()
+            c2p.SetInputData(self._vtkDataSet)
+            self._vtkPolyDataFilter.SetInputConnection(c2p.GetOutputPort())
+        else:
+            # use points but needs cells
+            p2c = vtk.vtkPointDataToCellData()
+            p2c.SetInputData(self._vtkDataSet)
+            # For contouring duplicate points seem to confuse it
+            self._vtkPolyDataFilter.SetInputConnection(p2c.GetOutputPort())
+        self._vtkPolyDataFilter.Update()
+        self._resultDict["vtk_backend_filter"] = self._vtkPolyDataFilter
+
     def _updateFromGenGridDict(self, genGridDict):
         """Overrides baseclass implementation."""
         self._vtkDataSet = genGridDict['vtk_backend_grid']
@@ -329,7 +358,7 @@ class Pipeline2D(IPipeline2D):
         self._useContinents = genGridDict['continents']
         self._dataWrapModulo = genGridDict['wrap']
         self._vtkGeoTransform = genGridDict['geo']
-        self._useCellScalars = genGridDict['cellData']
+        self._hasCellData = genGridDict['cellData']
 
     def _createMaskedDataMapper(self):
         """Overrides baseclass implementation."""
@@ -338,11 +367,11 @@ class Pipeline2D(IPipeline2D):
         if color is not None:
             color = self.getColorIndexOrRGBA(_colorMap, color)
         self._maskedDataMapper = vcs2vtk.putMaskOnVTKGrid(
-            self._data1, self._vtkDataSet, color, self._useCellScalars,
+            self._data1, self._vtkDataSet, color, self._hasCellData,
             deep=False)
 
         self._resultDict["vtk_backend_missing_mapper"] = (
-            self._maskedDataMapper, color, self._useCellScalars)
+            self._maskedDataMapper, color, self._hasCellData)
 
     def getPlottingBounds(self):
         """gm.datawc if it is set or dataset_bounds if there is not geographic projection
diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index b8c4eaead..bc34e3c9e 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -33,14 +33,21 @@ class VectorPipeline(Pipeline):
         lon = None
 
         latAccessor = data1.getLatitude()
-        lonAccesrsor = data1.getLongitude()
+        lonAccessor = data1.getLongitude()
         if latAccessor:
             lat = latAccessor[:]
-        if lonAccesrsor:
-            lon = lonAccesrsor[:]
+        if lonAccessor:
+            lon = lonAccessor[:]
 
-        gridGenDict = vcs2vtk.genGridOnPoints(data1, self._gm, deep=False, grid=grid,
-                                              geo=transform, data2=data2)
+        plotBasedDualGrid = kargs.get('plot_based_dual_grid', True)
+        if (plotBasedDualGrid):
+            hasCellData = data1.hasCellData()
+            dualGrid = hasCellData
+        else:
+            dualGrid = False
+        gridGenDict = vcs2vtk.genGrid(data1, data2, self._gm, deep=False, grid=grid,
+                                      geo=transform, genVectors=True,
+                                      dualGrid=dualGrid)
 
         data1 = gridGenDict["data"]
         data2 = gridGenDict["data2"]
@@ -54,6 +61,7 @@ class VectorPipeline(Pipeline):
         continents = gridGenDict['continents']
         self._dataWrapModulo = gridGenDict['wrap']
         geo = gridGenDict['geo']
+        cellData = gridGenDict['cellData']
 
         if geo is not None:
             newv = vtk.vtkDoubleArray()
@@ -83,16 +91,19 @@ class VectorPipeline(Pipeline):
 
         returned["vtk_backend_grid"] = grid
         returned["vtk_backend_geo"] = geo
-        missingMapper = vcs2vtk.putMaskOnVTKGrid(data1, grid, None, False,
-                                                 deep=False)
+        missingMapper = vcs2vtk.putMaskOnVTKGrid(data1, grid, actorColor=None,
+                                                 cellData=cellData, deep=False)
 
         # None/False are for color and cellData
         # (sent to vcs2vtk.putMaskOnVTKGrid)
         returned["vtk_backend_missing_mapper"] = (missingMapper, None, False)
 
-        w = vcs2vtk.generateVectorArray(data1, data2, grid)
-
-        grid.GetPointData().AddArray(w)
+        # convert to point data
+        if cellData:
+            c2p = vtk.vtkCellDataToPointData()
+            c2p.SetInputData(grid)
+            c2p.Update()
+            grid = c2p.GetOutput()
 
         # Vector attempt
         l = self._gm.line
@@ -119,7 +130,7 @@ class VectorPipeline(Pipeline):
 
         glyphFilter = vtk.vtkGlyph2D()
         glyphFilter.SetInputData(grid)
-        glyphFilter.SetInputArrayToProcess(1, 0, 0, 0, "vectors")
+        glyphFilter.SetInputArrayToProcess(1, 0, 0, 0, "vector")
         glyphFilter.SetSourceConnection(arrow.GetOutputPort())
         glyphFilter.SetVectorModeToUseVector()
 
-- 
GitLab


From 0d6bfec7174d847b46038d1c86a7ca06beceb3db Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Wed, 4 May 2016 16:24:18 -0400
Subject: [PATCH 23/68] BUG: Fix mean computation for point datasets.

With the new flag TransientAxis._genericBounds_ TransientAxis.getExplicitBounds
returns None if the bounds were not read from a NetCDF file but were autogenerated.
This creates a problem in cdutil.averager as bound axis are artificially extended to -90, 90
So, for a latbnds=[[90, 88], [88, 84], ..., [4, 0]] we extended it to
[[90, 88], [88,84], ..., [4, -90]]. We remove the code that did this.

This fix also improves the baseline for testEsmfRegridRegion.
---
 Packages/cdms2/Lib/grid.py | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/Packages/cdms2/Lib/grid.py b/Packages/cdms2/Lib/grid.py
index f11ca1764..9930f263a 100644
--- a/Packages/cdms2/Lib/grid.py
+++ b/Packages/cdms2/Lib/grid.py
@@ -496,14 +496,6 @@ class AbstractRectGrid(AbstractGrid):
         else:
             latbnds = lat.genGenericBounds()
 
-        # Stretch latitude bounds to +/- 90.0
-        if ascending:
-            latbnds[0,0] = min(latbnds[0,0],-90.0)
-            latbnds[-1,1] = max(latbnds[-1,1],90.0)
-        else:
-            latbnds[0,0] = max(latbnds[0,0],+90.0)
-            latbnds[-1,1] = min(latbnds[-1,1],-90.0)
-
         # Get longitude bounds
         lon = self.getLongitude()
         if len(lon)>1:
-- 
GitLab


From 2acc77cdf88741f93b8ff79c357d623b993197ea Mon Sep 17 00:00:00 2001
From: Sam Fries <fries2@llnl.gov>
Date: Wed, 11 May 2016 09:12:41 -0700
Subject: [PATCH 24/68] Made flake8 pass, removed extra line, unwrapped some
 wrapped lines

---
 Packages/vcs/vcs/boxfill.py  |  7 ++-----
 Packages/vcs/vcs/template.py | 23 +++++++++++++++++------
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/Packages/vcs/vcs/boxfill.py b/Packages/vcs/vcs/boxfill.py
index 4003606c9..b403895fc 100755
--- a/Packages/vcs/vcs/boxfill.py
+++ b/Packages/vcs/vcs/boxfill.py
@@ -742,8 +742,7 @@ class Gfb(object):
         nlev = float(self.color_2 - self.color_1 + 1)
         autolevels = False
 
-        if numpy.allclose(self.level_1, 1.e20) or \
-           numpy.allclose(self.level_2, 1.e20):
+        if numpy.allclose(self.level_1, 1.e20) or numpy.allclose(self.level_2, 1.e20):
             autolevels = True
             low_end = varmin
             high_end = varmax
@@ -755,7 +754,6 @@ class Gfb(object):
             low_end = numpy.ma.log10(low_end)
             high_end = numpy.ma.log10(high_end)
 
-
         if autolevels:
             # Use nice values for the scale
             scale = vcs.mkscale(low_end, high_end)
@@ -776,8 +774,7 @@ class Gfb(object):
         if self.legend:
             return self.legend
 
-        if numpy.allclose(self.level_1, 1.e20) or \
-           numpy.allclose(self.level_2, 1.e20):
+        if numpy.allclose(self.level_1, 1.e20) or numpy.allclose(self.level_2, 1.e20):
             autolevels = True
         else:
             autolevels = False
diff --git a/Packages/vcs/vcs/template.py b/Packages/vcs/vcs/template.py
index 3eaac046b..fd2ee2f0c 100644
--- a/Packages/vcs/vcs/template.py
+++ b/Packages/vcs/vcs/template.py
@@ -56,6 +56,18 @@ def _setgen(self, name, cls, value):
     setattr(self, "_%s" % name, value)
 
 
+def epsilon_gte(a, b):
+    """a >= b, using floating point epsilon value."""
+    float_epsilon = numpy.finfo(numpy.float32).eps
+    return -float_epsilon < a - b
+
+
+def epsilon_lte(a, b):
+    """a <= b, using floating point epsilon value."""
+    float_epsilon = numpy.finfo(numpy.float32).eps
+    return float_epsilon > a - b
+
+
 # read .scr file
 def process_src(nm, code):
     """Takes VCS script code (string) as input and generates boxfill gm from it"""
@@ -1874,15 +1886,14 @@ class P(object):
             if legend is None:
                 legend = vcs.mklabels(levels)
             # We'll use the less precise float epsilon since this is just for labels
-            float_epsilon = numpy.finfo(numpy.float32).eps
             if levels[0] < levels[1]:
-                # <=
-                comparison = lambda a, b: float_epsilon > a - b
+                comparison = epsilon_lte
             else:
-                # >=
-                comparison = lambda a, b: -float_epsilon < a - b
+                comparison = epsilon_gte
+
+            def in_bounds(x):
+                return comparison(levels[0], x) and comparison(x, levels[-1])
 
-            in_bounds = lambda x: comparison(levels[0], x) and comparison(x, levels[-1])
             dlong = dD / (len(levels) - 1)
 
             for l in legend.keys():
-- 
GitLab


From 5dd0a949f1b5b26c51cbb4513fd165f519031573 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Sat, 30 Apr 2016 21:49:57 -0400
Subject: [PATCH 25/68] Using common module for regression testing

---
 Packages/testing/__init__.py                  |  0
 .../testing/regression.py                     | 23 +++++++++-
 Packages/testing/setup.py                     | 14 ++++++
 testing/vcs/test_vcs_1D_datawc.py             | 21 +++------
 testing/vcs/test_vcs_1D_datawc_missing.py     | 29 ++----------
 testing/vcs/test_vcs_1D_with_manyDs.py        | 30 ++----------
 testing/vcs/test_vcs_1d_in_boxfill.py         | 27 ++---------
 ...cs_1d_marker_not_shown_if_xaxis_flipped.py | 33 ++-----------
 testing/vcs/test_vcs_1d_missing.py            | 26 ++---------
 testing/vcs/test_vcs_animate_boxfill.py       | 15 ++----
 testing/vcs/test_vcs_animate_isofill.py       | 23 ++++------
 testing/vcs/test_vcs_animate_isoline.py       | 27 ++++-------
 .../vcs/test_vcs_animate_isoline_colored.py   | 20 +++-----
 .../test_vcs_animate_isoline_text_labels.py   | 11 ++---
 ...vcs_animate_isoline_text_labels_colored.py | 10 ++--
 testing/vcs/test_vcs_animate_meshfill.py      | 10 +---
 testing/vcs/test_vcs_antialiasing.py          |  1 -
 testing/vcs/test_vcs_aspect_ratio.py          | 35 +++++---------
 testing/vcs/test_vcs_auto_time_labels.py      | 23 +++-------
 testing/vcs/test_vcs_autot_axis_titles.py     | 22 ++-------
 testing/vcs/test_vcs_bad_time_units.py        | 12 ++---
 testing/vcs/test_vcs_basic_gms.py             | 19 ++------
 testing/vcs/test_vcs_basic_text.py            | 17 ++-----
 testing/vcs/test_vcs_basic_vectors.py         | 19 ++------
 ...st_vcs_box_custom_as_def_vistrails_exts.py | 42 +++++------------
 .../test_vcs_boxfill_10x10_masked_numpy.py    | 28 +++--------
 testing/vcs/test_vcs_boxfill_10x10_numpy.py   | 27 +++--------
 testing/vcs/test_vcs_boxfill_custom.py        | 21 ++-------
 testing/vcs/test_vcs_boxfill_custom_ext1.py   | 22 ++-------
 .../vcs/test_vcs_boxfill_custom_ext1_ext2.py  | 22 ++-------
 testing/vcs/test_vcs_boxfill_custom_ext2.py   | 20 ++------
 ...t_vcs_boxfill_custom_non_default_levels.py | 24 ++--------
 .../test_vcs_boxfill_decreasing_latitude.py   | 27 ++---------
 testing/vcs/test_vcs_boxfill_lambert_crash.py | 17 ++-----
 testing/vcs/test_vcs_boxfill_lev1_lev2.py     | 35 ++++----------
 .../vcs/test_vcs_boxfill_lev1_lev2_ext1.py    | 37 +++++----------
 .../test_vcs_boxfill_lev1_lev2_ext1_ext2.py   | 39 +++++-----------
 .../vcs/test_vcs_boxfill_lev1_lev2_ext2.py    | 37 +++++----------
 .../test_vcs_boxfill_lev1_lev2_ta_missing.py  | 39 +++++-----------
 testing/vcs/test_vcs_boxfill_polar.py         | 31 +++----------
 testing/vcs/test_vcs_boxfill_robinson_wrap.py | 15 +-----
 testing/vcs/test_vcs_canvas_background.py     | 19 ++------
 .../vcs/test_vcs_canvas_background_update.py  | 20 ++------
 testing/vcs/test_vcs_click_info.py            | 20 ++------
 testing/vcs/test_vcs_close.py                 |  6 ---
 testing/vcs/test_vcs_colormaps_source.py      | 24 ++--------
 .../vcs/test_vcs_colorpicker_appearance.py    |  7 +--
 testing/vcs/test_vcs_configurator_resize.py   |  8 ++--
 testing/vcs/test_vcs_continents.py            | 25 ++--------
 testing/vcs/test_vcs_create_get.py            |  1 -
 testing/vcs/test_vcs_draw_logo_on.py          | 16 ++-----
 testing/vcs/test_vcs_fillarea_transparency.py | 17 ++-----
 testing/vcs/test_vcs_first_png_blank.py       | 19 ++------
 testing/vcs/test_vcs_flipNone.py              | 26 ++---------
 testing/vcs/test_vcs_flipX.py                 | 26 ++---------
 testing/vcs/test_vcs_flipXY.py                | 25 ++--------
 testing/vcs/test_vcs_flipY.py                 | 24 ++--------
 testing/vcs/test_vcs_gen_meshfill.py          | 29 ++----------
 .../test_vcs_gms_animate_projected_plots.py   | 23 ++--------
 testing/vcs/test_vcs_gms_patterns_hatches.py  | 16 ++-----
 testing/vcs/test_vcs_hatches_patterns.py      | 24 ++--------
 testing/vcs/test_vcs_import.py                |  1 -
 testing/vcs/test_vcs_infinity.py              | 20 ++------
 testing/vcs/test_vcs_iso_celine_part1.py      | 21 +++------
 testing/vcs/test_vcs_iso_celine_part2.py      | 25 +++-------
 ...st_vcs_isofill_data_read_north_to_south.py | 22 ++-------
 .../vcs/test_vcs_isofill_isoline_labels.py    | 29 ++----------
 .../vcs/test_vcs_isofill_mask_cell_shift.py   | 29 +++---------
 testing/vcs/test_vcs_isoline_labels.py        | 34 +++-----------
 .../vcs/test_vcs_isoline_labels_background.py | 26 ++---------
 ..._isoline_labels_multi_label_input_types.py | 46 +++++++------------
 .../vcs/test_vcs_isoline_labelskipdistance.py | 26 ++---------
 testing/vcs/test_vcs_isoline_numpy.py         | 22 +++------
 testing/vcs/test_vcs_isoline_width_stipple.py | 27 ++---------
 testing/vcs/test_vcs_issue_960_labels.py      | 26 ++++-------
 testing/vcs/test_vcs_lambert.py               | 23 ++--------
 testing/vcs/test_vcs_large_pattern_hatch.py   | 27 ++---------
 testing/vcs/test_vcs_legend.py                | 17 ++-----
 testing/vcs/test_vcs_lon_axes_freak_out.py    | 31 +++----------
 testing/vcs/test_vcs_markers.py               | 26 +++--------
 testing/vcs/test_vcs_matplotlib_colormap.py   | 26 ++---------
 testing/vcs/test_vcs_mercator_edge.py         | 23 ++--------
 testing/vcs/test_vcs_meshfill_draw_mesh.py    | 28 ++++-------
 testing/vcs/test_vcs_meshfill_no_wrapping.py  | 26 ++---------
 testing/vcs/test_vcs_meshfill_regular_grid.py | 23 ++--------
 testing/vcs/test_vcs_meshfill_vertices.py     | 21 ++-------
 testing/vcs/test_vcs_meshfill_zoom.py         | 27 +++--------
 testing/vcs/test_vcs_mintics.py               | 20 ++------
 testing/vcs/test_vcs_missing_colorname.py     | 24 ++--------
 ..._vcs_monotonic_decreasing_yxvsx_default.py | 29 ++++--------
 testing/vcs/test_vcs_oned_level_axis.py       | 27 +++--------
 testing/vcs/test_vcs_patterns.py              | 22 ++-------
 testing/vcs/test_vcs_plot_file_var.py         | 14 +++---
 .../test_vcs_plot_unstructured_via_boxfill.py | 20 ++------
 testing/vcs/test_vcs_png_to_base64.py         |  2 +-
 testing/vcs/test_vcs_png_window_resize.py     | 17 ++-----
 .../vcs/test_vcs_polar_set_opt_param_polar.py | 30 +++---------
 testing/vcs/test_vcs_remove_marker_none_1d.py | 24 ++--------
 testing/vcs/test_vcs_setcolormap.py           | 26 ++---------
 .../vcs/test_vcs_settings_color_name_rgba.py  | 27 +++--------
 .../test_vcs_settings_color_name_rgba_1d.py   | 22 ++-------
 ...st_vcs_settings_color_name_rgba_boxfill.py | 23 ++--------
 ...st_vcs_settings_color_name_rgba_isoline.py | 23 ++--------
 ...t_vcs_settings_color_name_rgba_meshfill.py | 23 ++--------
 testing/vcs/test_vcs_star_triangle_markers.py | 17 ++-----
 testing/vcs/test_vcs_taylor_2quads.py         | 33 ++-----------
 testing/vcs/test_vcs_taylor_template_ctl.py   | 29 ++----------
 testing/vcs/test_vcs_user_passed_date.py      | 17 ++-----
 .../test_vcs_user_passed_date_as_string.py    | 17 ++-----
 testing/vcs/test_vcs_vectors_missing.py       | 27 +++--------
 testing/vcs/test_vcs_vectors_robinson.py      | 16 ++-----
 testing/vcs/test_vcs_vectors_robinson_wrap.py | 16 ++-----
 testing/vcs/test_vcs_verify_boxfill_basics.py | 13 +++---
 testing/vcs/test_vcs_wmo_marker.py            | 17 ++-----
 testing/vcs/test_vcs_wmo_markers.py           | 25 +++-------
 testing/vcs/vtk_ui/vtk_ui_test.py             | 14 ++----
 .../vcsaddons/test_12_plot_one_leg_per_row.py | 15 ++----
 .../test_12_plot_one_leg_per_row_right.py     | 16 ++-----
 ...test_EzTemplate_12_plots_legd_direction.py | 17 ++-----
 ...t_EzTemplate_12_plots_margins_thickness.py | 15 ++----
 .../test_EzTemplate_12_plots_mix_glb_local.py | 14 +-----
 .../test_EzTemplate_12_plots_spacing.py       | 16 ++-----
 .../test_vcs_addons_EzTemplate_2x2.py         | 24 +++-------
 .../vcsaddons/test_vcsaddons_preview_2x2.py   | 16 ++-----
 124 files changed, 589 insertions(+), 2135 deletions(-)
 create mode 100644 Packages/testing/__init__.py
 rename testing/checkimage.py => Packages/testing/regression.py (84%)
 create mode 100755 Packages/testing/setup.py

diff --git a/Packages/testing/__init__.py b/Packages/testing/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/testing/checkimage.py b/Packages/testing/regression.py
similarity index 84%
rename from testing/checkimage.py
rename to Packages/testing/regression.py
index 9871f3557..68f381ce4 100644
--- a/testing/checkimage.py
+++ b/Packages/testing/regression.py
@@ -12,9 +12,28 @@ import os.path
 import re
 import sys
 import logging
+import vcs
 
 defaultThreshold=10.0
 
+def init():
+    testingDir = os.path.join(os.path.dirname(__file__), "..")
+    sys.path.append(testingDir)
+
+    vcsinst = vcs.init()
+    vcsinst.setantialiasing(0)
+    vcsinst.drawlogooff()
+    vcsinst.setbgoutputdimensions(1200,1091,units="pixels")
+    return vcsinst
+
+def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
+    vcsinst.png(fname)
+    sys.exit(check_result_image(fname, baseline, threshold))
+
+def run_wo_terminate(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
+    vcsinst.png(fname)
+    return check_result_image(fname, baseline, threshold)
+
 def image_compare(testImage, baselineImage):
     imageDiff = vtk.vtkImageDifference()
     imageDiff.SetInputData(testImage)
@@ -53,8 +72,8 @@ def find_alternates(fname):
             results.append(os.path.join(dirname, i))
     return results
 
-def check_result_image(fname, baselinefname, threshold = defaultThreshold,
-                       baseline = True, cleanup=True):
+def check_result_image(fname, baselinefname=sys.argv[1], threshold=defaultThreshold,
+                       baseline=True, cleanup=True):
     testImage = image_from_file(fname)
     if testImage is None:
         print "Testing image missing, test failed."
diff --git a/Packages/testing/setup.py b/Packages/testing/setup.py
new file mode 100755
index 000000000..70f790d7b
--- /dev/null
+++ b/Packages/testing/setup.py
@@ -0,0 +1,14 @@
+import os, sys
+from distutils.core import setup
+import cdat_info
+
+sys.path.append(os.environ.get('BUILD_DIR',"build"))
+
+setup(name="testing",
+      version=cdat_info.Version,
+      description="Testing infrastructure for cdat",
+      url="http://uvcdat.llnl.gov",
+      packages=['testing'],
+      package_dir={'testing': 'testing',},
+      install_requires=['numpy','vcs', 'vtk'],
+)
diff --git a/testing/vcs/test_vcs_1D_datawc.py b/testing/vcs/test_vcs_1D_datawc.py
index 1595a6cd7..8e671bb93 100644
--- a/testing/vcs/test_vcs_1D_datawc.py
+++ b/testing/vcs/test_vcs_1D_datawc.py
@@ -4,15 +4,13 @@ import vcs,numpy,cdms2,MV2,os,sys
 src=sys.argv[1]
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
 
-x.setbgoutputdimensions(1200,1091,units="pixels")
+import testing.regression as regression
+
+x = regression.init()
 yx =x.createyxvsx()
 
-data = """-11.14902417  -9.17390922  -7.29515002  
+data = """-11.14902417  -9.17390922  -7.29515002
 -7.51774549  -8.63608171
   -10.4827395   -9.93859485  -7.3394366   -5.39241468  -5.74825567
      -6.74967902  -7.09622319  -5.93836983  -4.04592997  -2.65591499
@@ -30,14 +28,9 @@ data = numpy.array(data,dtype=numpy.float)
 data = MV2.array(data)
 yx.datawc_x1 = 0
 yx.datawc_x2 = 80
-yx.datawc_y1 =-12 
-yx.datawc_y2 = 12 
+yx.datawc_y1 =-12
+yx.datawc_y2 = 12
 
 
 x.plot(data,yx,bg=1)
-fnm = "test_vcs_1D_datawc.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_1D_datawc.png", src)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_1D_datawc_missing.py b/testing/vcs/test_vcs_1D_datawc_missing.py
index 07e6f560a..d6caabc8e 100644
--- a/testing/vcs/test_vcs_1D_datawc_missing.py
+++ b/testing/vcs/test_vcs_1D_datawc_missing.py
@@ -1,19 +1,11 @@
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-yx =x.createyxvsx()
+x = regression.init()
+yx = x.createyxvsx()
 
 data = """
--999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. 
+-999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999. -999.
 0.059503571833625334
 0.059503571833625334 0.05664014775641405 0.05193557222118004
 0.04777129850801233 0.0407139313814465 0.029382624830271705
@@ -42,16 +34,5 @@ data = """
 """.split()
 data = numpy.array(data,dtype=numpy.float)
 data = MV2.masked_less(data,-900)
-#yx.datawc_x1 = 0
-#yx.datawc_x2 = 80
-##yx.datawc_y1 =-12 
-#yx.datawc_y2 = 12 
-
-
 x.plot(data,yx,bg=1)
-fnm = "test_vcs_1D_datawc_missing.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_1D_datawc_missing.png")
diff --git a/testing/vcs/test_vcs_1D_with_manyDs.py b/testing/vcs/test_vcs_1D_with_manyDs.py
index 1caba446e..28a6a7a8b 100644
--- a/testing/vcs/test_vcs_1D_with_manyDs.py
+++ b/testing/vcs/test_vcs_1D_with_manyDs.py
@@ -1,31 +1,9 @@
 
-import vcs,numpy,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
+x = regression.init()
 d = numpy.sin(numpy.arange(100))
-d=numpy.reshape(d,(10,10))
-
-
+d = numpy.reshape(d,(10,10))
 one = x.create1d()
-
 x.plot(d,one,bg=1)
-
-
-fnm = "test_1D_with_manyDs.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
-
+regression.run(x, "test_1D_with_manyDs.png", sys.argv[1])
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_1d_in_boxfill.py b/testing/vcs/test_vcs_1d_in_boxfill.py
index 292fe98a3..1da574394 100644
--- a/testing/vcs/test_vcs_1d_in_boxfill.py
+++ b/testing/vcs/test_vcs_1d_in_boxfill.py
@@ -1,29 +1,8 @@
 
-import vcs,numpy,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
+x = regression.init()
 d = numpy.sin(numpy.arange(100))
-
 b = x.createboxfill()
-
 x.plot(d,b,bg=1)
-
-
-fnm = "test_1d_in_boxfill.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
-
+regression.run(x, "test_1d_in_boxfill.png", sys.argv[1])
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py b/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py
index c350e4c59..f850f977e 100644
--- a/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py
+++ b/testing/vcs/test_vcs_1d_marker_not_shown_if_xaxis_flipped.py
@@ -1,42 +1,15 @@
-import vcs
-import numpy
-import MV2
-import cdms2
-import sys
-import os
 
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
+x = regression.init()
 data = MV2.array([4,5,6,7,1,3,7,9,])+230.
-
 p = cdms2.createAxis([2,5,100,200,500,800,850,1000])
-
 data.setAxis(0,p)
-
 data.id="jim"
-
 gm=x.create1d()
-
 gm.linewidth=0
 gm.datawc_x1=1000
 gm.datawc_x2=0
-
 gm.markersize=30
-
 x.plot(data,gm,bg=1)
-
-fnm = "test_1d_marker_not_shown_if_xaxis_flipped.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_1d_marker_not_shown_if_xaxis_flipped.png", sys.argv[1])
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_1d_missing.py b/testing/vcs/test_vcs_1d_missing.py
index 3a6880bdd..8c124e09c 100644
--- a/testing/vcs/test_vcs_1d_missing.py
+++ b/testing/vcs/test_vcs_1d_missing.py
@@ -3,15 +3,11 @@ import vcs,numpy,cdms2,MV2,os,sys
 src=sys.argv[1]
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
+import testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
 yx =x.createyxvsx()
-
-data = """-11.14902417  -9.17390922  -7.29515002  
+data = """-11.14902417  -9.17390922  -7.29515002
 -7.51774549  -8.63608171
   -10.4827395   -9.93859485  -7.3394366   -5.39241468  -5.74825567
      -6.74967902  -7.09622319  -5.93836983  -4.04592997  -2.65591499
@@ -30,17 +26,5 @@ data = MV2.array(data)
 
 data=MV2.masked_where(MV2.logical_and(data>-4,data<-2),data)
 
-#yx.datawc_x1 = 0
-#yx.datawc_x2 = 80
-##yx.datawc_y1 =-12 
-#yx.datawc_y2 = 12 
-
-
-x.plot(data,yx,bg=1)
-fnm = "test_vcs_1d_missing.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+x.plot(data, yx, bg=1)
+regression.run(x, "test_vcs_1d_missing.png", src)
diff --git a/testing/vcs/test_vcs_animate_boxfill.py b/testing/vcs/test_vcs_animate_boxfill.py
index 2bbd53c26..641b59edb 100644
--- a/testing/vcs/test_vcs_animate_boxfill.py
+++ b/testing/vcs/test_vcs_animate_boxfill.py
@@ -1,20 +1,14 @@
-import vcs
-import cdms2
-import os
-import sys
-import time
+import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
+
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
-
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
 
-x=vcs.init()
+x = regression.init()
 x.setantialiasing(0)
 x.drawlogooff()
 x.setbgoutputdimensions(1200,1091,units="pixels")
-
 gm=x.createboxfill()
 x.plot(s,gm,bg=1)
 x.animate.create()
@@ -26,8 +20,7 @@ src_pth = sys.argv[1]
 pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
-  print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_animate_isofill.py b/testing/vcs/test_vcs_animate_isofill.py
index ba5ea0e8d..591d66362 100644
--- a/testing/vcs/test_vcs_animate_isofill.py
+++ b/testing/vcs/test_vcs_animate_isofill.py
@@ -1,20 +1,13 @@
-import vcs
-import cdms2
-import os
-import sys
-import time
+
+import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
+
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
-
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",slice(0,12)) # read only 12 times steps to speed up things
 
+x = regression.init()
 gm=x.createisofill()
 x.plot(s,gm,bg=1)
 x.animate.create()
@@ -26,8 +19,8 @@ src_pth = sys.argv[1]
 pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
-  print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),
+         regression.defaultThreshold)
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_animate_isoline.py b/testing/vcs/test_vcs_animate_isoline.py
index 41e0c7318..cea333d3b 100644
--- a/testing/vcs/test_vcs_animate_isoline.py
+++ b/testing/vcs/test_vcs_animate_isoline.py
@@ -1,33 +1,24 @@
-import vcs
-import cdms2
-import os
-import sys
-import time
+import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
+
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
-
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",slice(0,12)) # read only 12 times steps to speed up things
 
-iso=x.createisoline()
-x.plot(s,iso,bg=1)
+x = regression.init()
+iso = x.createisoline()
+x.plot(s,iso, bg=1)
 x.animate.create()
 print "Saving now"
 prefix= os.path.split(__file__)[1][:-3]
 x.animate.save("%s.mp4"%prefix)
-pngs = x.animate.close(preserve_pngs = True) # so we can look at them again
+pngs = x.animate.close(preserve_pngs=True) # so we can look at them again
 src_pth = sys.argv[1]
 pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
-  print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_animate_isoline_colored.py b/testing/vcs/test_vcs_animate_isoline_colored.py
index 4fed45c86..4519ac16c 100644
--- a/testing/vcs/test_vcs_animate_isoline_colored.py
+++ b/testing/vcs/test_vcs_animate_isoline_colored.py
@@ -1,19 +1,12 @@
-import vcs
-import cdms2
-import os
-import sys
-import time
+import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
+
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
 
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",slice(0,12)) # read only 12 times steps to speed up things
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
 
 iso=x.createisoline()
 levs = range(0,101,10)
@@ -34,8 +27,7 @@ src_pth = sys.argv[1]
 pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
-  print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_animate_isoline_text_labels.py b/testing/vcs/test_vcs_animate_isoline_text_labels.py
index 7a3be1fc5..0e83c02c6 100644
--- a/testing/vcs/test_vcs_animate_isoline_text_labels.py
+++ b/testing/vcs/test_vcs_animate_isoline_text_labels.py
@@ -1,11 +1,7 @@
-import vcs
-import cdms2
-import os
-import sys
-import time
+import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
+
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
 
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
@@ -27,8 +23,7 @@ src_pth = sys.argv[1]
 pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
-  print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py b/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py
index cf009e4a8..02711e219 100644
--- a/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py
+++ b/testing/vcs/test_vcs_animate_isoline_text_labels_colored.py
@@ -1,11 +1,7 @@
-import vcs
-import cdms2
-import os
-import sys
-import time
+import vcs, numpy, cdms2, MV2, os, sys, time, testing.regression as regression
+
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
 
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 s=f("clt",slice(0,12)) # read only 12 times steps to speed up things
@@ -36,7 +32,7 @@ pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
   print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_animate_meshfill.py b/testing/vcs/test_vcs_animate_meshfill.py
index 78d6b1551..aa89a8639 100644
--- a/testing/vcs/test_vcs_animate_meshfill.py
+++ b/testing/vcs/test_vcs_animate_meshfill.py
@@ -1,12 +1,7 @@
-import vcs
-import cdms2
-import os
-import sys
-import MV2
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
 
 f=cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc"))
 s=f("sample")
@@ -38,8 +33,7 @@ src_pth = sys.argv[1]
 pth = os.path.join(src_pth,prefix)
 ret = 0
 for p in pngs:
-  print "Checking:",p
-  ret += checkimage.check_result_image(p,os.path.join(pth,os.path.split(p)[1]),checkimage.defaultThreshold)
+  ret += regression.check_result_image(p,os.path.join(pth,os.path.split(p)[1]))
 if ret == 0:
     os.removedirs(os.path.split(p)[0])
     os.remove("%s.mp4" % prefix)
diff --git a/testing/vcs/test_vcs_antialiasing.py b/testing/vcs/test_vcs_antialiasing.py
index 34f43e040..f744d3e04 100644
--- a/testing/vcs/test_vcs_antialiasing.py
+++ b/testing/vcs/test_vcs_antialiasing.py
@@ -1,4 +1,3 @@
-
 import vcs
 x=vcs.init()
 x.drawlogooff()
diff --git a/testing/vcs/test_vcs_aspect_ratio.py b/testing/vcs/test_vcs_aspect_ratio.py
index 1e59304a3..9e3cb3767 100644
--- a/testing/vcs/test_vcs_aspect_ratio.py
+++ b/testing/vcs/test_vcs_aspect_ratio.py
@@ -1,27 +1,20 @@
-
-import vcs
-import cdms2
-import sys
-import os
-import MV2
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
+src = sys.argv[1]
 pth0 = os.path.dirname(_file__)
 pth = os.path.join(pth0,"..")
 sys.path.append(pth)
-import checkimage
 
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",time=slice(0,1),squeeze=1)
-gm=vcs.createisofill()
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",time=slice(0,1),squeeze=1)
+gm = vcs.createisofill()
 
 def plot_a_ratio(s,gm,ratio):
     ret = 0
-    x=vcs.init()
-x.drawlogooff()
+    x = regression.init()
+    x.drawlogooff()
     x.open()
     x.geometry(400,800)
-    y=vcs.init()
+    y = regression.init()
     y.open()
     y.geometry(800,400)
     for X in [x,y]:
@@ -32,19 +25,13 @@ x.drawlogooff()
             orient = "port"
         fnm = "aspect_ratio_%s_%s.png" % (orient,ratio)
         X.png(fnm)
-        print "fnm:",fnm
         src = os.path.join(pth0,fnm)
-        print "src:",src
-        ret += checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+        ret += regression.check_result_image(fnm, src)
     return ret
 
-ret = 0 
+ret = 0
 for ratio in ["1t","2t",".5t","autot"]:
     ret  += plot_a_ratio(s,gm,ratio)
 
 
-sys.exit(ret)
-
-
-
-
+sys.exit(ret)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_auto_time_labels.py b/testing/vcs/test_vcs_auto_time_labels.py
index 2dfa661a9..e5422b29c 100644
--- a/testing/vcs/test_vcs_auto_time_labels.py
+++ b/testing/vcs/test_vcs_auto_time_labels.py
@@ -1,18 +1,7 @@
-import vcs,cdms2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",longitude=slice(34,35),squeeze=1)
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+import vcs, cdms2, os, sys, testing.regression as regression
+
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",longitude=slice(34,35),squeeze=1)
+x = regression.init()
 x.plot(s,bg=1)
-fnm = "test_vcs_auto_time_labels.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_auto_time_labels.png", sys.argv[1])
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_autot_axis_titles.py b/testing/vcs/test_vcs_autot_axis_titles.py
index ec485ccc0..dcc0f00b1 100644
--- a/testing/vcs/test_vcs_autot_axis_titles.py
+++ b/testing/vcs/test_vcs_autot_axis_titles.py
@@ -1,7 +1,4 @@
-import vcs
-import cdms2
-import os
-import sys
+import vcs, cdms2, os, sys, testing.regression as regression
 
 testConfig = {'a_boxfill': ('clt.nc', 'clt'),
               'a_mollweide_boxfill': ('clt.nc', 'clt'),
@@ -11,10 +8,6 @@ testConfig = {'a_boxfill': ('clt.nc', 'clt'),
               'a_robinson_isoline': ('clt.nc', 'clt')}
 
 # Tests if ratio=autot works correctly for background and foreground plots
-src = sys.argv[1]
-bg = 1
-if (sys.argv[2] == 'foreground'):
-    bg = 0
 plot = sys.argv[3]
 x_over_y = sys.argv[4]
 if (x_over_y == '0.5'):
@@ -26,12 +19,9 @@ else:
 pth = os.path.join(os.path.dirname(__file__), "..")
 sys.path.append(pth)
 
-import checkimage
-
 f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0])
 s = f(testConfig[plot][1])
-
-x = vcs.init(bg=bg, geometry=(xSize, ySize))
+x = regression.init(bg=bg, geometry=(xSize, ySize))
 
 # graphics method
 if (plot.find('boxfill') != -1):
@@ -50,10 +40,4 @@ x.setantialiasing(0)
 x.drawlogooff()
 x.plot(s, gm, ratio="autot")
 name = "test_autot_axis_titles_" + plot[2:] + "_" + x_over_y + "_" + str(bg) + ".png"
-x.png(name)
-
-print "name:", name
-print "src:", src
-
-ret = checkimage.check_result_image(name, src, checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, name, sys.argv[1])
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_bad_time_units.py b/testing/vcs/test_vcs_bad_time_units.py
index b89c2f7a7..0bdcd16c2 100644
--- a/testing/vcs/test_vcs_bad_time_units.py
+++ b/testing/vcs/test_vcs_bad_time_units.py
@@ -1,8 +1,8 @@
-import cdms2,vcs
-import os,sys
+import cdms2, vcs
+import os, sys
 
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",slice(0,1))
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",slice(0,1))
 s.getTime().units="XXX-))rvv"
-x=vcs.init()
-x.plot(s,bg=1)
+x = vcs.init()
+x.plot(s, bg=1)
diff --git a/testing/vcs/test_vcs_basic_gms.py b/testing/vcs/test_vcs_basic_gms.py
index daa144d9d..2cffb86e6 100644
--- a/testing/vcs/test_vcs_basic_gms.py
+++ b/testing/vcs/test_vcs_basic_gms.py
@@ -1,6 +1,4 @@
-
-import sys,os
-import argparse
+import argparse, os, sys, cdms2, MV2, testing.regression as regression, vcs, vtk
 
 p = argparse.ArgumentParser(description="Basic gm testing code for vcs")
 p.add_argument("--source", dest="src", help="source image file")
@@ -25,20 +23,9 @@ args = p.parse_args(sys.argv[1:])
 
 gm_type= args.gm
 src = args.src
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-import vcs
-import sys
-import cdms2
-import vtk
-import os
-import MV2
-
 bg = not args.show
 
-x=vcs.init()
+x = vcs.init()
 x.setantialiasing(0)
 x.drawlogooff()
 if bg:
@@ -143,7 +130,7 @@ print "fnm:",fnm
 print "src:",src
 if args.show:
     raw_input("Press Enter")
-ret = checkimage.check_result_image(fnm+'.png',src,20., cleanup=not args.keep)
+ret = regression.check_result_image(fnm+'.png',src,20., cleanup=not args.keep)
 if args.show:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcs/test_vcs_basic_text.py b/testing/vcs/test_vcs_basic_text.py
index d46bd4f48..d69f37ce0 100644
--- a/testing/vcs/test_vcs_basic_text.py
+++ b/testing/vcs/test_vcs_basic_text.py
@@ -1,11 +1,6 @@
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
+x = regression.init()
 x.drawlogooff()
 x.setbgoutputdimensions(1200,1091,units="pixels")
 txt=x.createtext()
@@ -16,10 +11,4 @@ txt.halign = "center"
 txt.valign="base"
 txt.angle=45
 x.plot(txt,bg=1)
-fnm = "test_basic_text.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_basic_text.png", sys.argv[1])
diff --git a/testing/vcs/test_vcs_basic_vectors.py b/testing/vcs/test_vcs_basic_vectors.py
index 561f7f2d8..37626e670 100644
--- a/testing/vcs/test_vcs_basic_vectors.py
+++ b/testing/vcs/test_vcs_basic_vectors.py
@@ -1,6 +1,5 @@
+import argparse, os, sys, numpy, cdms2, MV2, vcs, vtk
 
-import sys,os
-import argparse
 
 p = argparse.ArgumentParser(description="Basic gm testing code for vcs")
 p.add_argument("--source", dest="src", help="source image file")
@@ -18,21 +17,11 @@ args = p.parse_args(sys.argv[1:])
 
 if not args.show:
   src = args.src
-  pth = os.path.join(os.path.dirname(__file__),"..")
-  sys.path.append(pth)
-  import checkimage
-
-import vcs
-import sys
-import cdms2
-import vtk
-import os
-import MV2
-import numpy
+  import testing.regression as regression
 
 bg = not args.show
 
-x=vcs.init()
+x = vcs.init()
 x.setantialiasing(0)
 x.drawlogooff()
 if bg:
@@ -95,7 +84,7 @@ else:
   x.png(fnm)
   print "fnm:",fnm
   print "src:",src
-  ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep)
+  ret = regression.check_result_image(fnm+'.png',src, regression.defaultThreshold, cleanup=not args.keep)
 if args.show:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py b/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py
index c012c09ca..7d81b8981 100644
--- a/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py
+++ b/testing/vcs/test_vcs_box_custom_as_def_vistrails_exts.py
@@ -1,30 +1,12 @@
-import vcs
-import cdms2
-import os
-import sys
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",slice(0,1),squeeze=1)
-
-x=vcs.init()
-x.drawlogooff()
-x.setantialiasing(0)
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-gm=x.createboxfill()
-gm.boxfill_type="custom"
-gm.levels=[1.e20,1.e20]
-gm.ext_1="y"
-gm.ext_2="y"
-
-x.plot(s,gm,bg=1)
-fnm = "test_box_custom_as_def_vistrails_exts.png"
-src =sys.argv[1]
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+import os, sys, cdms2, vcs, testing.regression as regression
+
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",slice(0,1),squeeze=1)
+x = regression.init()
+gm = x.createboxfill()
+gm.boxfill_type = "custom"
+gm.levels = [1.e20,1.e20]
+gm.ext_1 = "y"
+gm.ext_2 = "y"
+x.plot(s, gm, bg=1)
+regression.run(x, "test_box_custom_as_def_vistrails_exts.png", sys.argv[1])
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py b/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py
index b2cdf8319..2444cc8a8 100644
--- a/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py
+++ b/testing/vcs/test_vcs_boxfill_10x10_masked_numpy.py
@@ -1,23 +1,9 @@
+import vcs, numpy, os, sys, testing.regression as regression
 
-import vcs,numpy,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+s = numpy.sin(numpy.arange(100))
+s = numpy.reshape(s,(10,10))
+s = numpy.ma.masked_greater(s,.5)
 
-s= numpy.sin(numpy.arange(100))
-s=numpy.reshape(s,(10,10))
-s=numpy.ma.masked_greater(s,.5)
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-x.plot(s,bg=1)
-fnm= "test_vcs_boxfill_10x10_masked_numpy.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+x = regression.init()
+x.plot(s, bg=1)
+regression.run(x, "test_vcs_boxfill_10x10_masked_numpy.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_10x10_numpy.py b/testing/vcs/test_vcs_boxfill_10x10_numpy.py
index 079105198..a45aa5889 100644
--- a/testing/vcs/test_vcs_boxfill_10x10_numpy.py
+++ b/testing/vcs/test_vcs_boxfill_10x10_numpy.py
@@ -1,22 +1,7 @@
+import vcs, numpy, os, sys, testing.regression as regression
 
-import vcs,numpy,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-s= numpy.sin(numpy.arange(100))
-s=numpy.reshape(s,(10,10))
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-x.plot(s,bg=1)
-fnm= "test_vcs_boxfill_10x10_numpy.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+s = numpy.sin(numpy.arange(100))
+s = numpy.reshape(s,(10,10))
+x = regression.init()
+x.plot(s)
+regression.run(x, "test_vcs_boxfill_10x10_numpy.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_custom.py b/testing/vcs/test_vcs_boxfill_custom.py
index 16685d971..5330a1103 100644
--- a/testing/vcs/test_vcs_boxfill_custom.py
+++ b/testing/vcs/test_vcs_boxfill_custom.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import cdms2, os, sys, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -10,10 +7,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 boxfill=canvas.createboxfill()
@@ -24,14 +18,5 @@ boxfill.boxfill_type = 'custom'
 canvas.plot(clt, boxfill, bg=1)
 
 # Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
 # Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_boxfill_custom.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_boxfill_custom.png")
diff --git a/testing/vcs/test_vcs_boxfill_custom_ext1.py b/testing/vcs/test_vcs_boxfill_custom_ext1.py
index dd16ab837..7a5e2005e 100644
--- a/testing/vcs/test_vcs_boxfill_custom_ext1.py
+++ b/testing/vcs/test_vcs_boxfill_custom_ext1.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import cdms2, os, sys, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -10,10 +7,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 boxfill=canvas.createboxfill()
@@ -28,14 +22,4 @@ boxfill.fillareacolors=vcs.getcolors(boxfill.levels)
 canvas.plot(clt, boxfill, bg=1)
 
 # Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_boxfill_custom_ext1.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_boxfill_custom_ext1.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py b/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py
index 68b5a9a41..744071671 100644
--- a/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py
+++ b/testing/vcs/test_vcs_boxfill_custom_ext1_ext2.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import os, sys, cdms2, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -10,10 +7,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 boxfill=canvas.createboxfill()
@@ -29,14 +23,4 @@ boxfill.fillareacolors=vcs.getcolors(boxfill.levels)
 canvas.plot(clt, boxfill, bg=1)
 
 # Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_boxfill_custom_ext1_ext2.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_boxfill_custom_ext1_ext2.png")
diff --git a/testing/vcs/test_vcs_boxfill_custom_ext2.py b/testing/vcs/test_vcs_boxfill_custom_ext2.py
index 959fc2c6c..d45950bdb 100644
--- a/testing/vcs/test_vcs_boxfill_custom_ext2.py
+++ b/testing/vcs/test_vcs_boxfill_custom_ext2.py
@@ -3,6 +3,8 @@ import os
 import sys
 import vcs
 
+import testing.regression as regression
+
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 clt = dataFile("clt")
@@ -10,10 +12,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 boxfill=canvas.createboxfill()
@@ -27,15 +26,4 @@ boxfill.fillareacolors=vcs.getcolors(boxfill.levels)
 
 canvas.plot(clt, boxfill, bg=1)
 
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_boxfill_custom_ext2.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_boxfill_custom_ext2.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py b/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py
index 7363d2250..b84db2bb5 100644
--- a/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py
+++ b/testing/vcs/test_vcs_boxfill_custom_non_default_levels.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import cdms2, os, sys, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -10,10 +7,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 boxfill=canvas.createboxfill()
@@ -25,16 +19,4 @@ boxfill.levels=levels
 boxfill.fillareacolors=vcs.getcolors(levels)
 
 canvas.plot(clt, boxfill, bg=1)
-
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_boxfill_custom_no_default_levels.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_boxfill_custom_no_default_levels.png")
diff --git a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py
index 009b947a9..1f727e3b5 100755
--- a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py
+++ b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py
@@ -1,23 +1,10 @@
 #!/usr/bin/env python
-import cdms2
-import cdutil
-import os
-import sys
-import vcs
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
+import cdms2, cdutil, os, sys, vcs, testing.regression as regression
 
 f = cdms2.open(sys.argv[2])
 ice = f("variable_6")
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 900, units="pixels")
+x = regression.init()
 
-#gm = x.createisofill()
-#gm.label = "y"
 gm = x.createboxfill()
 gm.boxfill_type = "custom"
 
@@ -44,12 +31,8 @@ tmpl.legend.y1 = .03
 tmpl.legend.y2 = .055
 tmpl.max.priority = 1
 
-#tmpl.crdate.priority=1
-#tmpl.crdate.x=.8
-#tmpl.crdate.y=.95
 txt = x.createtext()
 txt.height = 20
-#txt.color=242
 txt.valign = "half"
 txt.halign = "center"
 
@@ -69,8 +52,4 @@ gm.datawc_y2 = 30
 gm.datawc_y1 = 90
 
 x.plot(ice, gm, tmpl, bg = 1)
-fnm = "test_boxfill_decreasing_latitude.png"
-x.png(fnm)
-ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold)
-sys.exit(ret)
-
+regression.run(x, "test_boxfill_decreasing_latitude.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_lambert_crash.py b/testing/vcs/test_vcs_boxfill_lambert_crash.py
index f1827882f..f445ba555 100644
--- a/testing/vcs/test_vcs_boxfill_lambert_crash.py
+++ b/testing/vcs/test_vcs_boxfill_lambert_crash.py
@@ -1,17 +1,10 @@
 #!/usr/bin/env python
-import cdms2
-import os
-import sys
-import vcs
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
+import cdms2, os, sys, vcs, testing.regression as regression
 
 f = cdms2.open(sys.argv[2])
-a=f("Z3")
+a = f("Z3")
 
-x=vcs.init()
+x = regression.init()
 x.setantialiasing(0)
 x.drawlogooff()
 x.setbgoutputdimensions(1200, 900, units="pixels")
@@ -24,6 +17,4 @@ x.plot(a(latitude=(20,60),longitude=(-160,-120)),b, bg=1)
 fileName = os.path.basename(__file__)
 fileName = os.path.splitext(fileName)[0]
 fileName += '.png'
-x.png(fileName)
-ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold)
-sys.exit(ret)
+ret = regression.run(x, fileName)
diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2.py
index 5c69d7af3..c5b5cbcbe 100644
--- a/testing/vcs/test_vcs_boxfill_lev1_lev2.py
+++ b/testing/vcs/test_vcs_boxfill_lev1_lev2.py
@@ -1,25 +1,10 @@
-
-import cdms2,sys,vcs,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-f=cdms2.open(vcs.sample_data+"/clt.nc")
-s=f("clt",slice(0,1),squeeze=1)
-b=x.createboxfill()
-b.level_1=.5
-b.level_2=14.5
-x.plot(s,b,bg=1)
-
-fnm= "test_boxfill_lev1_lev2.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
+import os, sys, cdms2, vcs, testing.regression as regression
+
+x = regression.init()
+f = cdms2.open(vcs.sample_data+"/clt.nc")
+s = f("clt",slice(0,1),squeeze=1)
+b = x.createboxfill()
+b.level_1 = .5
+b.level_2 = 14.5
+x.plot(s, b, bg=1)
+regression.run(x, "test_boxfill_lev1_lev2.png")
diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py
index 594949238..67f87029e 100644
--- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py
+++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1.py
@@ -1,26 +1,11 @@
-
-import cdms2,sys,vcs,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-f=cdms2.open(vcs.sample_data+"/clt.nc")
-s=f("clt",slice(0,1),squeeze=1)
-b=x.createboxfill()
-b.level_1=20
-b.level_2=80
-b.ext_1="y"
-x.plot(s,b,bg=1)
-
-fnm= "test_boxfill_lev1_lev2_ext1.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
+import os, sys, cdms2, vcs, testing.regression as regression
+
+x = regression.init()
+f = cdms2.open(vcs.sample_data+"/clt.nc")
+s = f("clt",slice(0,1),squeeze=1)
+b = x.createboxfill()
+b.level_1 = 20
+b.level_2 = 80
+b.ext_1 = "y"
+x.plot(s, b, bg=1)
+regression.run(x, "test_boxfill_lev1_lev2_ext1.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py
index 9e355d1e1..dc7958c59 100644
--- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py
+++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext1_ext2.py
@@ -1,27 +1,12 @@
-
-import cdms2,sys,vcs,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-f=cdms2.open(vcs.sample_data+"/clt.nc")
-s=f("clt",slice(0,1),squeeze=1)
-b=x.createboxfill()
-b.level_1=20
-b.level_2=80
-b.ext_1="y"
-b.ext_2="y"
-x.plot(s,b,bg=1)
-
-fnm= "test_boxfill_lev1_lev2_ext1_ext2.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
+import os, sys, cdms2, vcs, testing.regression as regression
+
+x = regression.init()
+f = cdms2.open(vcs.sample_data+"/clt.nc")
+s = f("clt", slice(0,1), squeeze=1)
+b = x.createboxfill()
+b.level_1 = 20
+b.level_2 = 80
+b.ext_1 = "y"
+b.ext_2 = "y"
+x.plot(s, b, bg=1)
+regression.run(x, "test_boxfill_lev1_lev2_ext1_ext2.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py
index 375c93d8a..398325eab 100644
--- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py
+++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ext2.py
@@ -1,26 +1,11 @@
-
-import cdms2,sys,vcs,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-f=cdms2.open(vcs.sample_data+"/clt.nc")
-s=f("clt",slice(0,1),squeeze=1)
-b=x.createboxfill()
-b.level_1=20
-b.level_2=80
-b.ext_2="y"
-x.plot(s,b,bg=1)
-
-fnm= "test_boxfill_lev1_lev2_ext2.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
+import os, sys, cdms2, vcs, testing.regression as regression
+
+x = regression.init()
+f = cdms2.open(vcs.sample_data+"/clt.nc")
+s = f("clt",slice(0,1),squeeze=1)
+b = x.createboxfill()
+b.level_1 = 20
+b.level_2 = 80
+b.ext_2 = "y"
+x.plot(s, b, bg=1)
+regression.run(x, "test_boxfill_lev1_lev2_ext2.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py b/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py
index 984179e5c..d2a39a1ba 100644
--- a/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py
+++ b/testing/vcs/test_vcs_boxfill_lev1_lev2_ta_missing.py
@@ -1,28 +1,11 @@
-
-import cdms2,sys,vcs,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-f=cdms2.open(vcs.sample_data+"/ta_ncep_87-6-88-4.nc")
-s=f("ta",slice(0,1),longitude=slice(34,35),squeeze=1)-273.15
-s=cdms2.MV2.masked_less(s,-45.)
-b=x.createboxfill()
-b.level_1=-40
-b.level_2=40
-x.plot(s,b,bg=1)
-
-fnm= "test_boxfill_lev1_lev2_ta_missing.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-raw_input()
-
+import os, sys, cdms2, vcs, testing.regression as regression
+
+x = regression.init()
+f = cdms2.open(vcs.sample_data+"/ta_ncep_87-6-88-4.nc")
+s = f("ta",slice(0,1),longitude=slice(34,35),squeeze=1)-273.15
+s = cdms2.MV2.masked_less(s,-45.)
+b = x.createboxfill()
+b.level_1 = -40
+b.level_2 = 40
+x.plot(s, b, bg=1)
+regression.run(x, "test_boxfill_lev1_lev2_ta_missing.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_polar.py b/testing/vcs/test_vcs_boxfill_polar.py
index e4f534c9d..869d09802 100644
--- a/testing/vcs/test_vcs_boxfill_polar.py
+++ b/testing/vcs/test_vcs_boxfill_polar.py
@@ -1,33 +1,16 @@
-#!/usr/bin/env python
-import cdms2
-import os
-import sys
-import vcs
+import os, sys, cdms2, vcs, testing.regression as regression
 
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
 
 f = cdms2.open(vcs.sample_data + "/clt.nc")
-a=f("clt")
+a = f("clt")
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 900, units="pixels")
-
-p=x.getprojection("polar")
-b=x.createboxfill()
-b.projection=p
-#b.datawc_y1 = 90
-#b.datawc_y2 = -90
-
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
+p = x.getprojection("polar")
+b = x.createboxfill()
+b.projection = p
 x.plot(a(latitude=(90,-90)), b, bg=1)
 
 fileName = os.path.basename(__file__)
 fileName = os.path.splitext(fileName)[0]
 fileName += '.png'
-x.png(fileName)
-ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fileName)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_boxfill_robinson_wrap.py b/testing/vcs/test_vcs_boxfill_robinson_wrap.py
index 81b3206bd..de66e516c 100644
--- a/testing/vcs/test_vcs_boxfill_robinson_wrap.py
+++ b/testing/vcs/test_vcs_boxfill_robinson_wrap.py
@@ -1,15 +1,7 @@
-#!/usr/bin/env python
-import cdms2, cdutil, genutil
-import vcs,os
-import sys
+import os, sys, cdms2, cdutil, genutil, vcs, testing.regression as regression
 
 # This tests if extending the longitude to more than 360 decrees is handled correctly by
 # proj4. See https://github.com/UV-CDAT/uvcdat/issues/1728 for more information.
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
-
-
 cdmsfile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 clt2 = cdmsfile('clt')
 clt3 = clt2(latitude=(-90.0, 90.0),squeeze=1,longitude=(-180, 200.0),time=('1979-01', '1988-12'),)
@@ -19,7 +11,4 @@ kwargs = {}
 kwargs[ 'cdmsfile' ] = cdmsfile.id
 kwargs['bg'] = 1
 canvas.plot(clt3, gmBoxfill, **kwargs)
-fnm = "test_robinson_wrap.png"
-canvas.png(fnm)
-ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_robinson_wrap.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_canvas_background.py b/testing/vcs/test_vcs_canvas_background.py
index 1d39b330d..2c72b51f3 100644
--- a/testing/vcs/test_vcs_canvas_background.py
+++ b/testing/vcs/test_vcs_canvas_background.py
@@ -1,19 +1,6 @@
-import vcs, cdms2, os, sys
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(500,500,units="pixels")
+import os, sys, cdms2, vcs, testing.regression as regression
 
+x = regression.init()
 x.backgroundcolor = (255, 255, 255)
 x.open()
-fnm = "test_backgroundcolor_white.png"
-x.png(fnm)
-
-src=sys.argv[1]
-ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_backgroundcolor_white.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_canvas_background_update.py b/testing/vcs/test_vcs_canvas_background_update.py
index 454f0ef09..a28c08713 100644
--- a/testing/vcs/test_vcs_canvas_background_update.py
+++ b/testing/vcs/test_vcs_canvas_background_update.py
@@ -1,22 +1,8 @@
-import vcs, cdms2, os, sys
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x = vcs.init()
-
-x.drawlogooff()
-x.setbgoutputdimensions(500,500, units="pixels")
+import os, sys, cdms2, vcs, testing.regression as regression
 
+x = regression.init()
 x.backgroundcolor = (255, 255, 255)
 x.open()
 x.backgroundcolor = (255, 255, 0)
 x.update()
-fnm = "test_backgroundcolor_yellow.png"
-x.png(fnm)
-
-src=sys.argv[1]
-ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
-
-sys.exit(ret)
+regression.run(x, "test_backgroundcolor_yellow.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_click_info.py b/testing/vcs/test_vcs_click_info.py
index 0fe587792..c16a6c0d4 100644
--- a/testing/vcs/test_vcs_click_info.py
+++ b/testing/vcs/test_vcs_click_info.py
@@ -1,7 +1,4 @@
-import cdms2
-import sys
-import vcs
-import os
+import os, sys, cdms2, vcs, testing.regression as regression
 
 testConfig = {'a_boxfill': ('clt.nc', 'clt', (200, 200)),
               'a_mollweide_boxfill': ('clt.nc', 'clt', (222, 322)),
@@ -11,15 +8,7 @@ testConfig = {'a_boxfill': ('clt.nc', 'clt', (200, 200)),
 # Tests if the info produced when clicking on a map is correct.
 src = sys.argv[1]
 plot = sys.argv[2]
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-# Needs to set the size of window so it is consistent accross
-# test platforms
-x.open(814, 606)
+x = regression.init()
 
 # data
 f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0])
@@ -47,7 +36,4 @@ fileName = os.path.basename(src)
 fileName = os.path.splitext(fileName)[0]
 fileName += '.png'
 
-x.png(fileName, width=814, height= 606)
-
-ret = checkimage.check_result_image(fileName, src, checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fileName)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_close.py b/testing/vcs/test_vcs_close.py
index 7bf007224..3457a648e 100644
--- a/testing/vcs/test_vcs_close.py
+++ b/testing/vcs/test_vcs_close.py
@@ -1,7 +1,5 @@
 import os, sys, vcs, cdms2
-#import checkimage
 
-#src=sys.argv[1]
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
 cdmsfile = cdms2.open(vcs.sample_data+"/clt.nc")
@@ -9,8 +7,4 @@ data = cdmsfile('clt')
 x = vcs.init()
 x.plot(data, bg=1)
 x.close()
-#x.plot(data[4][1:89], bg=1)
-#fnm = "test_vcs_close.png"
-#x.png(fnm)
-#ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
 sys.exit(0)
diff --git a/testing/vcs/test_vcs_colormaps_source.py b/testing/vcs/test_vcs_colormaps_source.py
index 1dcc7d880..2cfc02721 100644
--- a/testing/vcs/test_vcs_colormaps_source.py
+++ b/testing/vcs/test_vcs_colormaps_source.py
@@ -1,27 +1,12 @@
-import vcs
-import argparse
-import cdms2
-import  os
-import sys
-
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import argparse, os, sys, cdms2, vcs, testing.regression as regression
 
 parser = argparse.ArgumentParser()
-
 parser.add_argument("-g",dest="gm",default="boxfill",choices = ["boxfill","isofill","meshfill","isoline","vector","1d"])
 parser.add_argument("-s",dest="src",default="vcs",choices=["vcs","canvas","gm"])
 parser.add_argument("-b",dest="baseline")
-
-
 args = parser.parse_args()
 
-x=vcs.init()
-x.setantialiasing(0)
-x.setbgoutputdimensions(1200, 1091, units="pixels")
-x.drawlogooff()
+x = regression.init()
 
 exec("gm = x.create%s()" % args.gm)
 
@@ -55,7 +40,4 @@ else:
 fnm = "test_vcs_colormaps_source_%s_%s.png" % (args.gm,args.src)
 x.png(fnm)
 baselineImage = args.baseline
-ret = checkimage.check_result_image(fnm, baselineImage,
-                                    checkimage.defaultThreshold)
-
-sys.exit(ret)
+ret = regression.run(x, fnm, baselineImage)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_colorpicker_appearance.py b/testing/vcs/test_vcs_colorpicker_appearance.py
index c92534071..4ccba61fd 100644
--- a/testing/vcs/test_vcs_colorpicker_appearance.py
+++ b/testing/vcs/test_vcs_colorpicker_appearance.py
@@ -1,7 +1,6 @@
 import vcs, vtk
 
 picker = vcs.colorpicker.ColorPicker(500, 250, None, 0)
-
 win = picker.render_window
 
 win.Render()
@@ -16,8 +15,6 @@ png_writer.Write()
 
 import sys, os
 if len(sys.argv) > 1:
-    src = sys.argv[1]
-    sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
-    import checkimage
-    ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
+    import testing.regression as regression
+    ret = regression.check_result_image(fnm, sys.argv[1])
     sys.exit(ret)
diff --git a/testing/vcs/test_vcs_configurator_resize.py b/testing/vcs/test_vcs_configurator_resize.py
index b6179626d..7692e6218 100644
--- a/testing/vcs/test_vcs_configurator_resize.py
+++ b/testing/vcs/test_vcs_configurator_resize.py
@@ -20,9 +20,7 @@ png_writer.Write()
 
 import sys, os
 if len(sys.argv) > 1:
-    pth = os.path.join(os.path.dirname(__file__), "..")
-    sys.path.append(pth)
-    import checkimage
+    import testing.regression as regression
     src = sys.argv[1]
-    ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
-    sys.exit(ret)
+    ret = regression.check_result_image(fnm, src)
+    sys.exit(ret)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_continents.py b/testing/vcs/test_vcs_continents.py
index 9ae3d62de..c102df9de 100644
--- a/testing/vcs/test_vcs_continents.py
+++ b/testing/vcs/test_vcs_continents.py
@@ -1,22 +1,14 @@
-import cdms2
-import os
-import sys
-import vcs
-import EzTemplate
+import os, sys, EzTemplate, cdms2, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 clt = dataFile("clt", time="1979-1-1", squeeze=1)
 
-
 # Zero out the array so we can see the continents clearly
 clt[:] = 0
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 boxfill = canvas.createboxfill()
@@ -64,15 +56,4 @@ for i in range(12):
         canvas.plot(clt, template, boxfill, continents=7, continents_line=cont_line, bg=1)
         os.environ["UVCDAT_DIR"] = current_dotdir
 
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_continents.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    25)
-sys.exit(ret)
+regression.run(canvas, "test_continents.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_create_get.py b/testing/vcs/test_vcs_create_get.py
index ec525d1b4..adb879d64 100644
--- a/testing/vcs/test_vcs_create_get.py
+++ b/testing/vcs/test_vcs_create_get.py
@@ -1,4 +1,3 @@
-
 import vcs
 x=vcs.init()
 x.drawlogooff()
diff --git a/testing/vcs/test_vcs_draw_logo_on.py b/testing/vcs/test_vcs_draw_logo_on.py
index 65271eb15..4a0c28d2c 100644
--- a/testing/vcs/test_vcs_draw_logo_on.py
+++ b/testing/vcs/test_vcs_draw_logo_on.py
@@ -1,19 +1,9 @@
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = vcs.init()
 a=numpy.arange(100)
 a.shape=(10,10)
 x.plot(a,bg=1)
 fnm = "test_vcs_draw_logo_on.png"
 x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.check_result_image(fnm, sys.argv[1])
diff --git a/testing/vcs/test_vcs_fillarea_transparency.py b/testing/vcs/test_vcs_fillarea_transparency.py
index dc3a8bf4b..831b3e029 100644
--- a/testing/vcs/test_vcs_fillarea_transparency.py
+++ b/testing/vcs/test_vcs_fillarea_transparency.py
@@ -1,13 +1,6 @@
-import vcs
-import sys,os
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, sys, os, testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+x = regression.init()
 
 fa1 = x.createfillarea()
 
@@ -29,8 +22,4 @@ x.plot(fa1,bg=True)
 x.plot(fa2,bg=True)
 
 fnm = os.path.split(__file__[:-2]+"png")[-1]
-x.png(fnm)
-src = sys.argv[1]
-
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_first_png_blank.py b/testing/vcs/test_vcs_first_png_blank.py
index d11c59e6d..1e0bd8e28 100644
--- a/testing/vcs/test_vcs_first_png_blank.py
+++ b/testing/vcs/test_vcs_first_png_blank.py
@@ -1,20 +1,7 @@
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 T=f('clt')
-v = vcs.init()
-v.setantialiasing(0)
-v.setbgoutputdimensions(1200,1091,units="pixels")
+v = regression.init()
 v.plot(T,bg=1)
-# This will write a blank plot to a file:
-fnm = "first_png_blank.png"
-v.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(v, 'first_png_blank.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_flipNone.py b/testing/vcs/test_vcs_flipNone.py
index a76e271f1..79b69ffdd 100644
--- a/testing/vcs/test_vcs_flipNone.py
+++ b/testing/vcs/test_vcs_flipNone.py
@@ -1,26 +1,8 @@
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
-
-
+x = regression.init()
+f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
 vr = "ta"
 s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1,level=(0,10000))
 x.plot(s,bg=1)
-fnm = "test_vcs_flipNone.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
+regression.run(x, 'test_vcs_flipNone.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_flipX.py b/testing/vcs/test_vcs_flipX.py
index 0de7001aa..e211bf16a 100644
--- a/testing/vcs/test_vcs_flipX.py
+++ b/testing/vcs/test_vcs_flipX.py
@@ -1,26 +1,8 @@
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
-
-
+x = regression.init()
+f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
 vr = "ta"
 s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1,latitude=(90,-90),level=(0,10000))
 x.plot(s,bg=1)
-fnm = "test_vcs_flipX.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
+regression.run(x, 'test_vcs_flipX.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_flipXY.py b/testing/vcs/test_vcs_flipXY.py
index 8dd0f8d89..779a0fe7e 100644
--- a/testing/vcs/test_vcs_flipXY.py
+++ b/testing/vcs/test_vcs_flipXY.py
@@ -1,26 +1,9 @@
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
-
+x = regression.init()
+f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
 
 vr = "ta"
 s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1,latitude=(90,-90))
 x.plot(s,bg=1)
-fnm = "test_vcs_flipXY.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
+regression.run(x, 'test_vcs_flipXY.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_flipY.py b/testing/vcs/test_vcs_flipY.py
index 7194f3f30..5efa57745 100644
--- a/testing/vcs/test_vcs_flipY.py
+++ b/testing/vcs/test_vcs_flipY.py
@@ -1,26 +1,8 @@
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x = regression.init()
 f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
-
-
 vr = "ta"
 s=f(vr,slice(0,1),longitude=slice(90,91),squeeze=1)
 x.plot(s,bg=1)
-fnm = "test_vcs_flipY.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
+regression.run(x, 'test_vcs_flipY.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_gen_meshfill.py b/testing/vcs/test_vcs_gen_meshfill.py
index b726a20a6..e59940554 100644
--- a/testing/vcs/test_vcs_gen_meshfill.py
+++ b/testing/vcs/test_vcs_gen_meshfill.py
@@ -1,39 +1,16 @@
+import os, sys, numpy, vcs, testing.regression as regression
 
-import vcs,numpy,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x = regression.init()
 
 data = numpy.array([1,2,3,4])
-
 blon = numpy.array([-1,1,1,0,-1])
 blat = numpy.array([0,0,1,2,1])
-
 acell=numpy.array([blat,blon])
 bcell = numpy.array([blat,blon+2.5])
 ccell = numpy.array([blat+2.5,blon+2.5])
 dcell = numpy.array([blat+2.5,blon])
-
 mesh = numpy.array([acell,bcell,ccell,dcell])
-
 m=x.createmeshfill()
 
 x.plot(data,mesh,m,bg=1)
-
-
-fnm = "test_vcs_gen_meshfill.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
-
+regression.run(x, "test_vcs_gen_meshfill.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_gms_animate_projected_plots.py b/testing/vcs/test_vcs_gms_animate_projected_plots.py
index 2e521cd4a..3de234e41 100644
--- a/testing/vcs/test_vcs_gms_animate_projected_plots.py
+++ b/testing/vcs/test_vcs_gms_animate_projected_plots.py
@@ -1,15 +1,5 @@
 # Test animation of projected plots
-
-import argparse
-import cdms2
-import MV2
-import os
-import sys
-import vcs
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage  # noqa
+import argparse, os, sys, cdms2, MV2, vcs, testing.regression as regression
 
 p = argparse.ArgumentParser(description="Testing animation of projected plots")
 p.add_argument("--gm_type", dest="gm", help="gm to test")
@@ -19,18 +9,13 @@ p.add_argument("--source", dest="src", help="path to baseline image")
 p.add_argument("--keep", dest="keep", action="store_true", default=False,
                help="Save images, even if baseline matches.")
 p.add_argument("--threshold", dest="threshold", type=int,
-               default=checkimage.defaultThreshold,
+               default=regression.defaultThreshold,
                help="Threshold value for image differnces")
 
 args = p.parse_args(sys.argv[1:])
 
 gm_type = args.gm
-
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 1091, units="pixels")
-
+x = regression.init()
 s = None
 
 if gm_type == "meshfill":
@@ -72,7 +57,7 @@ pngs = x.animate.close(preserve_pngs=True)  # so we can look at them again
 ret = 0
 pdir = os.path.split(pngs[0])[0]
 p = pdir + os.sep + "anim_0.png"
-ret = checkimage.check_result_image(p, args.src, args.threshold)
+ret = regression.check_result_image(p, args.src, args.threshold)
 if ret == 0 and not args.keep:
     for f in pngs:
         if os.path.isfile(f):
diff --git a/testing/vcs/test_vcs_gms_patterns_hatches.py b/testing/vcs/test_vcs_gms_patterns_hatches.py
index 4030429a0..a7681a420 100644
--- a/testing/vcs/test_vcs_gms_patterns_hatches.py
+++ b/testing/vcs/test_vcs_gms_patterns_hatches.py
@@ -1,14 +1,4 @@
-# Test the use of patterns/hatches for plots
-
-import argparse
-import cdms2
-import os
-import sys
-import vcs
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage  # noqa
+import argparse, os, sys, cdms2, vcs, testing.regression as regression
 
 p = argparse.ArgumentParser(description="Patterns/hatches testing code for vcs gms")
 p.add_argument("--source", dest="src", help="source image file")
@@ -22,7 +12,7 @@ p.add_argument("--lat2", dest="lat2", default=90, type=float, help="Last latitud
 p.add_argument("--lon1", dest="lon1", default=-180, type=float, help="First Longitude")
 p.add_argument("--lon2", dest="lon2", default=180, type=float, help="Last Longitude")
 p.add_argument("--keep", dest="keep", action="store_true", help="Save image, even if baseline matches.")
-p.add_argument("--threshold", dest="threshold", type=int, default=checkimage.defaultThreshold,
+p.add_argument("--threshold", dest="threshold", type=int, default=regression.defaultThreshold,
         help="Default threshold")
 p.add_argument("--non-contiguous", dest="contig", default=True, action="store_false", help="use non contiguous levels")
 
@@ -98,7 +88,7 @@ fnm += nm_xtra
 x.png(fnm)
 print "fnm:", fnm
 print "src:", src
-ret = checkimage.check_result_image(fnm+'.png', src,
+ret = regression.check_result_image(fnm+'.png', src,
                                     args.threshold,
                                     cleanup=not args.keep)
 if args.show:
diff --git a/testing/vcs/test_vcs_hatches_patterns.py b/testing/vcs/test_vcs_hatches_patterns.py
index 8cd1766f0..8a467259c 100644
--- a/testing/vcs/test_vcs_hatches_patterns.py
+++ b/testing/vcs/test_vcs_hatches_patterns.py
@@ -1,17 +1,6 @@
-import os
-import sys
-import vcs
+import os, sys, vcs, testing.regression as regression
 
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
-
-baselineImage = sys.argv[1]
-
-# Initialize the graphics canvas
-x = vcs.init()
-x.setantialiasing(0)
-x.setbgoutputdimensions(1200, 1091, units="pixels")
+x = regression.init()
 
 # Create a test plot for listing all the hatches and patterns
 style_list = []
@@ -77,11 +66,4 @@ plot_title.y = [.9]
 x.plot(plot_title, bg=1)
 x.plot(fill_test, bg=1)
 x.plot(fill_info, bg=1)
-
-testImage = os.path.abspath("test_vcs_hatches_patterns.png")
-x.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage,
-                                    checkimage.defaultThreshold)
-
-sys.exit(ret)
+regression.run(x, "test_vcs_hatches_patterns.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_import.py b/testing/vcs/test_vcs_import.py
index c12242125..01c3d0447 100644
--- a/testing/vcs/test_vcs_import.py
+++ b/testing/vcs/test_vcs_import.py
@@ -1,3 +1,2 @@
-
 import vcs
 
diff --git a/testing/vcs/test_vcs_infinity.py b/testing/vcs/test_vcs_infinity.py
index 235f551eb..daf406016 100644
--- a/testing/vcs/test_vcs_infinity.py
+++ b/testing/vcs/test_vcs_infinity.py
@@ -1,28 +1,16 @@
-
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import numpy
+import os, sys, numpy, MV2, cdms2, testing.regression as regression
 
 s= numpy.sin(numpy.arange(100))
-s=numpy.reshape(s,(10,10))
+s = numpy.reshape(s,(10,10))
 
 s[4,6] = numpy.inf
 s[7,9] = numpy.NINF
 s[9,2] = numpy.nan
 
-x=vcs.init()
+x = regression.init()
 x.setantialiasing(0)
 x.drawlogooff()
 x.setbgoutputdimensions(1200,1091,units="pixels")
 x.plot(s,bg=1)
 fnm = "infinity.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_iso_celine_part1.py b/testing/vcs/test_vcs_iso_celine_part1.py
index 586918d36..a8fcc5ae7 100644
--- a/testing/vcs/test_vcs_iso_celine_part1.py
+++ b/testing/vcs/test_vcs_iso_celine_part1.py
@@ -1,22 +1,13 @@
+import os,sys, MV2, numpy, vcs, cdms2, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
 src=sys.argv[1]
 pth0 = os.path.dirname(__file__)
-pth = os.path.join(pth0,"..")
-sys.path.append(pth)
-import checkimage
-f=cdms2.open(os.path.join(pth0,"celine.nc"))
-s=f("data")
-x=vcs.init()
+f = cdms2.open(os.path.join(pth0,"celine.nc"))
+s = f("data")
+x = regression.init()
 x.setantialiasing(0)
-x.drawlogooff()
 x.scriptrun(os.path.join(pth0,"celine.json"))
-i=x.getisofill("celine")
+i = x.getisofill("celine")
 x.plot(s,i,bg=1)
 fnm = "test_celine_iso.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_iso_celine_part2.py b/testing/vcs/test_vcs_iso_celine_part2.py
index f99f821da..c1c1df5b1 100644
--- a/testing/vcs/test_vcs_iso_celine_part2.py
+++ b/testing/vcs/test_vcs_iso_celine_part2.py
@@ -1,26 +1,15 @@
+import os, sys, MV2, numpy, vcs, cdms2, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
 pth0 = os.path.dirname(__file__)
-pth = os.path.join(pth0,"..")
-sys.path.append(pth)
-import checkimage
-f=cdms2.open(os.path.join(pth0,"celine.nc"))
-s=f("data")
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
+f = cdms2.open(os.path.join(pth0,"celine.nc"))
+s = f("data")
+x = regression.init()
 x.scriptrun(os.path.join(pth0,"celine.json"))
-i=x.getisofill("celine")
-b=vcs.createboxfill()
+i = x.getisofill("celine")
+b = vcs.createboxfill()
 b.levels=i.levels
 b.fillareacolors=i.fillareacolors
 b.boxfill_type="custom"
 x.plot(s,b,bg=1)
 fnm = "test_celine_iso_2.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isofill_data_read_north_to_south.py b/testing/vcs/test_vcs_isofill_data_read_north_to_south.py
index 5f12f65b0..8d1cc949c 100644
--- a/testing/vcs/test_vcs_isofill_data_read_north_to_south.py
+++ b/testing/vcs/test_vcs_isofill_data_read_north_to_south.py
@@ -1,24 +1,10 @@
-import cdms2
-import vcs
-import sys
-import os
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
+
 f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 clt = f("clt",latitude=(80.0, 38.0),squeeze=1,longitude=(-180.0, 180.0),time=slice(0,1))
-x = vcs.init()
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-x.setantialiasing(0)
+x = regression.init()
 gm = vcs.createisofill()
 gm.projection="polar"
 x.plot( clt,gm,bg=1)
 fnm = os.path.split(__file__)[-1][:-2]+"png"
-src= sys.argv[1]
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isofill_isoline_labels.py b/testing/vcs/test_vcs_isofill_isoline_labels.py
index d230fc8fc..192ffc4bf 100644
--- a/testing/vcs/test_vcs_isofill_isoline_labels.py
+++ b/testing/vcs/test_vcs_isofill_isoline_labels.py
@@ -1,24 +1,10 @@
-import vcs,cdms2,sys,os
-
-baselineImage = sys.argv[1]
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
 
 dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data = dataset("clt")
-
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
-
+canvas = regression.init()
 isofill = canvas.createisofill()
-
-# First plot the isofill
 canvas.plot(data, isofill, bg=1)
-
 isoline = canvas.createisoline()
 isoline.label="y"
 texts=[]
@@ -35,13 +21,6 @@ for i in range(10):
 isoline.text = texts
 isoline.linecolors = colors
 
-# Next plot the isolines with labels
+# Plot the isolines with labels
 canvas.plot(data, isoline, bg=1)
-
-testImage = os.path.abspath("test_isofill_isoline_labels.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage,
-                                    checkimage.defaultThreshold)
-
-sys.exit(ret)
+regression.run(canvas, "test_isofill_isoline_labels.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isofill_mask_cell_shift.py b/testing/vcs/test_vcs_isofill_mask_cell_shift.py
index 9bc867113..199b1586d 100644
--- a/testing/vcs/test_vcs_isofill_mask_cell_shift.py
+++ b/testing/vcs/test_vcs_isofill_mask_cell_shift.py
@@ -1,25 +1,8 @@
-import os,sys
-import MV2
-import vcs
-import cdms2
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt",slice(0,1),latitude=(30,70),longitude=(-130,-60))
-s2=MV2.masked_greater(s,65.)
+import os, sys, MV2, cdms2, vcs, testing.regression as regression
 
+x = regression.init()
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt",slice(0,1),latitude=(30, 70),longitude=(-130, -60))
+s2 = MV2.masked_greater(s, 65.)
 x.plot(s2,"default","isofill",bg=1)
-fnm = "test_vcs_isofill_mask_cell_shift.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_isofill_mask_cell_shift.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isoline_labels.py b/testing/vcs/test_vcs_isoline_labels.py
index 77033f2c8..460235431 100644
--- a/testing/vcs/test_vcs_isoline_labels.py
+++ b/testing/vcs/test_vcs_isoline_labels.py
@@ -1,20 +1,8 @@
-import vcs,cdms2,sys,os
-
-# ('/path/to/filename', '.extension')
-baseline = os.path.splitext(sys.argv[1])
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
 
 dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data = dataset("clt")
-
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
-
+canvas = regression.init()
 isoline = canvas.createisoline()
 isoline.label="y"
 texts=[]
@@ -33,24 +21,17 @@ isoline.text = texts
 # First test using isoline.text[...].color
 canvas.plot(data, isoline, bg=1)
 
+baseline = os.path.splitext(sys.argv[1])
 baselineImage = "%s%s"%baseline
-testImage = os.path.abspath("test_isoline_labels.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage,
-                                    checkimage.defaultThreshold)
+ret = regression.run_wo_terminate(canvas, "test_isoline_labels.png", baselineImage)
 
 # Now set isoline.linecolors and test again.
 canvas.clear()
 isoline.linecolors = colors
 canvas.plot(data, isoline, bg=1)
-
 baselineImage = "%s%d%s"%(baseline[0], 2, baseline[1])
 testImage = os.path.abspath("test_isoline_labels2.png")
-canvas.png(testImage)
-
-ret += checkimage.check_result_image(testImage, baselineImage,
-                                     checkimage.defaultThreshold)
+ret += regression.run_wo_terminate(canvas, testImage, baselineImage)
 
 # Now set isoline.textcolors and test again.
 canvas.clear()
@@ -59,9 +40,6 @@ canvas.plot(data, isoline, bg=1)
 
 baselineImage = "%s%d%s"%(baseline[0], 3, baseline[1])
 testImage = os.path.abspath("test_isoline_labels3.png")
-canvas.png(testImage)
-
-ret += checkimage.check_result_image(testImage, baselineImage,
-                                     checkimage.defaultThreshold)
+ret += regression.run_wo_terminate(canvas, testImage, baselineImage)
 
 sys.exit(ret)
diff --git a/testing/vcs/test_vcs_isoline_labels_background.py b/testing/vcs/test_vcs_isoline_labels_background.py
index da1d1e6ac..08088836a 100644
--- a/testing/vcs/test_vcs_isoline_labels_background.py
+++ b/testing/vcs/test_vcs_isoline_labels_background.py
@@ -1,26 +1,13 @@
-import cdms2
-import os
-import sys
-import vcs
+import os, sys, cdms2, vcs, testing.regression as regression
 import random
 
-# ('/path/to/filename', '.extension')
-baseline = os.path.splitext(sys.argv[1])
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
-
 (latmin, latmax, lonmin, lonmax) = (-90, 90, -180, 180)
 dataset = cdms2.open(os.path.join(vcs.sample_data, "tas_cru_1979.nc"))
 data = dataset("tas", time=slice(0, 1), latitude=(latmin, latmax),
                longitude=(lonmin, lonmax, 'co'), squeeze=1)
 dataset.close()
 
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 canvas.backgroundcolor = [100, 105, 105]
 
 isoline = canvas.createisoline()
@@ -50,11 +37,6 @@ isoline.labelskipdistance = 15.0
 
 # First test using isoline.text[...].color
 canvas.plot(data, isoline, bg=1)
-
+baseline = os.path.splitext(sys.argv[1])
 baselineImage = "%s%s" % baseline
-testImage = os.path.abspath("test_isoline_labels_background.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, baselineImage)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py b/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py
index da5e5d3c3..8c6e13a7e 100644
--- a/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py
+++ b/testing/vcs/test_vcs_isoline_labels_multi_label_input_types.py
@@ -1,30 +1,18 @@
-import vcs
-import cdms2
-import os,sys
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt")
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-iso=x.createisoline()
-t=x.createtext()
-t.color=243
-t.height=25
-to=x.createtextorientation()
-to.height = 55
-tt=x.createtexttable()
-tt.color=245
-iso.textcolors=[None,None,None,242,244]
-iso.text=[t,tt,to]
-iso.label="y"
-x.plot(s,iso,bg=1)
-x.png("test_vcs_isoline_labels_multi_label_input_types.png")
-
-src=sys.argv[1]
+import os, sys, cdms2, vcs, testing.regression as regression
 
-ret = checkimage.check_result_image('test_vcs_isoline_labels_multi_label_input_types.png',src,checkimage.defaultThreshold)
-sys.exit(ret)
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt")
+x = regression.init()
+iso = x.createisoline()
+t = x.createtext()
+t.color = 243
+t.height = 25
+to = x.createtextorientation()
+to.height = 55
+tt = x.createtexttable()
+tt.color = 245
+iso.textcolors = [None,None,None,242,244]
+iso.text = [t,tt,to]
+iso.label = "y"
+x.plot(s, iso, bg=1)
+regression.run(x, "test_vcs_isoline_labels_multi_label_input_types.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isoline_labelskipdistance.py b/testing/vcs/test_vcs_isoline_labelskipdistance.py
index 04ecdfabb..4b119e0bc 100644
--- a/testing/vcs/test_vcs_isoline_labelskipdistance.py
+++ b/testing/vcs/test_vcs_isoline_labelskipdistance.py
@@ -1,21 +1,8 @@
-import cdms2
-import os
-import sys
-import vcs
-
-baselineImage = sys.argv[1]
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
 
 dataset = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 data = dataset("clt")
-
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 isoline = canvas.createisoline()
 isoline.label = "y"
@@ -36,11 +23,4 @@ isoline.linecolors = colors
 
 # Next plot the isolines with labels
 canvas.plot(data, isoline, bg=1)
-
-testImage = os.path.abspath("test_isoline_labelskipdistance.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage,
-                                    checkimage.defaultThreshold)
-
-sys.exit(ret)
+regression.run(canvas, "test_isoline_labelskipdistance.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isoline_numpy.py b/testing/vcs/test_vcs_isoline_numpy.py
index ced140e77..147f2f499 100644
--- a/testing/vcs/test_vcs_isoline_numpy.py
+++ b/testing/vcs/test_vcs_isoline_numpy.py
@@ -1,21 +1,13 @@
-import vcs,cdms2,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
+import os, sys, cdms2, vcs, testing.regression as regression
+
+x = regression.init()
 x.setantialiasing(0)
 x.setbgoutputdimensions(1200,1091,units="pixels")
 x.drawlogooff()
 fnm = os.path.join(vcs.sample_data,'clt.nc')
-f=cdms2.open(fnm)
-
-s=f("clt")
-gm=x.createisofill()
+f = cdms2.open(fnm)
+s = f("clt")
+gm = x.createisofill()
 x.plot(s.filled(),gm,bg=1)
 fnm = "test_vcs_isoline_numpy.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_isoline_width_stipple.py b/testing/vcs/test_vcs_isoline_width_stipple.py
index b563436c2..5da8f91f4 100644
--- a/testing/vcs/test_vcs_isoline_width_stipple.py
+++ b/testing/vcs/test_vcs_isoline_width_stipple.py
@@ -1,22 +1,8 @@
-import cdms2
-import os
-import sys
-import vcs
-
-baselineImage = sys.argv[1]
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage  # noqa
+import os, sys, cdms2, vcs, testing.regression as regression
 
 dataset = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 data = dataset("clt")
-
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
-
+canvas = regression.init()
 isoline = canvas.createisoline()
 isoline.label = "y"
 texts = []
@@ -35,15 +21,8 @@ for i in range(7):
 isoline.levels = levels
 isoline.text = texts
 isoline.linecolors = colors
-
 isoline.linewidths = (1, 2, 3, 4, 1)
 isoline.line = ('dot', 'dash', 'solid', 'dash-dot', 'long-dash', 'dot', 'dash')
-
 # Next plot the isolines with labels
 canvas.plot(data, isoline, bg=1)
-
-testImage = os.path.abspath("test_isoline_width_stipple.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage, 30)
-sys.exit(ret)
+regression.run(canvas, "test_isoline_width_stipple.png")
diff --git a/testing/vcs/test_vcs_issue_960_labels.py b/testing/vcs/test_vcs_issue_960_labels.py
index ee45216cd..7da2104ff 100644
--- a/testing/vcs/test_vcs_issue_960_labels.py
+++ b/testing/vcs/test_vcs_issue_960_labels.py
@@ -1,29 +1,19 @@
-import sys,os,cdms2,vcs
-import vcs
-src1=sys.argv[1]
-src2=sys.argv[2]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+import os, sys, cdms2, vcs, testing.regression as regression
+
+src1 = sys.argv[1]
+src2 = sys.argv[2]
+x = regression.init()
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 s=f("clt",time=slice(0,1),latitude=(-7,5),squeeze=1)
 x.plot(s,bg=1)
 fnm = "test_vcs_issue_960_labels_1.png"
 x.png(fnm)
-print "fnm:",fnm
-print "src:",src1
-ret = checkimage.check_result_image(fnm,src1,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, src1)
 b=x.createboxfill()
 b.datawc_y1=-7
 b.datawc_y2=5
 x.plot(s,b,bg=1)
 fnm = "test_vcs_issue_960_labels_2.png"
 x.png(fnm)
-print "fnm:",fnm
-print "src:",src2
-ret += checkimage.check_result_image(fnm,src2,checkimage.defaultThreshold)
-sys.exit(ret)
+ret += regression.check_result_image(fnm, src2)
+sys.exit(ret)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_lambert.py b/testing/vcs/test_vcs_lambert.py
index 17a50209f..c78e71e9b 100644
--- a/testing/vcs/test_vcs_lambert.py
+++ b/testing/vcs/test_vcs_lambert.py
@@ -1,27 +1,10 @@
-import vcs,cdms2
-import os,sys
+import os, sys, cdms2, vcs, testing.regression as regression
 f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 s = f("clt")
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+x = regression.init()
 iso = x.createisofill()
 p=x.createprojection()
 p.type="lambert"
-
 iso.projection = p
 x.plot(s(latitude=(20, 60),longitude=(-140,-20)), iso, bg=True)
-
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_vcs_lambert.png"
-x.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_lambert.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_large_pattern_hatch.py b/testing/vcs/test_vcs_large_pattern_hatch.py
index 3bcf0827d..782cfb14b 100644
--- a/testing/vcs/test_vcs_large_pattern_hatch.py
+++ b/testing/vcs/test_vcs_large_pattern_hatch.py
@@ -1,31 +1,12 @@
-import vcs
-import sys
-import os
-
-baseline = sys.argv[1]
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
-
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1090, units="pixels")
-canvas.drawlogooff()
+import os, sys, vcs, testing.regression as regression
 
+canvas = regression.init()
 fillarea = vcs.createfillarea()
 fillarea.x = [[0, .33, .33, 0], [.33, .67, .67, .33], [.67, 1, 1, .67]]
 fillarea.y = [[0, 0, 1, 1]] * 3
 fillarea.style = ["solid", "pattern", "hatch"]
 fillarea.index = [1, 5, 5]
 fillarea.color = [50, 50, 50]
-
 canvas.plot(fillarea, bg=True)
-
-testImage = os.path.abspath("test_vcs_large_pattern_hatch.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baseline,
-                                    checkimage.defaultThreshold)
-
-sys.exit(ret)
+fnm = os.path.abspath("test_vcs_large_pattern_hatch.png")
+regression.run(canvas, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_legend.py b/testing/vcs/test_vcs_legend.py
index 26beec7e5..a352bc080 100644
--- a/testing/vcs/test_vcs_legend.py
+++ b/testing/vcs/test_vcs_legend.py
@@ -1,5 +1,4 @@
-import sys,os
-import argparse
+import os, sys, argparse, cdms2, MV2, vcs, testing.regression as regression
 
 p = argparse.ArgumentParser(description="Basic gm testing code for vcs")
 p.add_argument("--source", dest="src", help="source image file")
@@ -14,20 +13,10 @@ args = p.parse_args(sys.argv[1:])
 
 gm_type= args.gm
 src = args.src
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-import vcs
-import sys
-import cdms2
-import vtk
-import os
-import MV2
 
 bg = not args.show
 
-x=vcs.init()
+x = vcs.init()
 x.setantialiasing(0)
 x.drawlogooff()
 if bg:
@@ -81,7 +70,7 @@ fnm = "test_vcs_legend_%s_%s_ext1_%s_ext2_%s" % (gm_type.lower(),args.orientatio
 x.png(fnm)
 print "fnm:",fnm
 print "src:",src
-ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep)
+ret = regression.check_result_image(fnm+'.png', src,regression.defaultThreshold, cleanup=not args.keep)
 if args.show:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcs/test_vcs_lon_axes_freak_out.py b/testing/vcs/test_vcs_lon_axes_freak_out.py
index ecb63f2a5..f18328f58 100644
--- a/testing/vcs/test_vcs_lon_axes_freak_out.py
+++ b/testing/vcs/test_vcs_lon_axes_freak_out.py
@@ -1,30 +1,11 @@
-import os,sys,vcs,cdms2
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
 
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+s = f("clt")
+s3 = f("clt",longitude=(0,360))
 
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-s=f("clt")
-s3=f("clt",longitude=(0,360))
-
-print s.shape,s3.shape
-
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x = regression.init()
 x.plot(s,bg=1)
 x.clear()
 x.plot(s3,bg=1)
-
-fnm = "test_lon_axes_freak_out.png"
-
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_lon_axes_freak_out.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_markers.py b/testing/vcs/test_vcs_markers.py
index 50f4f00d1..21b7a671b 100644
--- a/testing/vcs/test_vcs_markers.py
+++ b/testing/vcs/test_vcs_markers.py
@@ -1,28 +1,14 @@
+import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x = regression.init()
 m = x.createmarker()
-m.x=[[0.,],[5,],[10.,],[15.]]
-m.y=[[0.,],[5,],[10.,],[15.]]
+m.x = [[0.,],[5,],[10.,],[15.]]
+m.y = [[0.,],[5,],[10.,],[15.]]
 m.worldcoordinate=[-5,20,-5,20]
+
 #m.worldcoordinate=[-10,10,0,10]
 m.type=['plus','diamond','square_fill',"hurricane"]
 m.color=[242,243,244,242]
 m.size=[20,20,20,5]
 x.plot(m,bg=1)
-fnm= "test_markers.png"
-
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_markers.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_matplotlib_colormap.py b/testing/vcs/test_vcs_matplotlib_colormap.py
index 06b9f49b9..baf0e1bb0 100644
--- a/testing/vcs/test_vcs_matplotlib_colormap.py
+++ b/testing/vcs/test_vcs_matplotlib_colormap.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import os, sys, cdms2, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -10,24 +7,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
-
+canvas = regression.init()
 canvas.setcolormap(vcs.matplotlib2vcs("viridis"))
-
 canvas.plot(clt, bg=1)
-
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_matplotlib_colormap.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_matplotlib_colormap.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_mercator_edge.py b/testing/vcs/test_vcs_mercator_edge.py
index eb6d79cdb..31f6cb83b 100644
--- a/testing/vcs/test_vcs_mercator_edge.py
+++ b/testing/vcs/test_vcs_mercator_edge.py
@@ -1,24 +1,9 @@
-import vcs,cdms2
-import os,sys
+import os, sys, cdms2, vcs, testing.regression as regression
+
 f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 s = f("clt")
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
 iso = x.createisofill()
 iso.projection = "mercator"
 x.plot(s(latitude=(-90, 90)), iso, bg=1)
-
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_vcs_mercator_edge.png"
-x.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_mercator_edge.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_meshfill_draw_mesh.py b/testing/vcs/test_vcs_meshfill_draw_mesh.py
index ef214e648..08801d7a6 100644
--- a/testing/vcs/test_vcs_meshfill_draw_mesh.py
+++ b/testing/vcs/test_vcs_meshfill_draw_mesh.py
@@ -1,23 +1,11 @@
-import vcs,cdms2,sys,os
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.setbgoutputdimensions(1200,1091,units="pixels")
-x.drawlogooff()
-fnmcurv = os.path.join(vcs.sample_data,'sampleCurveGrid4.nc')
-f=cdms2.open(fnmcurv)
+import os, sys, cdms2, vcs, testing.regression as regression
 
-s=f("sample")
-m=x.createmeshfill()
-m.mesh=True
+x = regression.init()
+fnmcurv = os.path.join(vcs.sample_data,'sampleCurveGrid4.nc')
+f = cdms2.open(fnmcurv)
+s = f("sample")
+m = x.createmeshfill()
+m.mesh = True
 
 x.plot(s,m,bg=1)
-fnm = "test_meshfill_draw_mesh.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_meshfill_draw_mesh.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_meshfill_no_wrapping.py b/testing/vcs/test_vcs_meshfill_no_wrapping.py
index 967758c78..9ee4a99f1 100755
--- a/testing/vcs/test_vcs_meshfill_no_wrapping.py
+++ b/testing/vcs/test_vcs_meshfill_no_wrapping.py
@@ -1,23 +1,7 @@
-#!/usr/bin/env python
-import cdms2 
-import os 
-import sys
-import vcs
-
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
-
-
-f=cdms2.open(sys.argv[2])
-h=f("heat")
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 900, units="pixels")
+import os, sys, cdms2, vcs, testing.regression as regression
 
+f = cdms2.open(sys.argv[2])
+h = f("heat")
+x = regression.init()
 x.plot(h, bg=1)
-fnm = "vcs_test_meshfill_no_wrapping.png"
-x.png(fnm)
-ret = checkimage.check_result_image(fnm, sys.argv[1], checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "vcs_test_meshfill_no_wrapping.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_meshfill_regular_grid.py b/testing/vcs/test_vcs_meshfill_regular_grid.py
index 9a955f9ff..77a390b22 100644
--- a/testing/vcs/test_vcs_meshfill_regular_grid.py
+++ b/testing/vcs/test_vcs_meshfill_regular_grid.py
@@ -1,22 +1,7 @@
-import vcs, cdms2, os, sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
+import os, sys, cdms2, vcs, testing.regression as regression
 
-x.setbgoutputdimensions(1200,1091,units="pixels")
-x = vcs.init()
-x.setantialiasing(0)
+x = regression.init()
 f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 s = f("clt")
-x.meshfill(s,bg=1)
-fnm = "test_meshfill_regular_grid.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+x.meshfill(s, bg=1)
+regression.run(x, "test_meshfill_regular_grid.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_meshfill_vertices.py b/testing/vcs/test_vcs_meshfill_vertices.py
index 6317ef071..103e68109 100644
--- a/testing/vcs/test_vcs_meshfill_vertices.py
+++ b/testing/vcs/test_vcs_meshfill_vertices.py
@@ -1,19 +1,8 @@
-import numpy
-import vcs
-import sys
-import os
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, numpy, vcs, testing.regression as regression
 
-x=vcs.init()
-
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 1090, units="pixels")
+x = regression.init()
 
 data_values = [ 25, 45, 55.]
-
 data_lon = [ 5., 10., 15.]
 data_lat = [ 5., 10., 15.]
 
@@ -50,8 +39,4 @@ m.levels = [20,30,50,70,80]
 m.mesh = True
 
 x.plot(numpy.array(data_values,),mesh,m,bg=True)
-x.png("test_vcs_meshfill_vertices_issue.png")
-src = sys.argv[1]
-ret = checkimage.check_result_image("test_vcs_meshfill_vertices_issue.png",
-                                    src, checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_meshfill_vertices_issue.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_meshfill_zoom.py b/testing/vcs/test_vcs_meshfill_zoom.py
index 1026f0ff0..c366d8010 100644
--- a/testing/vcs/test_vcs_meshfill_zoom.py
+++ b/testing/vcs/test_vcs_meshfill_zoom.py
@@ -1,14 +1,4 @@
-#!/usr/bin/env python
-import cdms2
-import os
-import sys
-import vcs
-
-# We test if gm.datawc zooms in correctly into the plot. This works only for
-# data using a linear projection. It does not work for geographic projections.
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
 
 flip = False
 if (len(sys.argv) == 3):
@@ -19,12 +9,10 @@ fileName = os.path.splitext(fileName)[0]
 if (flip):
     fileName = fileName + '_flip'
 fileName = fileName + '.png'
-f=cdms2.open(os.path.join(vcs.sample_data, "sampleCurveGrid4.nc"))
-s=f("sample")
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-m=x.createmeshfill()
+f = cdms2.open(os.path.join(vcs.sample_data, "sampleCurveGrid4.nc"))
+s = f("sample")
+x = regression.init()
+m = x.createmeshfill()
 # m.mesh = True
 m.datawc_x1 = -20
 m.datawc_x2 = 20
@@ -33,7 +21,4 @@ if (flip):
 m.datawc_y1 = -20
 m.datawc_y2 = 20
 x.plot(s,m, bg=1)
-x.png(fileName)
-ret = checkimage.check_result_image(fileName, sys.argv[1], checkimage.defaultThreshold)
-sys.exit(ret)
-
+regression.run(x, fileName)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_mintics.py b/testing/vcs/test_vcs_mintics.py
index 01f65848b..302c22fd4 100644
--- a/testing/vcs/test_vcs_mintics.py
+++ b/testing/vcs/test_vcs_mintics.py
@@ -1,16 +1,10 @@
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
 f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 s = f("clt")
 box = x.createboxfill()
+
 # Should ignore the string here
 box.xmtics1 = {i:"Test" for i in range(-180, 180, 15) if i % 30 != 0}
 box.ymtics1 = {i:"Test" for i in range(-90, 90, 5) if i % 10 != 0}
@@ -23,10 +17,4 @@ template.xmintic2.priority = 1
 template.xmintic2.y2 += template.xmintic1.y1 - template.xmintic1.y2
 template.ymintic2.priority = 1
 x.plot(s, template, box, bg=1)
-fnm = "test_vcs_mintics.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_mintics.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_missing_colorname.py b/testing/vcs/test_vcs_missing_colorname.py
index 1ed68b475..9b3db7545 100644
--- a/testing/vcs/test_vcs_missing_colorname.py
+++ b/testing/vcs/test_vcs_missing_colorname.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import os, sys, cdms2, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -11,10 +8,7 @@ height, width = clt.shape
 clt.mask = [[True if i % 2 else False for i in range(width)] for _ in range(height)]
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 # Create and plot quick boxfill with default settings:
 # Only have to test boxfill because all 2D methods use the same code
@@ -25,16 +19,4 @@ boxfill = canvas.createboxfill()
 boxfill.missing = "Medium Aquamarine"
 
 canvas.plot(clt, boxfill, bg=1)
-
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_vcs_missing_colorname.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_vcs_missing_colorname.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py b/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py
index 9f30f40ae..4dcd059a0 100644
--- a/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py
+++ b/testing/vcs/test_vcs_monotonic_decreasing_yxvsx_default.py
@@ -1,27 +1,14 @@
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
-x.setantialiasing(0)
+import os, sys, numpy, cdms2, MV2, vcs, testing.regression as regression
 
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
-t=cdms2.createAxis(numpy.arange(120))
+x = regression.init()
+t = cdms2.createAxis(numpy.arange(120))
 t.designateTime()
-t.id="time"
-t.units="months since 2014"
+t.id = "time"
+t.units = "months since 2014"
 data = MV2.arange(120,0,-1)
-data.id="data"
+data.id = "data"
 data.setAxis(0,t)
-x=vcs.init()
-x.setantialiasing(0)
+x = regression.init()
 x.plot(data,bg=1)
 fnm = 'test_vcs_monotonic_decreasing_yxvsx_default.png'
-
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_oned_level_axis.py b/testing/vcs/test_vcs_oned_level_axis.py
index 25479a56b..ecb708c77 100644
--- a/testing/vcs/test_vcs_oned_level_axis.py
+++ b/testing/vcs/test_vcs_oned_level_axis.py
@@ -1,24 +1,9 @@
+import os, sys, vcs, cdms2, cdutil, testing.regression as regression
 
-import sys,cdutil
-import vcs
-import os
-import cdms2
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-f=cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
-ta=f("ta",time=slice(0,1),squeeze=1)
-ta=cdutil.averager(ta,axis="yx")
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+f = cdms2.open(os.path.join(vcs.sample_data,"ta_ncep_87-6-88-4.nc"))
+ta = f("ta",time=slice(0,1),squeeze=1)
+ta = cdutil.averager(ta,axis="yx")
+x = regression.init()
 x.plot(ta,bg=1)
 fnm = "test_oned_level_axis.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_patterns.py b/testing/vcs/test_vcs_patterns.py
index fed4f41a8..c407f7cfe 100644
--- a/testing/vcs/test_vcs_patterns.py
+++ b/testing/vcs/test_vcs_patterns.py
@@ -1,19 +1,8 @@
-import cdms2
-import os
-import sys
-import vcs
-
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(pth)
-import checkimage
+import os, sys, vcs, cdms2, testing.regression as regression
 
 f = cdms2.open(vcs.sample_data+"/clt.nc")
 s = f("clt", time=slice(0, 1), squeeze=1)
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 1090, units="pixels")
+x = regression.init()
 iso = vcs.createisofill("isoleg")
 iso.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
 iso.fillareastyle = "pattern"
@@ -21,9 +10,4 @@ iso.fillareacolors = vcs.getcolors([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
 iso.fillareaindices = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
 x.plot(s, iso, bg=1)
 fnm = "test_vcs_patterns.png"
-x.png(fnm)
-
-print "fnm:", fnm
-print "src:", src
-ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold+5.)
-sys.exit(ret)
+regression.run(x, fnm, threshold=regression.defaultThreshold+5.)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_plot_file_var.py b/testing/vcs/test_vcs_plot_file_var.py
index e20f947a6..0dd68945d 100644
--- a/testing/vcs/test_vcs_plot_file_var.py
+++ b/testing/vcs/test_vcs_plot_file_var.py
@@ -1,8 +1,6 @@
-import vcs
-import os
-import sys
-import cdms2
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-V=f("clt")
-x=vcs.init()
-x.plot(V,bg=1)
+import os, sys, vcs, cdms2
+
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+V = f("clt")
+x = vcs.init()
+x.plot(V, bg=1)
diff --git a/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py b/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py
index 4aa1d24eb..535ff432e 100644
--- a/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py
+++ b/testing/vcs/test_vcs_plot_unstructured_via_boxfill.py
@@ -1,21 +1,7 @@
-import vcs
-import os,sys
-import cdms2
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-
-import checkimage
+import vcs, os, sys, cdms2, testing.regression as regression
 
 f = cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc"))
 s = f("sample")
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
 x.plot(s,bg=1)
-fnm = "test_plot_unstructured_via_boxfill.png"
-src = sys.argv[1]
-x.png(fnm)
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_plot_unstructured_via_boxfill.png")
diff --git a/testing/vcs/test_vcs_png_to_base64.py b/testing/vcs/test_vcs_png_to_base64.py
index 6b88b3511..f6d78e2fa 100644
--- a/testing/vcs/test_vcs_png_to_base64.py
+++ b/testing/vcs/test_vcs_png_to_base64.py
@@ -1,4 +1,4 @@
-import vcs,numpy,cdms2,MV2,os,sys
+import vcs, numpy, cdms2, MV2, os, sys
 
 x = vcs.init()
 x.drawlogooff()
diff --git a/testing/vcs/test_vcs_png_window_resize.py b/testing/vcs/test_vcs_png_window_resize.py
index 0adeeb66b..a6346ca28 100644
--- a/testing/vcs/test_vcs_png_window_resize.py
+++ b/testing/vcs/test_vcs_png_window_resize.py
@@ -1,20 +1,9 @@
-import vcs
-import sys
-import os
+import vcs, sys, os, testing.regression as regression
 
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-x=vcs.init()
+x = regression.init()
 x.setantialiasing(0)
 x.drawlogooff()
 x.open(814,628)
 x.plot([1,2,3,4,5,6,7])
 fnm = __file__[:-3]+".png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_polar_set_opt_param_polar.py b/testing/vcs/test_vcs_polar_set_opt_param_polar.py
index 8c508ca3c..4e777fb2b 100644
--- a/testing/vcs/test_vcs_polar_set_opt_param_polar.py
+++ b/testing/vcs/test_vcs_polar_set_opt_param_polar.py
@@ -1,29 +1,13 @@
+import vcs, cdms2, sys, os, testing.regression as regression
 
-import vcs
-import cdms2
-import sys
-import os
-
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-f=cdms2.open(os.path.join(vcs.sample_data,'clt.nc'))
-s=f("clt",slice(0,1),squeeze=1)
-x=vcs.init()
+f = cdms2.open(os.path.join(vcs.sample_data,'clt.nc'))
+s = f("clt",slice(0,1),squeeze=1)
+x = regression.init()
 x.setantialiasing(0)
 x.drawlogooff()
 x.setbgoutputdimensions(1200,1091,units="pixels")
-i=x.createisofill()
-p=x.getprojection("polar")
+i = x.createisofill()
+p = x.getprojection("polar")
 i.projection=p
 x.plot(s,i,bg=1)
-fnm= "test_polar_set_opt_param_polar.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-
+regression.run(x, "test_polar_set_opt_param_polar.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_remove_marker_none_1d.py b/testing/vcs/test_vcs_remove_marker_none_1d.py
index f868361b0..e112f86bc 100644
--- a/testing/vcs/test_vcs_remove_marker_none_1d.py
+++ b/testing/vcs/test_vcs_remove_marker_none_1d.py
@@ -3,31 +3,13 @@
 #
 # J-Y Peterschmitt - LSCE - 03/2015
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
 dummy_data = numpy.arange(50, dtype=numpy.float32)
-
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x = regression.init()
 gm = x.createyxvsx('test_yxvsx')
 
-
-# Remove the marker
 gm.marker = None
-
 x.plot(gm, dummy_data,bg=1)
-
 fnm = "test_remove_marker_none_1d.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
-# The end
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_setcolormap.py b/testing/vcs/test_vcs_setcolormap.py
index c3e639660..78d7fad81 100644
--- a/testing/vcs/test_vcs_setcolormap.py
+++ b/testing/vcs/test_vcs_setcolormap.py
@@ -1,32 +1,12 @@
 
-import cdms2
-import os
-import sys
-import vcs
-
-baselineFilename = sys.argv[1]
-checkImagePath = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(checkImagePath)
-import checkimage
+import cdms2, os, sys, vcs, testing.regression as regression
 
 cdmsfile = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data = cdmsfile('clt')
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x = regression.init()
 t=x.gettemplate('default')
 x.plot(data, t, bg=True)
 
 # This should force the image to update
 x.setcolormap('bl_to_drkorang')
-
-testFilename = "test_vcs_setcolormap.png"
-x.png(testFilename)
-
-ret = checkimage.check_result_image(testFilename,
-                                    baselineFilename,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_setcolormap.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_settings_color_name_rgba.py b/testing/vcs/test_vcs_settings_color_name_rgba.py
index 0b6aeef22..0fa6ec288 100644
--- a/testing/vcs/test_vcs_settings_color_name_rgba.py
+++ b/testing/vcs/test_vcs_settings_color_name_rgba.py
@@ -1,28 +1,13 @@
-import vcs
-import numpy
-import os
-import sys
-import cdms2
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, numpy, os, sys, cdms2, testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+x = regression.init()
 
-f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
-data=f("clt",slice(0,1,))
+f = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
+data = f("clt",slice(0,1,))
 gm = x.createisofill()
 gm.levels = range(0,110,10)
 gm.fillareacolors = ["green","red","blue","bisque","yellow","grey",
         [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]]
 x.plot(data,gm,bg=True)
-fnm = 'test_vcs_settings_color_name_rgba_isofill.png'
-src = sys.argv[1]
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+fnm = "test_vcs_settings_color_name_rgba_isofill.png"
+regression.run(x, fnm)
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_1d.py b/testing/vcs/test_vcs_settings_color_name_rgba_1d.py
index 0fe844c20..8bca782a6 100644
--- a/testing/vcs/test_vcs_settings_color_name_rgba_1d.py
+++ b/testing/vcs/test_vcs_settings_color_name_rgba_1d.py
@@ -1,16 +1,6 @@
-import vcs
-import numpy
-import os
-import sys
-import cdms2
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, numpy, os, sys, cdms2, testing.regression as regression
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+x = regression.init()
 
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data=f("clt")[:,5,8]
@@ -18,10 +8,4 @@ gm = x.create1d()
 gm.linecolor="salmon"
 gm.markercolor = [0,0,100]
 x.plot(data,gm,bg=True)
-fnm = 'test_vcs_settings_color_name_rgba_1d.png'
-src = sys.argv[1]
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, 'test_vcs_settings_color_name_rgba_1d.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py b/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py
index 043d331c8..34228513e 100644
--- a/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py
+++ b/testing/vcs/test_vcs_settings_color_name_rgba_boxfill.py
@@ -1,17 +1,6 @@
-import vcs
-import numpy
-import os
-import sys
-import cdms2
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+import vcs, numpy, os, sys, cdms2, testing.regression as regression
 
+x = regression.init()
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data=f("clt",slice(0,1,))
 gm = x.createboxfill()
@@ -20,10 +9,4 @@ gm.levels = range(0,110,10)
 gm.fillareacolors = ["green","red","blue","bisque","yellow","grey",
         [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]]
 x.plot(data,gm,bg=True)
-fnm = 'test_vcs_settings_color_name_rgba_boxfill.png'
-src = sys.argv[1]
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, 'test_vcs_settings_color_name_rgba_boxfill.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py b/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py
index 200293dbe..c23edc2a6 100644
--- a/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py
+++ b/testing/vcs/test_vcs_settings_color_name_rgba_isoline.py
@@ -1,17 +1,6 @@
-import vcs
-import numpy
-import os
-import sys
-import cdms2
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+import vcs, numpy, os, sys, cdms2, testing.regression as regression
 
+x=regression.init()
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data=f("clt",slice(0,1,))
 gm = x.createisoline()
@@ -19,10 +8,4 @@ gm.levels = range(0,110,10)
 gm.linecolors = ["green","red","blue","bisque","yellow","grey",
         [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]]
 x.plot(data,gm,bg=True)
-fnm = 'test_vcs_settings_color_name_rgba_isoline.png'
-src = sys.argv[1]
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, 'test_vcs_settings_color_name_rgba_isoline.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py b/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py
index 4a0858d1d..0b3ffc871 100644
--- a/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py
+++ b/testing/vcs/test_vcs_settings_color_name_rgba_meshfill.py
@@ -1,17 +1,6 @@
-import vcs
-import numpy
-import os
-import sys
-import cdms2
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1090,units="pixels")
+import vcs, numpy, os, sys, cdms2, testing.regression as regression
 
+x = regression.init()
 f=cdms2.open(os.path.join(vcs.sample_data,"sampleCurveGrid4.nc"))
 data=f("sample")
 gm = x.createmeshfill()
@@ -19,10 +8,4 @@ gm.levels = range(0,1501,150)
 gm.fillareacolors = ["green","red","blue","bisque","yellow","grey",
         [100,0,0,50], [0,100,0],"salmon",[0,0,100,75]]
 x.plot(data,gm,bg=True)
-fnm = 'test_vcs_settings_color_name_rgba_meshfill.png'
-src = sys.argv[1]
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+ret = regression.run(x, 'test_vcs_settings_color_name_rgba_meshfill.png')
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_star_triangle_markers.py b/testing/vcs/test_vcs_star_triangle_markers.py
index 4564e4059..2d75e05d0 100644
--- a/testing/vcs/test_vcs_star_triangle_markers.py
+++ b/testing/vcs/test_vcs_star_triangle_markers.py
@@ -1,9 +1,5 @@
 
-import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import vcs, numpy, cdms2, MV2, os, sys, testing.regression as regression
 
 x=vcs.init()
 x.drawlogooff()
@@ -16,12 +12,5 @@ m.x = [[.1], [.3], [.5], [.7], [.9]]
 m.y = [[.1], [.3], [.5], [.7], [.9]]
 m.color = [200, 150, 160, 175, 125]
 m.size = [50, 50, 50, 50, 50]
-x.plot(m,bg=1)
-fnm = "test_star_triangle_markers.png"
-x.png(fnm)
-
-print "fnm:",fnm
-print "src:",src
-
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+x.plot(m, bg=1)
+regression.run(x, "test_star_triangle_markers.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_taylor_2quads.py b/testing/vcs/test_vcs_taylor_2quads.py
index 3458acb91..84f102615 100644
--- a/testing/vcs/test_vcs_taylor_2quads.py
+++ b/testing/vcs/test_vcs_taylor_2quads.py
@@ -1,17 +1,6 @@
 
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import vcs, MV2
+import sys, os, vcs, MV2, testing.regression as regression
 
-
-bg=True
-
-#
-# First create some sample data
-#
 data = MV2.array([[-0.50428531,-0.8505522 ,],
  [ 0.70056821,-0.27235352,],
  [ 0.05106154, 0.23012322,],
@@ -19,20 +8,8 @@ data = MV2.array([[-0.50428531,-0.8505522 ,],
  [ 0.85760801,-0.08336641,],
  [ 1.14083397,-0.78326507,]])
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-
-if bg:
-  x.setbgoutputdimensions(1200,1091,units="pixels")
-
-td=x.createtaylordiagram('new')
-
+x = regression.init()
+td = x.createtaylordiagram('new')
 td.quadrans = 2
-x.plot(data,td,skill = td.defaultSkillFunction,bg=bg)
-fnm = "test_vcs_taylor_2quads.png"
-x.png(fnm)
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-if not bg:
-    raw_input("Press Enter")
-sys.exit(ret)
+x.plot(data, td, skill = td.defaultSkillFunction, bg=1)
+regression.run(x, "test_vcs_taylor_2quads.png")
diff --git a/testing/vcs/test_vcs_taylor_template_ctl.py b/testing/vcs/test_vcs_taylor_template_ctl.py
index 40b78f0dc..b6f610c7d 100644
--- a/testing/vcs/test_vcs_taylor_template_ctl.py
+++ b/testing/vcs/test_vcs_taylor_template_ctl.py
@@ -1,20 +1,8 @@
 
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import vcs,MV2
+import sys, os, vcs, MV2
+import testing.regression as regression
 
-bg=True
-
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-if bg:
-  x.setbgoutputdimensions(1200,1091,units="pixels")
-if not bg:
-    x.open()
+x = regression.init()
 
 ## Create a template from the default taylor diagram
 t=x.createtemplate('mytaylor','deftaylor')
@@ -61,12 +49,5 @@ t.xmintic2.priority=1
 # Create some dummy data for display purposes
 data=MV2.array([[1.52,.52,],[.83,.84]])
 
-x.plot(data,t,td,bg=bg)
-fnm="test_vcs_taylor_template_ctl.png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-if not bg:
-    raw_input("Press Enter")
-sys.exit(ret)
+x.plot(data, t, td, bg=1)
+regression.run(x, "test_vcs_taylor_template_ctl.png")
diff --git a/testing/vcs/test_vcs_user_passed_date.py b/testing/vcs/test_vcs_user_passed_date.py
index 643d2019c..bb5b18a0d 100644
--- a/testing/vcs/test_vcs_user_passed_date.py
+++ b/testing/vcs/test_vcs_user_passed_date.py
@@ -1,18 +1,9 @@
 import vcs,cdms2,os,sys,cdtime
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import testing.regression as regression
+
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 s=f("clt",squeeze=1)
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x=regression.init()
 x.plot(s,bg=1,time=cdtime.comptime(2015))
 fnm = os.path.split(__file__)[1][:-3]+".png"
-x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
diff --git a/testing/vcs/test_vcs_user_passed_date_as_string.py b/testing/vcs/test_vcs_user_passed_date_as_string.py
index cd5d777f3..e9bdf83e6 100644
--- a/testing/vcs/test_vcs_user_passed_date_as_string.py
+++ b/testing/vcs/test_vcs_user_passed_date_as_string.py
@@ -1,18 +1,11 @@
 import vcs,cdms2,os,sys,cdtime
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import testing.regression as regression
+
+x = regression.init()
+
 f=cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 s=f("clt",squeeze=1)
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
 x.plot(s,bg=1,time='2015-02-23')
 fnm = os.path.split(__file__)[1][:-3]+".png"
 x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, fnm)
diff --git a/testing/vcs/test_vcs_vectors_missing.py b/testing/vcs/test_vcs_vectors_missing.py
index fd53c97e1..5e8b08e5b 100644
--- a/testing/vcs/test_vcs_vectors_missing.py
+++ b/testing/vcs/test_vcs_vectors_missing.py
@@ -1,6 +1,6 @@
 
-import sys,os
-import argparse
+import sys, os, argparse
+import vcs, cdms2, vtk, MV2, numpy, testing.regression as regression
 
 p = argparse.ArgumentParser(description="Basic gm testing code for vcs")
 p.add_argument("--source", dest="src", help="source image file")
@@ -14,28 +14,17 @@ if not args.show:
   src = args.src
   pth = os.path.join(os.path.dirname(__file__),"..")
   sys.path.append(pth)
-  import checkimage
-
-import vcs
-import sys
-import cdms2
-import vtk
-import os
-import MV2
-import numpy
-
 
 bg = not args.show
-
-x=vcs.init()
+x = vcs.init()
 x.setantialiasing(0)
 x.drawlogooff()
 if bg:
   x.setbgoutputdimensions(1200,1091,units="pixels")
 x.setcolormap("rainbow")
-gm=vcs.createvector()
+gm = vcs.createvector()
 gm.scale = args.scale
-nm_xtra=""
+nm_xtra = ""
 xtra = {}
 import cdms2
 import os
@@ -52,14 +41,12 @@ if args.show:
   pass
   #x.interact()
 else:
-  fnm = "test_vcs_vectors_missing" 
+  fnm = "test_vcs_vectors_missing"
   if args.scale!=1.:
     fnm+="_%.1g" % args.scale
   fnm+=nm_xtra
   x.png(fnm)
-  print "fnm:",fnm
-  print "src:",src
-  ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep)
+  ret = regression.check_result_image(fnm+'.png', src, regression.defaultThreshold, cleanup=not args.keep)
 if args.show:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcs/test_vcs_vectors_robinson.py b/testing/vcs/test_vcs_vectors_robinson.py
index 49052c679..5cde92c82 100644
--- a/testing/vcs/test_vcs_vectors_robinson.py
+++ b/testing/vcs/test_vcs_vectors_robinson.py
@@ -1,13 +1,7 @@
 import vcs, cdms2, numpy, os, sys
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import testing.regression as regression
 
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 1091, units="pixels")
+x = regression.init()
 f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 u = f("u")
 v = f("v")
@@ -16,8 +10,4 @@ p = x.createprojection()
 p.type = "robinson"
 V.projection = p
 x.plot(u,v,V, bg=1)
-
-fnm = "test_vcs_vectors_robinson.png"
-x.png(fnm)
-ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_vectors_robinson.png")
diff --git a/testing/vcs/test_vcs_vectors_robinson_wrap.py b/testing/vcs/test_vcs_vectors_robinson_wrap.py
index 86491cc2f..3cb30f06f 100644
--- a/testing/vcs/test_vcs_vectors_robinson_wrap.py
+++ b/testing/vcs/test_vcs_vectors_robinson_wrap.py
@@ -1,13 +1,7 @@
 import vcs, cdms2, numpy, os, sys
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import testing.regression as regression
 
-x = vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200, 1091, units="pixels")
+x = regression.init()
 f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
 lon1 = -180
 u = f("clt")
@@ -19,8 +13,4 @@ p = x.createprojection()
 p.type = "robinson"
 V.projection = p
 x.plot(u,v,V, bg=1)
-
-fnm = "test_vcs_vectors_robinson_wrap.png"
-x.png(fnm)
-ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "test_vcs_vectors_robinson_wrap.png")
diff --git a/testing/vcs/test_vcs_verify_boxfill_basics.py b/testing/vcs/test_vcs_verify_boxfill_basics.py
index 7d08a2b75..0d7c4c2d0 100644
--- a/testing/vcs/test_vcs_verify_boxfill_basics.py
+++ b/testing/vcs/test_vcs_verify_boxfill_basics.py
@@ -1,4 +1,3 @@
-
 import vcs
 import numpy
 import cdtime
@@ -12,12 +11,12 @@ b=x.createboxfill()
 assert(b.projection == "linear")
 assert(b.xticlabels1 == "*")
 assert(b.xticlabels2 == "*")
-assert(b.xmtics1 == "") 
+assert(b.xmtics1 == "")
 assert(b.xmtics2 == "")
 assert(b.yticlabels1 == "*")
 assert(b.yticlabels2 == "*")
-assert(b.ymtics1 == "")  
-assert(b.ymtics2 == "")  
+assert(b.ymtics1 == "")
+assert(b.ymtics2 == "")
 assert(numpy.allclose(b.datawc_x1, 1e+20))
 assert(numpy.allclose(b.datawc_x2, 1e+20))
 assert(numpy.allclose(b.datawc_y1, 1e+20))
@@ -71,12 +70,12 @@ assert(b.name == "test_b_ok")
 assert(b.projection == "test_bfill")
 assert(b.xticlabels1 == {23:"Hi"})
 assert(b.xticlabels2 == {23:"Hi"})
-assert(b.xmtics1 == {23:"Hi"}) 
+assert(b.xmtics1 == {23:"Hi"})
 assert(b.xmtics2 == {23:"Hi"})
 assert(b.yticlabels1 == {23:"Hi"})
 assert(b.yticlabels2 == {23:"Hi"})
-assert(b.ymtics1 == {23:"Hi"})  
-assert(b.ymtics2 == {23:"Hi"})  
+assert(b.ymtics1 == {23:"Hi"})
+assert(b.ymtics2 == {23:"Hi"})
 assert(numpy.allclose(b.datawc_x1, 56.7))
 assert(numpy.allclose(b.datawc_x2, 56.7))
 assert(numpy.allclose(b.datawc_y1, 56.7))
diff --git a/testing/vcs/test_vcs_wmo_marker.py b/testing/vcs/test_vcs_wmo_marker.py
index b4478372f..854e4a9be 100644
--- a/testing/vcs/test_vcs_wmo_marker.py
+++ b/testing/vcs/test_vcs_wmo_marker.py
@@ -1,14 +1,10 @@
 
 import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+
+import testing.regression as regression
+x = regression.init()
+
 
 m = x.createmarker()
 M=1
@@ -22,8 +18,5 @@ x.plot(m,bg=1)
 fnm = 'wmo_marker.png'
 x.png(fnm)
 
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(x, "wmo_marker.png")
 
diff --git a/testing/vcs/test_vcs_wmo_markers.py b/testing/vcs/test_vcs_wmo_markers.py
index 5785e0925..5162eeeee 100644
--- a/testing/vcs/test_vcs_wmo_markers.py
+++ b/testing/vcs/test_vcs_wmo_markers.py
@@ -1,26 +1,20 @@
 
 import vcs,numpy,cdms2,MV2,os,sys
-src=sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import testing.regression as regression
 
 wmo = ['w00', 'w01', 'w02', 'w03', 'w04', 'w05', 'w06', 'w07', 'w08', 'w09',
        'w10', 'w11', 'w12', 'w13', 'w14', 'w15', 'w16', 'w17', 'w18', 'w19',
-       'w20', 'w21', 'w22', 'w23', 'w24', 'w25', 'w26', 'w27', 'w28', 'w29', 
+       'w20', 'w21', 'w22', 'w23', 'w24', 'w25', 'w26', 'w27', 'w28', 'w29',
        'w30', 'w31', 'w32', 'w33', 'w34', 'w35', 'w36', 'w37', 'w38', 'w39',
        'w40', 'w41', 'w42', 'w43', 'w44', 'w45', 'w46', 'w47', 'w48', 'w49',
        'w50', 'w51', 'w52', 'w53', 'w54', 'w55', 'w56', 'w57', 'w58', 'w59',
-       'w60', 'w61', 'w62', 'w63', 'w64', 'w65', 'w66', 'w67', 'w68', 'w69', 
+       'w60', 'w61', 'w62', 'w63', 'w64', 'w65', 'w66', 'w67', 'w68', 'w69',
        'w70', 'w71', 'w72', 'w73', 'w74', 'w75', 'w76', 'w77', 'w78', 'w79',
        'w80', 'w81', 'w82', 'w83', 'w84', 'w85', 'w86', 'w87', 'w88', 'w89',
        'w90', 'w91', 'w92', 'w93', 'w94', 'w95', 'w96', 'w97', 'w98', 'w99',
        'w100', 'w101', 'w102']
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
+x = regression.init()
 
 m = x.createmarker()
 M=7
@@ -37,13 +31,6 @@ for Y in range(7):
 m.x = xs
 m.y = ys
 m.list()
-x.plot(m,bg=1)
-fnm = "wmo_markers.png"
-x.png(fnm)
-
-
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
-sys.exit(ret)
+x.plot(m, bg=1)
+regression.run(x, "wmo_markers.png");
 
diff --git a/testing/vcs/vtk_ui/vtk_ui_test.py b/testing/vcs/vtk_ui/vtk_ui_test.py
index facfd7f45..40bbeaef1 100644
--- a/testing/vcs/vtk_ui/vtk_ui_test.py
+++ b/testing/vcs/vtk_ui/vtk_ui_test.py
@@ -1,8 +1,4 @@
-import vtk
-import vcs.vtk_ui
-import os
-import sys
-import time
+import, os, sys, time, vcs.vtk_ui, vtk
 
 
 def init():
@@ -101,15 +97,13 @@ class vtk_ui_test(object):
     def check_image(self, compare_against):
         """
         Checks the current render window's output against the image specified in the argument,
-        returns the result of checkimage.check_result_image
+        returns the result of regression.check_result_image
         """
         generate_png(self.win, self.test_file)
         pth = os.path.join(os.path.dirname(__file__), "../..")
         sys.path.append(pth)
-        import checkimage
-        print "fnm:", self.test_file
-        print "src:", compare_against
-        return checkimage.check_result_image(self.test_file, compare_against, checkimage.defaultThreshold)
+        import regression
+        return regression.check_result_image(self.test_file, compare_against)
 
     def test(self):
         self.do_test()
diff --git a/testing/vcsaddons/test_12_plot_one_leg_per_row.py b/testing/vcsaddons/test_12_plot_one_leg_per_row.py
index b3cfa0fba..0c0298527 100644
--- a/testing/vcsaddons/test_12_plot_one_leg_per_row.py
+++ b/testing/vcsaddons/test_12_plot_one_leg_per_row.py
@@ -1,14 +1,7 @@
-
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import EzTemplate,vcs
-## 12 plot one legend per row
+import os, sys, EzTemplate, vcs, testing.regression as regression
 
 ## Initialize VCS
-x=vcs.init()
+x = vcs.init()
 x.drawlogooff()
 
 bg = True
@@ -20,9 +13,7 @@ for i in range(12):
     t.legend.priority=0 # Turn off legend
 fnm = "test_12_plot_one_leg_per_row.png"
 M.preview(fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py b/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py
index 42e0f64e4..b57b76724 100644
--- a/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py
+++ b/testing/vcsaddons/test_12_plot_one_leg_per_row_right.py
@@ -1,17 +1,13 @@
+import os, sys, testing.regression as regression
 
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
 import EzTemplate,vcs
 import cdms,EzTemplate,vcs,sys
 ## 12 plots 1 legend per row on the right
 ## Initialize VCS
-x=vcs.init()
+x = vcs.init()
 x.drawlogooff()
-bg=True
-M=EzTemplate.Multi(rows=4,columns=3)
+bg = True
+M = EzTemplate.Multi(rows=4,columns=3)
 M.legend.direction='vertical'
 for i in range(12):
     t=M.get(legend='local')
@@ -19,9 +15,7 @@ for i in range(12):
         t.legend.priority=0 # Turn off legend
 fnm = "test_12_plot_one_leg_per_row_right.png"
 M.preview(fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py b/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py
index b6ca9eb34..d46e7b9ac 100644
--- a/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py
+++ b/testing/vcsaddons/test_EzTemplate_12_plots_legd_direction.py
@@ -1,14 +1,7 @@
-
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import EzTemplate,vcs
-## 12 plot one legend per row
+import os, sys, EzTemplate, vcs, testing.regression as regression
 
 ## Initialize VCS
-x=vcs.init()
+x = vcs.init()
 x.drawlogooff()
 
 bg = True
@@ -26,10 +19,8 @@ for i in range(12):
       t=M.get()
 
 fnm = "test_EzTemplate_12_plots_legd_direction.png"
-M.preview(fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+M.preview(fnm, bg=bg)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py b/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py
index 40899f264..73b7c8dbf 100644
--- a/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py
+++ b/testing/vcsaddons/test_EzTemplate_12_plots_margins_thickness.py
@@ -1,14 +1,7 @@
-
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import EzTemplate,vcs
-## 12 plot one legend per row
+import os, sys, EzTemplate, vcs, testing.regression as regression
 
 ## Initialize VCS
-x=vcs.init()
+x = vcs.init()
 x.drawlogooff()
 
 bg = True
@@ -25,9 +18,7 @@ for i in range(12):
       t=M.get()
 fnm = "test_EzTemplate_12_plots_margins_thickness.png"
 M.preview(fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py b/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py
index 043e03de4..6e9398fe8 100644
--- a/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py
+++ b/testing/vcsaddons/test_EzTemplate_12_plots_mix_glb_local.py
@@ -1,12 +1,4 @@
-
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import EzTemplate,vcs
-## 12 plot one legend per row
-
+import os, sys, EzTemplate, vcs, testing.regression as regression
 ## Initialize VCS
 x=vcs.init()
 x.drawlogooff()
@@ -24,9 +16,7 @@ for i in range(12):
 
 fnm = "test_EzTemplate_12_plots_mix_glb_local.png"
 M.preview(fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py b/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py
index d17eb1a69..5d4cd293b 100644
--- a/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py
+++ b/testing/vcsaddons/test_EzTemplate_12_plots_spacing.py
@@ -1,14 +1,6 @@
-
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-import EzTemplate,vcs
-## 12 plot one legend per row
-
+import os, sys, EzTemplate, vcs, testing.regression as regression
 ## Initialize VCS
-x=vcs.init()
+x = vcs.init()
 x.drawlogooff()
 
 bg = True
@@ -18,9 +10,7 @@ M.spacing.vertical=.1
 
 fnm = "test_EzTemplate_12_plots_spacing.png"
 M.preview(fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py b/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
index 2619fe5ef..ee645d16c 100644
--- a/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
+++ b/testing/vcsaddons/test_vcs_addons_EzTemplate_2x2.py
@@ -1,21 +1,11 @@
+import os, sys, cdms2, testing.regression as regression, vcs, vcsaddons
 
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-import vcs
-import vcsaddons
-import cdms2
-
-f=cdms2.open(os.path.join(vcs.sample_data,'clt.nc'))
-s=f("clt",time=slice(0,1),squeeze=1)
+f = cdms2.open(os.path.join(vcs.sample_data,'clt.nc'))
+s = f("clt",time=slice(0,1),squeeze=1)
 
 bg = True
-
-M=vcsaddons.EzTemplate.Multi(rows=2,columns=2)
-x=vcs.init()
+M = vcsaddons.EzTemplate.Multi(rows=2,columns=2)
+x = vcs.init()
 x.setantialiasing(0)
 x.drawlogooff()
 if bg:
@@ -25,9 +15,7 @@ for i in range(4):
 
 fnm = "test_vcs_addons_EzTemplate_2x2.png"
 x.png(fnm)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
diff --git a/testing/vcsaddons/test_vcsaddons_preview_2x2.py b/testing/vcsaddons/test_vcsaddons_preview_2x2.py
index 754aa5cea..a0318f25a 100644
--- a/testing/vcsaddons/test_vcsaddons_preview_2x2.py
+++ b/testing/vcsaddons/test_vcsaddons_preview_2x2.py
@@ -1,22 +1,12 @@
-
-import sys,os
-src = sys.argv[1]
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
-
-import vcsaddons
+import os, sys, testing.regression as regression, vcsaddons
 
 bg = True
-
-M=vcsaddons.EzTemplate.Multi(rows=2,columns=2)
+M = vcsaddons.EzTemplate.Multi(rows=2,columns=2)
 if bg:
   M.x.setbgoutputdimensions(1200,1091,units="pixels")
 fnm = "test_vcsaddons_preview_2x2.png"
 M.preview(out=fnm,bg=bg)
-print "fnm:",fnm
-print "src:",src
-ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
+ret = regression.check_result_image(fnm, sys.argv[1])
 if not bg:
     raw_input("Press Enter")
 sys.exit(ret)
-- 
GitLab


From 569843aec62da106d9a7452983f49c999adcf4aa Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Fri, 13 May 2016 07:34:01 -0400
Subject: [PATCH 26/68] Updated to current master

---
 testing/vcs/test_fewer_colors_than_levels.py | 20 +++--------------
 testing/vcs/test_vcs_no_continents.py        | 23 +++-----------------
 2 files changed, 6 insertions(+), 37 deletions(-)

diff --git a/testing/vcs/test_fewer_colors_than_levels.py b/testing/vcs/test_fewer_colors_than_levels.py
index 2779d4b6d..c500cf19e 100644
--- a/testing/vcs/test_fewer_colors_than_levels.py
+++ b/testing/vcs/test_fewer_colors_than_levels.py
@@ -1,18 +1,9 @@
-import vcs,cdms2,sys,os
-
-baselineImage = sys.argv[1]
-
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, cdms2, vcs, testing.regression as regression
 
 dataset = cdms2.open(os.path.join(vcs.sample_data,"clt.nc"))
 data = dataset("clt")
 
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200, 1091, units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 boxfill = canvas.createboxfill()
 
@@ -21,9 +12,4 @@ boxfill.color_2 = 250
 
 canvas.plot(data, boxfill, bg=1)
 
-testImage = os.path.abspath("test_fewer_colors_than_levels.png")
-canvas.png(testImage)
-
-ret = checkimage.check_result_image(testImage, baselineImage, checkimage.defaultThreshold)
-
-sys.exit(ret)
+regression.run(canvas, "test_fewer_colors_than_levels.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_no_continents.py b/testing/vcs/test_vcs_no_continents.py
index 03630d457..a5c3e8d04 100644
--- a/testing/vcs/test_vcs_no_continents.py
+++ b/testing/vcs/test_vcs_no_continents.py
@@ -1,7 +1,4 @@
-import cdms2
-import os
-import sys
-import vcs
+import os, sys, cdms2, vcs, testing.regression as regression
 
 # Load the clt data:
 dataFile = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
@@ -10,10 +7,7 @@ clt = clt(latitude=(-90.0, 90.0), longitude=(-180., 175.), squeeze=1,
           time=('1979-1-1 0:0:0.0', '1988-12-1 0:0:0.0'))
 
 # Initialize canvas:
-canvas = vcs.init()
-canvas.setantialiasing(0)
-canvas.setbgoutputdimensions(1200,1091,units="pixels")
-canvas.drawlogooff()
+canvas = regression.init()
 
 t1 = vcs.createtemplate()
 t1.scale(.5, "y")
@@ -24,15 +18,4 @@ t2.move(.5, 'y')
 canvas.plot(clt, t1, continents=0, bg=True)
 canvas.plot(clt, t2, continents=1, bg=True)
 
-# Load the image testing module:
-testingDir = os.path.join(os.path.dirname(__file__), "..")
-sys.path.append(testingDir)
-import checkimage
-
-# Create the test image and compare:
-baseline = sys.argv[1]
-testFile = "test_vcs_no_continents.png"
-canvas.png(testFile)
-ret = checkimage.check_result_image(testFile, baseline,
-                                    checkimage.defaultThreshold)
-sys.exit(ret)
+regression.run(canvas, "test_vcs_no_continents.png")
\ No newline at end of file
-- 
GitLab


From 9990b92bbd4c29b95800d8a9feb3f14060158074 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Fri, 13 May 2016 07:36:49 -0400
Subject: [PATCH 27/68] Ported common code to testing common

---
 Packages/testing/common.py                    | 22 +++++++++++++++++++
 Packages/testing/regression.py                |  1 +
 .../vcs/test_vcs_fillarea_basics_no_plot.py   |  8 ++-----
 testing/vcs/test_vcs_verify_boxfill_basics.py |  7 ++----
 testing/vcs/test_vcs_verify_proj_basics.py    |  8 ++-----
 5 files changed, 29 insertions(+), 17 deletions(-)
 create mode 100644 Packages/testing/common.py

diff --git a/Packages/testing/common.py b/Packages/testing/common.py
new file mode 100644
index 000000000..7a32bcec5
--- /dev/null
+++ b/Packages/testing/common.py
@@ -0,0 +1,22 @@
+def test_values_setting(gm,attributes,good_values=[],bad_values=[]):
+  if isinstance(attributes,str):
+    attributes=[attributes,]
+  for att in attributes:
+    for val in good_values:
+      setattr(gm,att,val)
+    for val in bad_values:
+      try:
+        setattr(gm,att,val)
+        success = True
+      except:
+        success = False
+      else:
+        if success:
+          if hasattr(gm,"g_name"):
+            nm = gm.g_name
+          elif hasattr(gm,"s_name"):
+            nm = gm.s_name
+          else:
+            nm=gm.p_name
+          raise Exception,"Should not be able to set %s attribute '%s' to %s" % (nm,att,repr(val))
+          sys.exit(1)
diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py
index 68f381ce4..bcc088202 100644
--- a/Packages/testing/regression.py
+++ b/Packages/testing/regression.py
@@ -138,6 +138,7 @@ def check_result_image(fname, baselinefname=sys.argv[1], threshold=defaultThresh
     printDart("ValidImage", "image/png", os.path.abspath(bestFilename), "File")
     return -1
 
+
 def main():
     if len(sys.argv) != 4:
         print "Error:"
diff --git a/testing/vcs/test_vcs_fillarea_basics_no_plot.py b/testing/vcs/test_vcs_fillarea_basics_no_plot.py
index 870aae9be..9a8e38ce7 100644
--- a/testing/vcs/test_vcs_fillarea_basics_no_plot.py
+++ b/testing/vcs/test_vcs_fillarea_basics_no_plot.py
@@ -1,9 +1,5 @@
-
-import vcs
-import numpy
-import cdtime
-
-from vcs_test_common import *
+import numpy, cdtime, vcs
+from testing.common import test_values_setting
 
 x=vcs.init()
 x.drawlogooff()
diff --git a/testing/vcs/test_vcs_verify_boxfill_basics.py b/testing/vcs/test_vcs_verify_boxfill_basics.py
index 0d7c4c2d0..0768ff9f9 100644
--- a/testing/vcs/test_vcs_verify_boxfill_basics.py
+++ b/testing/vcs/test_vcs_verify_boxfill_basics.py
@@ -1,8 +1,5 @@
-import vcs
-import numpy
-import cdtime
-
-from vcs_test_common import *
+import numpy, cdtime, vcs
+from testing.common import test_values_setting
 
 x=vcs.init()
 x.drawlogooff()
diff --git a/testing/vcs/test_vcs_verify_proj_basics.py b/testing/vcs/test_vcs_verify_proj_basics.py
index f1e1fa0a9..822a6fc0b 100644
--- a/testing/vcs/test_vcs_verify_proj_basics.py
+++ b/testing/vcs/test_vcs_verify_proj_basics.py
@@ -1,9 +1,5 @@
-
-import vcs
-import numpy
-import cdtime
-
-from vcs_test_common import *
+import numpy, cdtime, vcs
+from testing.common import test_values_setting
 
 x=vcs.init()
 x.drawlogooff()
-- 
GitLab


From a2ce6ac2f478aae2a184d4f618bbd3542325a1e1 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Fri, 13 May 2016 08:01:52 -0400
Subject: [PATCH 28/68] Added testing to the modules to be built

---
 Packages/testing/regression.py |  2 ++
 Packages/testing/setup.py      |  3 +--
 installation/control.py        | 11 ++++++-----
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py
index bcc088202..b272d592f 100644
--- a/Packages/testing/regression.py
+++ b/Packages/testing/regression.py
@@ -27,10 +27,12 @@ def init():
     return vcsinst
 
 def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
+    """Export plot to a png and exit after comparsion."""
     vcsinst.png(fname)
     sys.exit(check_result_image(fname, baseline, threshold))
 
 def run_wo_terminate(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
+    """Export plot to a png and return comparison with baseline."""
     vcsinst.png(fname)
     return check_result_image(fname, baseline, threshold)
 
diff --git a/Packages/testing/setup.py b/Packages/testing/setup.py
index 70f790d7b..85c270ed8 100755
--- a/Packages/testing/setup.py
+++ b/Packages/testing/setup.py
@@ -9,6 +9,5 @@ setup(name="testing",
       description="Testing infrastructure for cdat",
       url="http://uvcdat.llnl.gov",
       packages=['testing'],
-      package_dir={'testing': 'testing',},
-      install_requires=['numpy','vcs', 'vtk'],
+      package_dir = {'testing': '', }
 )
diff --git a/installation/control.py b/installation/control.py
index 7a3a52091..49ed5d9af 100644
--- a/installation/control.py
+++ b/installation/control.py
@@ -1,7 +1,7 @@
 # This file is used to control the behavior of install.py.
 
 # The search path is used if the X11 directories aren't configured.
-x11search = ['/usr/X11R6', '/usr/X11R6.5.1', 
+x11search = ['/usr/X11R6', '/usr/X11R6.5.1',
              '/usr/X11R6.4','/usr','/usr/openwin','/opt']
 # Here is where they are on OSF1 and perhaps similar systems
 x11OSF1lib = ['/usr/lib/X11', '/usr/lib']
@@ -48,14 +48,14 @@ else:
     make_code = 'make'
 
 # List of packages to be built
-packages = [ 
+packages = [
     "Packages/pydebug",
     "Packages/cdtime",
     "Packages/demo",
     "Packages/help",
     "Packages/regrid2",
-    "Packages/cdms2", 
-    "Packages/esg", 
+    "Packages/cdms2",
+    "Packages/esg",
     "Packages/ncml",
     "Packages/DV3D",
     "Packages/vcs",
@@ -63,9 +63,10 @@ packages = [
     "Packages/cdutil",
     "Packages/unidata",
     "Packages/xmgrace",
-    "Packages/genutil", 
+    "Packages/genutil",
     "Packages/Thermo",
     "Packages/WK",
     "Packages/gui_support",
     "Packages/distarray",
+    "Packages/testing",
     ]
-- 
GitLab


From 477e09750e554da288341d72ffd1d0cf39bce308 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Fri, 13 May 2016 14:21:05 -0400
Subject: [PATCH 29/68] Marked export to gs as no longer supported

---
 Packages/vcs/vcs/Canvas.py | 63 ++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 34 deletions(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index d98270c55..8de655fbc 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -5309,47 +5309,42 @@ Options:::
     def gs(self, filename='noname.gs', device='png256',
            orientation=None, resolution='792x612'):
         """
- Function: gs
+        Function: gs
 
- Description of Function:
-    This routine allows the user to save the VCS canvas in one of the many
-    GhostScript (gs) file types (also known as devices). To view other
-    GhostScript devices, issue the command "gs --help" at the terminal
-    prompt. Device names include: bmp256, epswrite, jpeg, jpeggray,
-    pdfwrite, png256, png16m, sgirgb, tiffpack, and tifflzw. By default
-    the device = 'png256'.
-
-    If no path/file name is given and no previously created gs file has been
-    designated, then file
+        Description of Function:
+        This routine allows the user to save the VCS canvas in one of the many
+        GhostScript (gs) file types (also known as devices). To view other
+        GhostScript devices, issue the command "gs --help" at the terminal
+        prompt. Device names include: bmp256, epswrite, jpeg, jpeggray,
+        pdfwrite, png256, png16m, sgirgb, tiffpack, and tifflzw. By default
+        the device = 'png256'.
+
+        If no path/file name is given and no previously created gs file has been
+        designated, then file
 
         /$HOME/%s/default.gs
 
-    will be used for storing gs images. However, if a previously created gs
-    file exist, then this output file will be used for storage.
+        will be used for storing gs images. However, if a previously created gs
+        file exist, then this output file will be used for storage.
 
-    By default, the page orientation is the canvas' orientation.
-    To translate the page orientation to portrait mode (p), set the parameter orientation = 'p'.
-    To translate the page orientation to landscape mode (l), set the parameter orientation = 'l'.
+        By default, the page orientation is the canvas' orientation.
+        To translate the page orientation to portrait mode (p), set the parameter orientation = 'p'.
+        To translate the page orientation to landscape mode (l), set the parameter orientation = 'l'.
 
-    The gs command is used to create a single gs file at this point. The user
-    can use other tools to append separate image files.
+        The gs command is used to create a single gs file at this point. The user
+        can use other tools to append separate image files.
 
- Example of Use:
-    a=vcs.init()
-    a.plot(array)
-    a.gs('example') #defaults: device='png256', orientation='l' and resolution='792x612'
-    a.gs(filename='example.tif', device='tiffpack', orientation='l', resolution='800x600')
-    a.gs(filename='example.pdf', device='pdfwrite', orientation='l', resolution='200x200')
-    a.gs(filename='example.jpg', device='jpeg', orientation='p', resolution='1000x1000')
-""" % (self._dotdir)
-        if orientation is None:
-            orientation = self.orientation()[0]
-        r = resolution.split('x')
-        f1 = f1 = float(r[0]) / 1100.0 * 100.0
-        f2 = f2 = float(r[1]) / 849.85 * 100.0
-        resolution = "%4.1fx%4.1f" % (f2, f1)
-        nargs = (filename, device, orientation, resolution)
-        return self.canvas.gs(*nargs)
+        Example of Use:
+        a=vcs.init()
+        a.plot(array)
+        a.gs('example') #defaults: device='png256', orientation='l' and resolution='792x612'
+        a.gs(filename='example.tif', device='tiffpack', orientation='l', resolution='800x600')
+        a.gs(filename='example.pdf', device='pdfwrite', orientation='l', resolution='200x200')
+        a.gs(filename='example.jpg', device='jpeg', orientation='p', resolution='1000x1000')
+
+        NOTE: This method is marked as deprecated
+        """ % (self._dotdir)
+        warnings.warn("Export to GhostScript is no longer supported", Warning)
 
     ##########################################################################
     #                                                                           #
-- 
GitLab


From 853af67c62c4aa7e5e42400e3027bf497a5c49fd Mon Sep 17 00:00:00 2001
From: Charles Doutriaux <doutriaux1@llnl.gov>
Date: Mon, 16 May 2016 09:00:14 -0700
Subject: [PATCH 30/68] Update Canvas.py

Allow for deprecation warnings
---
 Packages/vcs/vcs/Canvas.py | 38 ++------------------------------------
 1 file changed, 2 insertions(+), 36 deletions(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 8de655fbc..79dcd0dcd 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -27,6 +27,7 @@ Normally, created by vcs.init()
 Contains the method plot.
 """
 import warnings
+warnings.filterwarnings("default","",DeprecationWarning,"",0)
 from pauser import pause
 import numpy.ma
 import MV2
@@ -5308,43 +5309,8 @@ Options:::
     ##########################################################################
     def gs(self, filename='noname.gs', device='png256',
            orientation=None, resolution='792x612'):
-        """
-        Function: gs
-
-        Description of Function:
-        This routine allows the user to save the VCS canvas in one of the many
-        GhostScript (gs) file types (also known as devices). To view other
-        GhostScript devices, issue the command "gs --help" at the terminal
-        prompt. Device names include: bmp256, epswrite, jpeg, jpeggray,
-        pdfwrite, png256, png16m, sgirgb, tiffpack, and tifflzw. By default
-        the device = 'png256'.
-
-        If no path/file name is given and no previously created gs file has been
-        designated, then file
-
-        /$HOME/%s/default.gs
-
-        will be used for storing gs images. However, if a previously created gs
-        file exist, then this output file will be used for storage.
 
-        By default, the page orientation is the canvas' orientation.
-        To translate the page orientation to portrait mode (p), set the parameter orientation = 'p'.
-        To translate the page orientation to landscape mode (l), set the parameter orientation = 'l'.
-
-        The gs command is used to create a single gs file at this point. The user
-        can use other tools to append separate image files.
-
-        Example of Use:
-        a=vcs.init()
-        a.plot(array)
-        a.gs('example') #defaults: device='png256', orientation='l' and resolution='792x612'
-        a.gs(filename='example.tif', device='tiffpack', orientation='l', resolution='800x600')
-        a.gs(filename='example.pdf', device='pdfwrite', orientation='l', resolution='200x200')
-        a.gs(filename='example.jpg', device='jpeg', orientation='p', resolution='1000x1000')
-
-        NOTE: This method is marked as deprecated
-        """ % (self._dotdir)
-        warnings.warn("Export to GhostScript is no longer supported", Warning)
+        warnings.warn("Export to GhostScript is no longer supported", DeprecationWarning)
 
     ##########################################################################
     #                                                                           #
-- 
GitLab


From 243863d7c57e1727ef3110610682910ad230026c Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Mon, 16 May 2016 14:36:56 -0400
Subject: [PATCH 31/68] Added note on deprecation warning and moved it further
 down

---
 Packages/vcs/vcs/Canvas.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 79dcd0dcd..06a8bebdc 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -27,7 +27,6 @@ Normally, created by vcs.init()
 Contains the method plot.
 """
 import warnings
-warnings.filterwarnings("default","",DeprecationWarning,"",0)
 from pauser import pause
 import numpy.ma
 import MV2
@@ -74,6 +73,8 @@ import vcs.manageElements  # noqa
 import configurator  # noqa
 from projection import round_projections  # noqa
 
+# Python < 3 DeprecationWarning ignored by default
+warnings.filterwarnings("default", "", DeprecationWarning, "", 0)
 
 class SIGNAL(object):
 
-- 
GitLab


From 4e5e43d954b7e8fd05c0873bc38df773e02e6743 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Mon, 16 May 2016 14:58:39 -0400
Subject: [PATCH 32/68] Using a simple approach to turn on deprecation warning

---
 Packages/vcs/vcs/Canvas.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 06a8bebdc..1599e0a03 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -74,7 +74,7 @@ import configurator  # noqa
 from projection import round_projections  # noqa
 
 # Python < 3 DeprecationWarning ignored by default
-warnings.filterwarnings("default", "", DeprecationWarning, "", 0)
+warnings.simplefilter('default')
 
 class SIGNAL(object):
 
-- 
GitLab


From 2dbbdec142265dc8199f3d990201ad660c551392 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Tue, 17 May 2016 16:34:12 -0400
Subject: [PATCH 33/68] Fixed vtk ui tests

---
 testing/vcs/vtk_ui/vtk_ui_test.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testing/vcs/vtk_ui/vtk_ui_test.py b/testing/vcs/vtk_ui/vtk_ui_test.py
index 40bbeaef1..d5cbe18bf 100644
--- a/testing/vcs/vtk_ui/vtk_ui_test.py
+++ b/testing/vcs/vtk_ui/vtk_ui_test.py
@@ -1,4 +1,4 @@
-import, os, sys, time, vcs.vtk_ui, vtk
+import os, sys, time, vtk, vcs.vtk_ui
 
 
 def init():
@@ -102,7 +102,7 @@ class vtk_ui_test(object):
         generate_png(self.win, self.test_file)
         pth = os.path.join(os.path.dirname(__file__), "../..")
         sys.path.append(pth)
-        import regression
+        import testing.regression as regression
         return regression.check_result_image(self.test_file, compare_against)
 
     def test(self):
-- 
GitLab


From 29d182bd5442ea6b71f95f9856d6ec9a9983a6ac Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 07:31:37 -0400
Subject: [PATCH 34/68] Updated test name to match the naming convention

---
 testing/vcs/test_vcs_boxfill_lev1_lev2.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/vcs/test_vcs_boxfill_lev1_lev2.py b/testing/vcs/test_vcs_boxfill_lev1_lev2.py
index c5b5cbcbe..6c1d985d7 100644
--- a/testing/vcs/test_vcs_boxfill_lev1_lev2.py
+++ b/testing/vcs/test_vcs_boxfill_lev1_lev2.py
@@ -7,4 +7,4 @@ b = x.createboxfill()
 b.level_1 = .5
 b.level_2 = 14.5
 x.plot(s, b, bg=1)
-regression.run(x, "test_boxfill_lev1_lev2.png")
+regression.run(x, "test_vcs_boxfill_lev1_lev2.png")
-- 
GitLab


From 88df13b95b1a5000db8d5e58c9c3152865dc5baa Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 09:57:38 -0400
Subject: [PATCH 35/68] Updated dv3d package to use regression module

---
 testing/dv3d/TestManager.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testing/dv3d/TestManager.py b/testing/dv3d/TestManager.py
index 51ed57183..94e7e365e 100644
--- a/testing/dv3d/TestManager.py
+++ b/testing/dv3d/TestManager.py
@@ -10,7 +10,7 @@ import vcs, os, sys, shutil, collections, subprocess
 TestingDir=os.path.dirname(__file__)
 pth = os.path.join(TestingDir,"..")
 sys.path.append(pth)
-import checkimage
+import testing.regression as regression
 
 DefaultSampleFile = "geos5-sample.nc"
 DefaultSampleVar = "uwnd"
@@ -128,8 +128,8 @@ class vcsTest:
         test_image = '.'.join( [ self.name, 'test', 'png' ] )
         self.canvas.png( test_image, width = 900, height = 600 )
 
-        ret = checkimage.check_result_image( test_image, self.image_name,\
-                checkimage.defaultThreshold+3. )
+        ret = regression.check_result_image( test_image, self.image_name,\
+                regression.defaultThreshold+3. )
 
         if  interactive:
             print "Type <Enter> to continue and update ref image ( type 'n' to skip update )."
-- 
GitLab


From 9e86fb3b9be60ea6e08558034a56c2a22bc2c9db Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 09:59:10 -0400
Subject: [PATCH 36/68] Fixed flake8 test

---
 Packages/vcs/vcs/Canvas.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 49fdbf978..0e9d23426 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -76,6 +76,7 @@ from projection import round_projections  # noqa
 # Python < 3 DeprecationWarning ignored by default
 warnings.simplefilter('default')
 
+
 class SIGNAL(object):
 
     def __init__(self, name=None):
-- 
GitLab


From dc508774b3b0d886a7908213c73f8ac21b64a55d Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 10:01:36 -0400
Subject: [PATCH 37/68] Updated esmf test to use regression module

---
 .../regrid/testEsmfRegridPeriodictyRegional.py  | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/testing/regrid/testEsmfRegridPeriodictyRegional.py b/testing/regrid/testEsmfRegridPeriodictyRegional.py
index 2b9279525..53a1a706b 100644
--- a/testing/regrid/testEsmfRegridPeriodictyRegional.py
+++ b/testing/regrid/testEsmfRegridPeriodictyRegional.py
@@ -1,9 +1,4 @@
-import vcs,cdms2
-import os,sys
-import EzTemplate
-pth = os.path.join(os.path.dirname(__file__),"..")
-sys.path.append(pth)
-import checkimage
+import os, sys, vcs, cdms2, EzTemplate, testing.regression as regression
 
 data = sys.argv[1]
 png = sys.argv[2]
@@ -38,11 +33,7 @@ s_esmf_lin.id = "ESMF Linear"
 s_esmf_con = s.regrid(grid_dest,regridTool="esmf",regridMethod="conservative")
 s_esmf_lin.id = "ESMF Conservative"
 
-x=vcs.init()
-x.setantialiasing(0)
-x.drawlogooff()
-x.setbgoutputdimensions(1200,1091,units="pixels")
-
+x=regression.init()
 t=x.createtemplate()
 t.blank()
 t.data.priority=1
@@ -60,7 +51,5 @@ x.plot(s,M.get(),gm,bg=1)
 x.plot(s_regrid2,M.get(),gm,bg=1)
 x.plot(s_esmf_lin,M.get(),gm,bg=1)
 x.plot(s_esmf_con,M.get(),gm,bg=1)
-x.png("esmf_issue_1125")
 
-ret = checkimage.check_result_image("esmf_issue_1125.png",png,checkimage.defaultThreshold)
-sys.exit(ret)
+ret = regression.run(x, "esmf_issue_1125.png", png)
-- 
GitLab


From 395c7459b2a3915c0c7a6eb4f37561ad9af972b8 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 10:10:53 -0400
Subject: [PATCH 38/68] Updated diagnostics tests to use regression module

---
 testing/metrics/diags_test.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testing/metrics/diags_test.py b/testing/metrics/diags_test.py
index ff71c8d66..2d4131cb8 100755
--- a/testing/metrics/diags_test.py
+++ b/testing/metrics/diags_test.py
@@ -12,7 +12,7 @@ import sys, os, shutil, tempfile, subprocess
 import cdms2, numpy
 pth = os.path.join(os.path.dirname(__file__),"..")
 sys.path.append(pth)
-import checkimage
+import testing.regression as regression
 import argparse, pdb
 
 class DiagTest(object):
@@ -95,7 +95,7 @@ class DiagTest(object):
     def execute(self, test_str, imagefilename, imagethreshold, ncfiles, rtol, atol):
         print test_str
         if imagethreshold is None:  # user didn't specify a value
-     	    imagethreshold = checkimage.defaultThreshold
+	    imagethreshold = regression.defaultThreshold
         # Silence annoying messages about how to set the NetCDF file type.  Anything will do.
         cdms2.setNetcdfShuffleFlag(0)
         cdms2.setNetcdfDeflateFlag(0)
@@ -118,7 +118,7 @@ class DiagTest(object):
             imagebaselinefname = os.path.join( self.baselinepath, imagefilename )
             #pdb.set_trace()
             print "OK THRESHOLD IS:",imagethreshold
-            graphics_result = checkimage.check_result_image( imagefname, imagebaselinefname, imagethreshold )
+            graphics_result = regression.check_result_image( imagefname, imagebaselinefname, imagethreshold )
             print "Graphics file", imagefname, "match difference:", graphics_result
             
             #initialize to successful graphics check
-- 
GitLab


From 314fc2bf70fb9c410ba7c1200a1fcaec9dfbfdd5 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 11:53:42 -0400
Subject: [PATCH 39/68] Fixed numpy test

---
 testing/vcs/test_vcs_boxfill_10x10_numpy.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/vcs/test_vcs_boxfill_10x10_numpy.py b/testing/vcs/test_vcs_boxfill_10x10_numpy.py
index a45aa5889..765917942 100644
--- a/testing/vcs/test_vcs_boxfill_10x10_numpy.py
+++ b/testing/vcs/test_vcs_boxfill_10x10_numpy.py
@@ -3,5 +3,5 @@ import vcs, numpy, os, sys, testing.regression as regression
 s = numpy.sin(numpy.arange(100))
 s = numpy.reshape(s,(10,10))
 x = regression.init()
-x.plot(s)
+x.plot(s, bg=1)
 regression.run(x, "test_vcs_boxfill_10x10_numpy.png")
\ No newline at end of file
-- 
GitLab


From f19b372e0ccc187eef150f1ce7af83a56021616b Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 11:59:38 -0400
Subject: [PATCH 40/68] Fixed canvas update test

---
 testing/vcs/test_vcs_boxfill_decreasing_latitude.py | 2 +-
 testing/vcs/test_vcs_canvas_background_update.py    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py
index 1f727e3b5..6cbc0f016 100755
--- a/testing/vcs/test_vcs_boxfill_decreasing_latitude.py
+++ b/testing/vcs/test_vcs_boxfill_decreasing_latitude.py
@@ -51,5 +51,5 @@ gm.fillareacolors = cols
 gm.datawc_y2 = 30
 gm.datawc_y1 = 90
 
-x.plot(ice, gm, tmpl, bg = 1)
+x.plot(ice, gm, tmpl, bg=1)
 regression.run(x, "test_boxfill_decreasing_latitude.png")
\ No newline at end of file
diff --git a/testing/vcs/test_vcs_canvas_background_update.py b/testing/vcs/test_vcs_canvas_background_update.py
index a28c08713..80f79d2aa 100644
--- a/testing/vcs/test_vcs_canvas_background_update.py
+++ b/testing/vcs/test_vcs_canvas_background_update.py
@@ -5,4 +5,4 @@ x.backgroundcolor = (255, 255, 255)
 x.open()
 x.backgroundcolor = (255, 255, 0)
 x.update()
-regression.run(x, "test_backgroundcolor_yellow.png")
\ No newline at end of file
+regression.check_result_image(x, "test_backgroundcolor_yellow.png")
\ No newline at end of file
-- 
GitLab


From a14200869100199487b89ea08dd37ad2b7d97731 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 16:06:31 -0400
Subject: [PATCH 41/68] Using a fixed size for click test

---
 Packages/testing/regression.py     | 8 +++++---
 testing/vcs/test_vcs_click_info.py | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py
index b272d592f..68ded76d9 100644
--- a/Packages/testing/regression.py
+++ b/Packages/testing/regression.py
@@ -16,14 +16,16 @@ import vcs
 
 defaultThreshold=10.0
 
-def init():
+def init(*args, **kwargs):
     testingDir = os.path.join(os.path.dirname(__file__), "..")
     sys.path.append(testingDir)
 
-    vcsinst = vcs.init()
+    vcsinst = vcs.init(*args, **kwargs)
     vcsinst.setantialiasing(0)
     vcsinst.drawlogooff()
-    vcsinst.setbgoutputdimensions(1200,1091,units="pixels")
+
+    if ('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs):
+        vcsinst.setbgoutputdimensions(1200, 1091, units="pixels")
     return vcsinst
 
 def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
diff --git a/testing/vcs/test_vcs_click_info.py b/testing/vcs/test_vcs_click_info.py
index c16a6c0d4..f37ee651a 100644
--- a/testing/vcs/test_vcs_click_info.py
+++ b/testing/vcs/test_vcs_click_info.py
@@ -8,7 +8,7 @@ testConfig = {'a_boxfill': ('clt.nc', 'clt', (200, 200)),
 # Tests if the info produced when clicking on a map is correct.
 src = sys.argv[1]
 plot = sys.argv[2]
-x = regression.init()
+x = regression.init(bg=False, geometry=(800, 600))
 
 # data
 f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0])
-- 
GitLab


From 9c121a20f2121a0fcca665123d50b27553f176a0 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 21:19:46 -0400
Subject: [PATCH 42/68] Fixed failing test because of incorrect capture window
 size

---
 testing/vcs/test_vcs_configurator_resize.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/testing/vcs/test_vcs_configurator_resize.py b/testing/vcs/test_vcs_configurator_resize.py
index 7692e6218..bd3490afb 100644
--- a/testing/vcs/test_vcs_configurator_resize.py
+++ b/testing/vcs/test_vcs_configurator_resize.py
@@ -4,15 +4,16 @@ x = vcs.init()
 x.open()
 x.configure()
 
-x.backend.renWin.SetSize(814, 303)
-
 fnm = "test_vcs_configurator_resize.png"
 
 win = x.backend.renWin
-win.Render()
+win.SetSize(814, 303)
+
 out_filter = vtk.vtkWindowToImageFilter()
 out_filter.SetInput(win)
 
+win.Render()
+
 png_writer = vtk.vtkPNGWriter()
 png_writer.SetFileName(fnm)
 png_writer.SetInputConnection(out_filter.GetOutputPort())
-- 
GitLab


From 2c3407c4a791c301930ea1c634918f16a163d148 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 21:38:46 -0400
Subject: [PATCH 43/68] Set size on render window only if it has been created

---
 Packages/vcs/vcs/VTKPlots.py | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index 8cfe83a28..da5810614 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -73,7 +73,7 @@ class VTKVCSBackend(object):
         # Initially set to 16x Multi-Sampled Anti-Aliasing
         self.antialiasing = 8
         self._rasterPropsInVectorFormats = False
-        self._initialGeometry = geometry
+        self._geometry = geometry
 
         if renWin is not None:
             self.renWin = renWin
@@ -383,9 +383,9 @@ class VTKVCSBackend(object):
             # turning off antialiasing by default
             # mostly so that pngs are same accross platforms
             self.renWin.SetMultiSamples(self.antialiasing)
-            if self._initialGeometry is not None:
-                width = self._initialGeometry["width"]
-                height = self._initialGeometry["height"]
+            if self._geometry is not None:
+                width = self._geometry["width"]
+                height = self._geometry["height"]
             else:
                 width = None
                 height = None
@@ -444,9 +444,9 @@ class VTKVCSBackend(object):
             if (self.bg):
                 height = self.canvas.bgY
                 width = self.canvas.bgX
-            elif (self._initialGeometry):
-                height = self._initialGeometry['height']
-                width = self._initialGeometry['width']
+            elif (self._geometry):
+                height = self._geometry['height']
+                width = self._geometry['width']
             else:
                 height = self.canvas.bgY
                 width = self.canvas.bgX
@@ -554,7 +554,9 @@ class VTKVCSBackend(object):
             return True
 
     def geometry(self, x, y, *args):
-        self.renWin.SetSize(x, y)
+        if self.renWin is not None:
+            self.renWin.SetSize(x, y)
+        self._geometry = {'width': x, 'height': y}
         self._lastSize = (x, y)
 
     def flush(self):
-- 
GitLab


From a36eba425fa8451c4628957e6af434f010736398 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 18 May 2016 21:48:57 -0400
Subject: [PATCH 44/68] Return geometry object if no argument is given

---
 Packages/vcs/vcs/Canvas.py   |  3 +++
 Packages/vcs/vcs/VTKPlots.py | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Packages/vcs/vcs/Canvas.py b/Packages/vcs/vcs/Canvas.py
index 0e9d23426..49361248c 100644
--- a/Packages/vcs/vcs/Canvas.py
+++ b/Packages/vcs/vcs/Canvas.py
@@ -4116,6 +4116,9 @@ Options:::
     a.geometry(450,337)
 
 """
+        if len(args) == 0:
+            return self.backend.geometry()
+
         if (args[0] <= 0) or (args[1] <= 0):
             raise ValueError(
                 'Error -  The width and height values must be an integer greater than 0.')
diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index da5810614..7e32798d1 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -553,7 +553,15 @@ class VTKVCSBackend(object):
         else:
             return True
 
-    def geometry(self, x, y, *args):
+    def geometry(self, *args):
+        if len(args) == 0:
+            return self._geometry;
+        if len(args) < 2:
+            raise TypeError("Function takes zero or two <width, height> " \
+                            "or more than two arguments. Got " + len(*args))
+        x = args[0]
+        y = args[1]
+
         if self.renWin is not None:
             self.renWin.SetSize(x, y)
         self._geometry = {'width': x, 'height': y}
-- 
GitLab


From dc86269c4bf0eb8fe579234fa7bf386f55e1b242 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Thu, 19 May 2016 11:37:09 -0400
Subject: [PATCH 45/68] Added test to validate geometry function

---
 testing/vcs/CMakeLists.txt       |  4 ++++
 testing/vcs/test_vcs_geometry.py | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
 create mode 100644 testing/vcs/test_vcs_geometry.py

diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index 9e8cf78e3..05928a0c8 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -381,6 +381,10 @@ cdat_add_test(test_vcs_missing_colorname
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_missing_colorname.py
   "${BASELINE_DIR}/test_vcs_missing_colorname.png"
   )
+cdat_add_test(test_vcs_geometry
+  "${PYTHON_EXECUTABLE}"
+  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_geometry.py
+  )
 ##############################################################################
 #
 # These tests perform plotting and need sample data
diff --git a/testing/vcs/test_vcs_geometry.py b/testing/vcs/test_vcs_geometry.py
new file mode 100644
index 000000000..578bfb67d
--- /dev/null
+++ b/testing/vcs/test_vcs_geometry.py
@@ -0,0 +1,32 @@
+import sys, vcs
+
+# This will check if we can set the geometry
+# at the initialization of canvas
+canvas = vcs.init(geometry=(600, 400))
+canvas.open()
+
+if dict(width=600, height=400) != canvas.geometry():
+    canvas.close()
+    sys.exit(1)
+
+canvas.close()
+
+canvas2 = vcs.init()
+
+# This will check if we can safely set the geometry even
+# though the canvas window has not been created yet
+canvas2.geometry(400, 400)
+canvas2.open()
+if dict(width=400, height=400) != canvas2.geometry():
+    canvas2.close()
+    sys.exit(1)
+
+# This will check if we can dynamically change the geometry
+canvas2.geometry(500, 400)
+canvas2.geometry(500, 500)
+if dict(width=500, height=500) != canvas2.geometry():
+    canvas2.close()
+    sys.exit(1)
+
+canvas2.close()
+sys.exit(0)
\ No newline at end of file
-- 
GitLab


From 7a599261680593869bc2708a2a0697f5696f9f48 Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Tue, 26 Apr 2016 16:34:06 -0400
Subject: [PATCH 46/68] ENH #1885: Show info at clicked point for point
 datasets

---
 Packages/vcs/vcs/VTKPlots.py                | 197 ++++++++++----------
 Packages/vcs/vcs/vcs2vtk.py                 |   1 +
 Packages/vcs/vcs/vcsvtk/boxfillpipeline.py  |   3 -
 Packages/vcs/vcs/vcsvtk/isofillpipeline.py  |   3 -
 Packages/vcs/vcs/vcsvtk/isolinepipeline.py  |   3 -
 Packages/vcs/vcs/vcsvtk/meshfillpipeline.py |   3 -
 Packages/vcs/vcs/vcsvtk/pipeline2d.py       |  32 +++-
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py   | 124 ++++--------
 testing/vcs/CMakeLists.txt                  |  41 ++--
 testing/vcs/test_vcs_click_info.py          |  26 ++-
 10 files changed, 197 insertions(+), 236 deletions(-)

diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index 8cfe83a28..37382c0e9 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -46,18 +46,16 @@ class VTKVCSBackend(object):
         self._renderers = {}
         self._plot_keywords = [
             'cdmsfile',
-            'cell_coordinates'
-            # used to render the continents
-            'continents_renderer',
+            'cell_coordinates',
             # dataset bounds in lon/lat coordinates
             'dataset_bounds',
             # This may be smaller than the data viewport. It is used
             # if autot is passed
             'ratio_autot_viewport',
-            # used to render the dataset
-            'dataset_renderer',
-            # dataset scale: (xScale, yScale)
-            'dataset_scale',
+            # used to render the dataset for clicked point info (hardware selection)
+            'surface_renderer',
+            # (xScale, yScale) - datasets can be scaled using the window ratio
+            'surface_scale',
             # the same as vcs.utils.getworldcoordinates for now. getworldcoordinates uses
             # gm.datawc_... or, if that is not set, it uses data axis margins (without bounds).
             'plotting_dataset_bounds',
@@ -138,99 +136,92 @@ class VTKVCSBackend(object):
             d = vcs.elements["display"][dnm]
             if d.array[0] is None:
                 continue
-            t = vcs.elements["template"][d.template]
-            gm = vcs.elements[d.g_type][d.g_name]
-            # for non-linear projection or for meshfill. Meshfill is wrapped at
-            # VTK level, so vcs calculations do not work.
-            if gm.projection != "linear" or gm.g_name == 'Gfm':
-                selector = vtk.vtkHardwareSelector()
-                datasetRenderer = d.backend['dataset_renderer']
-                continentsRenderer = d.backend.get('continents_renderer')
-                dataset = d.backend['vtk_backend_grid']
-                if (datasetRenderer and dataset):
-                    selector.SetRenderer(datasetRenderer)
-                    selector.SetArea(xy[0], xy[1], xy[0], xy[1])
-                    selector.SetFieldAssociation(vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS)
-                    # We want to be able see information behind continents
-                    if (continentsRenderer):
-                        continentsRenderer.SetDraw(False)
-                    selection = selector.Select()
-                    if (continentsRenderer):
-                        continentsRenderer.SetDraw(True)
-                    if (selection.GetNumberOfNodes() > 0):
-                        selectionNode = selection.GetNode(0)
-                        prop = selectionNode.GetProperties().Get(selectionNode.PROP())
-                        if (prop):
-                            cellIds = prop.GetMapper().GetInput().GetCellData().GetGlobalIds()
-                            if (cellIds):
-                                # scalar value
-                                a = selectionNode.GetSelectionData().GetArray(0)
-                                geometryId = a.GetValue(0)
-                                cellId = cellIds.GetValue(geometryId)
-                                scalars = dataset.GetCellData().GetScalars()
-                                value = scalars.GetValue(cellId)
-                                geoTransform = d.backend['vtk_backend_geo']
-                                if (geoTransform):
-                                    geoTransform.Inverse()
-                                # Use the world picker to get world coordinates
-                                # we deform the dataset, so we need to fix the
-                                # world picker using xScale, yScale
-                                xScale, yScale = d.backend['dataset_scale']
-                                worldPicker = vtk.vtkWorldPointPicker()
-                                worldPicker.Pick(xy[0], xy[1], 0, datasetRenderer)
-                                worldPosition = list(worldPicker.GetPickPosition())
-                                if (xScale > yScale):
-                                    worldPosition[0] /= (xScale/yScale)
-                                else:
-                                    worldPosition[1] /= (yScale/xScale)
-                                lonLat = worldPosition
-                                if (geoTransform):
-                                    geoTransform.InternalTransformPoint(worldPosition, lonLat)
-                                    geoTransform.Inverse()
-                                st += "Var: %s\n" % d.array[0].id
-                                if (float("inf") not in lonLat):
-                                    st += "X=%4.1f\nY=%4.1f\n" % (lonLat[0], lonLat[1])
-                                st += "Value: %g" % value
-            else:
-                if t.data.x1 <= x <= t.data.x2 and t.data.y1 <= y <= t.data.y2:
-                    x1, x2, y1, y2 = vcs.utils.getworldcoordinates(gm,
-                                                                   d.array[0].getAxis(-1),
-                                                                   d.array[0].getAxis(-2))
-
-                    X = (x - t.data.x1) / (t.data.x2 - t.data.x1) * (x2 - x1) + x1
-                    Y = (y - t.data.y1) / (t.data.y2 - t.data.y1) * (y2 - y1) + y1
-
-                    # Ok we now have the X/Y values we need to figure out the
-                    # indices
-                    try:
-                        I = d.array[0].getAxis(-1).mapInterval((X, X, 'cob'))[0]
-                        try:
-                            J = d.array[
-                                0].getAxis(-2).mapInterval((Y, Y, 'cob'))[0]
-                            # Values at that point
-                            V = d.array[0][..., J, I]
-                        except:
-                            V = d.array[0][..., I]
-                        if isinstance(V, numpy.ndarray):
-                            # Grab the appropriate time slice
-                            if self.canvas.animate.created():
-                                t = self.canvas.animate.frame_num
-                                try:
-                                    taxis = V.getTime()
-                                    V = V(time=taxis[t % len(taxis)]).flat[0]
-                                except:
-                                    V = V.flat[0]
+            # Use the hardware selector to determine the cell id we clicked on
+            selector = vtk.vtkHardwareSelector()
+            surfaceRenderer = d.backend['surface_renderer']
+            dataset = d.backend['vtk_backend_grid']
+            if (surfaceRenderer and dataset):
+                selector.SetRenderer(surfaceRenderer)
+                selector.SetArea(xy[0], xy[1], xy[0], xy[1])
+                selector.SetFieldAssociation(vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS)
+                # We only want to render the surface for selection
+                renderers = self.renWin.GetRenderers()
+                renderers.InitTraversal()
+                while(True):
+                    renderer = renderers.GetNextItem()
+                    if (renderer is None):
+                        break
+                    renderer.SetDraw(False)
+                surfaceRenderer.SetDraw(True)
+                selection = selector.Select()
+                renderers.InitTraversal()
+                while(True):
+                    renderer = renderers.GetNextItem()
+                    if (renderer is None):
+                        break
+                    renderer.SetDraw(True)
+                surfaceRenderer.SetDraw(False)
+                if (selection.GetNumberOfNodes() > 0):
+                    selectionNode = selection.GetNode(0)
+                    prop = selectionNode.GetProperties().Get(selectionNode.PROP())
+                    if (prop):
+                        cellIds = prop.GetMapper().GetInput().GetCellData().GetGlobalIds()
+                        if (cellIds):
+                            st += "Var: %s\n" % d.array[0].id
+                            # cell attribute
+                            a = selectionNode.GetSelectionData().GetArray(0)
+                            geometryId = a.GetValue(0)
+                            cellId = cellIds.GetValue(geometryId)
+                            attributes = dataset.GetCellData().GetScalars()
+                            if (attributes is None):
+                                attributes = dataset.GetCellData().GetVectors()
+                            elementId = cellId
+
+                            geoTransform = d.backend['vtk_backend_geo']
+                            if (geoTransform):
+                                geoTransform.Inverse()
+                            # Use the world picker to get world coordinates
+                            # we deform the dataset, so we need to fix the
+                            # world picker using xScale, yScale
+                            xScale, yScale = d.backend['surface_scale']
+                            worldPicker = vtk.vtkWorldPointPicker()
+                            worldPicker.Pick(xy[0], xy[1], 0, surfaceRenderer)
+                            worldPosition = list(worldPicker.GetPickPosition())
+                            if (xScale > yScale):
+                                worldPosition[0] /= (xScale/yScale)
                             else:
-                                V = V.flat[0]
-                        try:
-                            st += "Var: %s\nX[%i] = %4.1f\nY[%i] = %4.1f\nValue: %g" % (
-                                d.array[0].id, I, X, J, Y, V)
-                        except:
-                            st += "Var: %s\nX = %4.1f\nY[%i] = %4.1f\nValue: %g" % (
-                                d.array[0].id, X, I, Y, V)
-                    except:
-                        st += "Var: %s\nX=%g\nY=%g\nValue = N/A" % (
-                            d.array[0].id, X, Y)
+                                worldPosition[1] /= (yScale/xScale)
+                            lonLat = worldPosition
+                            if (attributes is None):
+                                # if point dataset, return the value for the closest point
+                                cell = dataset.GetCell(cellId)
+                                closestPoint = [0, 0, 0]
+                                subId = vtk.mutable(0)
+                                pcoords = [0, 0, 0]
+                                dist2 = vtk.mutable(0)
+                                weights = [0] * cell.GetNumberOfPoints()
+                                cell.EvaluatePosition(worldPosition, closestPoint,
+                                                      subId, pcoords, dist2, weights)
+                                indexMax = numpy.argmax(weights)
+                                pointId = cell.GetPointId(indexMax)
+                                attributes = dataset.GetPointData().GetScalars()
+                                if (attributes is None):
+                                    attributes = dataset.GetPointData().GetVectors()
+                                elementId = pointId
+                            if (geoTransform):
+                                geoTransform.InternalTransformPoint(worldPosition, lonLat)
+                                geoTransform.Inverse()
+                            if (float("inf") not in lonLat):
+                                st += "X=%4.1f\nY=%4.1f\n" % (lonLat[0], lonLat[1])
+                            # get the cell value or the closest point value
+                            if (attributes):
+                                if (attributes.GetNumberOfComponents() > 1):
+                                    v = attributes.GetTuple(elementId)
+                                    st += "Value: (%g, %g)" % (v[0], v[1])
+                                else:
+                                    value = attributes.GetValue(elementId)
+                                    st += "Value: %g" % value
+
         if st == "":
             return
         ren = vtk.vtkRenderer()
@@ -859,9 +850,9 @@ class VTKVCSBackend(object):
                     ren = self.createRenderer()
                     self.renWin.AddRenderer(ren)
                     self.setLayer(ren, 1)
-                    self._renderers[(None, None, None)] = ren
+                    self._renderers[(None, None, None)] = (ren, 1, 1)
                 else:
-                    ren = self._renderers[(None, None, None)]
+                    ren, xratio, yratio = self._renderers[(None, None, None)]
                 tt, to = crdate.name.split(":::")
                 tt = vcs.elements["texttable"][tt]
                 to = vcs.elements["textorientation"][to]
@@ -896,9 +887,9 @@ class VTKVCSBackend(object):
                     ren = self.createRenderer()
                     self.renWin.AddRenderer(ren)
                     self.setLayer(ren, 1)
-                    self._renderers[(None, None, None)] = ren
+                    self._renderers[(None, None, None)] = (ren, 1, 1)
                 else:
-                    ren = self._renderers[(None, None, None)]
+                    ren, xratio, yratio = self._renderers[(None, None, None)]
                 tt, to = zname.name.split(":::")
                 tt = vcs.elements["texttable"][tt]
                 to = vcs.elements["textorientation"][to]
diff --git a/Packages/vcs/vcs/vcs2vtk.py b/Packages/vcs/vcs/vcs2vtk.py
index 86cfcfd0a..aa4a228ac 100644
--- a/Packages/vcs/vcs/vcs2vtk.py
+++ b/Packages/vcs/vcs/vcs2vtk.py
@@ -809,6 +809,7 @@ def doWrap(Act, wc, wrap=[0., 360], fastClip=True):
     if wrap is None:
         return Act
     Mapper = Act.GetMapper()
+    Mapper.Update()
     data = Mapper.GetInput()
     # insure that GLOBALIDS are not removed by the append filter
     attributes = data.GetCellData()
diff --git a/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py b/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py
index 1ea81febb..f2a3ea602 100644
--- a/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/boxfillpipeline.py
@@ -130,8 +130,6 @@ class BoxfillPipeline(Pipeline2D):
                 geo=self._vtkGeoTransform,
                 priority=self._template.data.priority,
                 create_renderer=(dataset_renderer is None))
-        self._resultDict['dataset_renderer'] = dataset_renderer
-        self._resultDict['dataset_scale'] = (xScale, yScale)
 
         for act in patternActors:
             if self._vtkGeoTransform is None:
@@ -211,7 +209,6 @@ class BoxfillPipeline(Pipeline2D):
                 vp, self._template.data.priority,
                 vtk_backend_grid=self._vtkDataSet,
                 dataset_bounds=self._vtkDataSetBounds)
-            self._resultDict['continents_renderer'] = continents_renderer
 
     def _plotInternalBoxfill(self):
         """Implements the logic to render a non-custom boxfill."""
diff --git a/Packages/vcs/vcs/vcsvtk/isofillpipeline.py b/Packages/vcs/vcs/vcsvtk/isofillpipeline.py
index af3b037a8..55098f9e5 100644
--- a/Packages/vcs/vcs/vcsvtk/isofillpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/isofillpipeline.py
@@ -158,8 +158,6 @@ class IsofillPipeline(Pipeline2D):
                 geo=self._vtkGeoTransform,
                 priority=self._template.data.priority,
                 create_renderer=(dataset_renderer is None))
-        self._resultDict['dataset_renderer'] = dataset_renderer
-        self._resultDict['dataset_scale'] = (xScale, yScale)
         for act in patternActors:
             self._context().fitToViewport(
                 act, vp,
@@ -226,4 +224,3 @@ class IsofillPipeline(Pipeline2D):
                 vp, self._template.data.priority,
                 vtk_backend_grid=self._vtkDataSet,
                 dataset_bounds=self._vtkDataSetBounds)
-            self._resultDict['continents_renderer'] = continents_renderer
diff --git a/Packages/vcs/vcs/vcsvtk/isolinepipeline.py b/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
index 2d9b66472..1560de7c1 100644
--- a/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
@@ -273,8 +273,6 @@ class IsolinePipeline(Pipeline2D):
                 create_renderer=(dataset_renderer is None))
 
             countLevels += len(l)
-        self._resultDict['dataset_renderer'] = dataset_renderer
-        self._resultDict['dataset_scale'] = (xScale, yScale)
         if len(textprops) > 0:
             self._resultDict["vtk_backend_contours_labels_text_properties"] = \
                 textprops
@@ -332,4 +330,3 @@ class IsolinePipeline(Pipeline2D):
                 vp, self._template.data.priority,
                 vtk_backend_grid=self._vtkDataSet,
                 dataset_bounds=self._vtkDataSetBounds)
-            self._resultDict['continents_renderer'] = continents_renderer
diff --git a/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py b/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
index 7101a4729..64a95c4e3 100644
--- a/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/meshfillpipeline.py
@@ -195,8 +195,6 @@ class MeshfillPipeline(Pipeline2D):
                 geo=self._vtkGeoTransform,
                 priority=self._template.data.priority,
                 create_renderer=(dataset_renderer is None))
-        self._resultDict['dataset_renderer'] = dataset_renderer
-        self._resultDict['dataset_scale'] = (xScale, yScale)
         for act in self._patternActors:
             if self._vtkGeoTransform is None:
                 # If using geofilter on wireframed does not get wrapped not sure
@@ -270,7 +268,6 @@ class MeshfillPipeline(Pipeline2D):
                 vp, self._template.data.priority,
                 vtk_backend_grid=self._vtkDataSet,
                 dataset_bounds=self._vtkDataSetBounds)
-            self._resultDict['continents_renderer'] = continents_renderer
 
     def getPlottingBounds(self):
         """gm.datawc if it is set or dataset_bounds
diff --git a/Packages/vcs/vcs/vcsvtk/pipeline2d.py b/Packages/vcs/vcs/vcsvtk/pipeline2d.py
index baa2f8915..dc12f3f5c 100644
--- a/Packages/vcs/vcs/vcsvtk/pipeline2d.py
+++ b/Packages/vcs/vcs/vcsvtk/pipeline2d.py
@@ -50,6 +50,7 @@ class IPipeline2D(Pipeline):
             applied to points.
         - _needsCellData: True if the plot needs cell scalars, false if
             the plot needs point scalars
+        - _needsVectors: True if the plot needs vectors, false if it needs scalars
         - _scalarRange: The range of _data1 as tuple(float min, float max)
         - _maskedDataMapper: The mapper used to render masked data.
     """
@@ -79,6 +80,7 @@ class IPipeline2D(Pipeline):
         self._dataWrapModulo = None
         self._hasCellData = None
         self._needsCellData = None
+        self._needsVectors = False
         self._scalarRange = None
         self._maskedDataMapper = None
 
@@ -276,6 +278,8 @@ class Pipeline2D(IPipeline2D):
 
         # Preprocess the input scalar data:
         self._updateScalarData()
+        self._min = self._data1.min()
+        self._max = self._data1.max()
         self._scalarRange = vcs.minmax(self._data1)
 
         # Create/update the VTK dataset.
@@ -313,8 +317,6 @@ class Pipeline2D(IPipeline2D):
         """Overrides baseclass implementation."""
         self._data1 = self._context().trimData2D(self._originalData1)
         self._data2 = self._context().trimData2D(self._originalData2)
-        self._min = self._data1.min()
-        self._max = self._data1.max()
 
     def _updateVTKDataSet(self, plotBasedDualGrid):
         """
@@ -327,8 +329,10 @@ class Pipeline2D(IPipeline2D):
         genGridDict = vcs2vtk.genGrid(self._data1, self._data2, self._gm,
                                       deep=False,
                                       grid=self._vtkDataSet,
-                                      geo=self._vtkGeoTransform, dualGrid=dualGrid)
+                                      geo=self._vtkGeoTransform, genVectors=self._needsVectors,
+                                      dualGrid=dualGrid)
         self._data1 = genGridDict["data"]
+        self._data2 = genGridDict["data2"]
         self._updateFromGenGridDict(genGridDict)
 
     def _createPolyDataFilter(self):
@@ -339,6 +343,7 @@ class Pipeline2D(IPipeline2D):
         elif self._hasCellData:
             # use cells but needs points
             c2p = vtk.vtkCellDataToPointData()
+            c2p.PassCellDataOn()
             c2p.SetInputData(self._vtkDataSet)
             self._vtkPolyDataFilter.SetInputConnection(c2p.GetOutputPort())
         else:
@@ -349,6 +354,27 @@ class Pipeline2D(IPipeline2D):
             self._vtkPolyDataFilter.SetInputConnection(p2c.GetOutputPort())
         self._vtkPolyDataFilter.Update()
         self._resultDict["vtk_backend_filter"] = self._vtkPolyDataFilter
+        # create an actor and a renderer for the surface mesh.
+        # this is used for displaying point information using the hardware selection
+        mapper = vtk.vtkPolyDataMapper()
+        mapper.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
+        act = vtk.vtkActor()
+        act.SetMapper(mapper)
+        vp = self._resultDict.get(
+            'ratio_autot_viewport',
+            [self._template.data.x1, self._template.data.x2,
+             self._template.data.y1, self._template.data.y2])
+        plotting_dataset_bounds = self.getPlottingBounds()
+        surface_renderer, xScale, yScale = self._context().fitToViewport(
+            act, vp,
+            wc=plotting_dataset_bounds, geoBounds=self._vtkDataSet.GetBounds(),
+            geo=self._vtkGeoTransform,
+            priority=self._template.data.priority,
+            create_renderer=True)
+        self._resultDict['surface_renderer'] = surface_renderer
+        self._resultDict['surface_scale'] = (xScale, yScale)
+        if (surface_renderer):
+            surface_renderer.SetDraw(False)
 
     def _updateFromGenGridDict(self, genGridDict):
         """Overrides baseclass implementation."""
diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index bc34e3c9e..0badc60b4 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -1,75 +1,47 @@
-from .pipeline import Pipeline
+from .pipeline2d import Pipeline2D
 
 import vcs
 from vcs import vcs2vtk
 import vtk
 
 
-class VectorPipeline(Pipeline):
+class VectorPipeline(Pipeline2D):
 
     """Implementation of the Pipeline interface for VCS vector plots."""
 
     def __init__(self, gm, context_):
         super(VectorPipeline, self).__init__(gm, context_)
+        self._needsCellData = False
+        self._needsVectors = True
 
-    def plot(self, data1, data2, tmpl, grid, transform, **kargs):
+    def _plotInternal(self):
         """Overrides baseclass implementation."""
         # Preserve time and z axis for plotting these inof in rendertemplate
-        geo = None  # to make flake8 happy
         projection = vcs.elements["projection"][self._gm.projection]
-        returned = {}
-        taxis = data1.getTime()
-        if data1.ndim > 2:
-            zaxis = data1.getAxis(-3)
+        taxis = self._originalData1.getTime()
+        if self._originalData1.ndim > 2:
+            zaxis = self._originalData1.getAxis(-3)
         else:
             zaxis = None
 
-        # Ok get3 only the last 2 dims
-        data1 = self._context().trimData2D(data1)
-        data2 = self._context().trimData2D(data2)
-
         scale = 1.0
         lat = None
         lon = None
 
-        latAccessor = data1.getLatitude()
-        lonAccessor = data1.getLongitude()
+        latAccessor = self._data1.getLatitude()
+        lonAccessor = self._data1.getLongitude()
         if latAccessor:
             lat = latAccessor[:]
         if lonAccessor:
             lon = lonAccessor[:]
 
-        plotBasedDualGrid = kargs.get('plot_based_dual_grid', True)
-        if (plotBasedDualGrid):
-            hasCellData = data1.hasCellData()
-            dualGrid = hasCellData
-        else:
-            dualGrid = False
-        gridGenDict = vcs2vtk.genGrid(data1, data2, self._gm, deep=False, grid=grid,
-                                      geo=transform, genVectors=True,
-                                      dualGrid=dualGrid)
-
-        data1 = gridGenDict["data"]
-        data2 = gridGenDict["data2"]
-        geo = gridGenDict["geo"]
-
-        grid = gridGenDict['vtk_backend_grid']
-        xm = gridGenDict['xm']
-        xM = gridGenDict['xM']
-        ym = gridGenDict['ym']
-        yM = gridGenDict['yM']
-        continents = gridGenDict['continents']
-        self._dataWrapModulo = gridGenDict['wrap']
-        geo = gridGenDict['geo']
-        cellData = gridGenDict['cellData']
-
-        if geo is not None:
+        if self._vtkGeoTransform is not None:
             newv = vtk.vtkDoubleArray()
             newv.SetNumberOfComponents(3)
             newv.InsertTupleValue(0, [lon.min(), lat.min(), 0])
             newv.InsertTupleValue(1, [lon.max(), lat.max(), 0])
 
-            vcs2vtk.projectArray(newv, projection, [xm, xM, ym, yM])
+            vcs2vtk.projectArray(newv, projection, self._vtkDataSetBounds)
             dimMin = [0, 0, 0]
             dimMax = [0, 0, 0]
 
@@ -89,22 +61,6 @@ class VectorPipeline(Pipeline):
         else:
             scale = 1.0
 
-        returned["vtk_backend_grid"] = grid
-        returned["vtk_backend_geo"] = geo
-        missingMapper = vcs2vtk.putMaskOnVTKGrid(data1, grid, actorColor=None,
-                                                 cellData=cellData, deep=False)
-
-        # None/False are for color and cellData
-        # (sent to vcs2vtk.putMaskOnVTKGrid)
-        returned["vtk_backend_missing_mapper"] = (missingMapper, None, False)
-
-        # convert to point data
-        if cellData:
-            c2p = vtk.vtkCellDataToPointData()
-            c2p.SetInputData(grid)
-            c2p.Update()
-            grid = c2p.GetOutput()
-
         # Vector attempt
         l = self._gm.line
         if l is None:
@@ -129,7 +85,7 @@ class VectorPipeline(Pipeline):
         arrow.FilledOff()
 
         glyphFilter = vtk.vtkGlyph2D()
-        glyphFilter.SetInputData(grid)
+        glyphFilter.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
         glyphFilter.SetInputArrayToProcess(1, 0, 0, 0, "vector")
         glyphFilter.SetSourceConnection(arrow.GetOutputPort())
         glyphFilter.SetVectorModeToUseVector()
@@ -163,22 +119,20 @@ class VectorPipeline(Pipeline):
 
         plotting_dataset_bounds = vcs2vtk.getPlottingBounds(
             vcs.utils.getworldcoordinates(self._gm,
-                                          data1.getAxis(-1),
-                                          data1.getAxis(-2)),
-            [xm, xM, ym, yM], geo)
+                                          self._data1.getAxis(-1),
+                                          self._data1.getAxis(-2)),
+            self._vtkDataSetBounds, self._vtkGeoTransform)
         x1, x2, y1, y2 = plotting_dataset_bounds
-        if geo is None:
+        if self._vtkGeoTransform is None:
             wc = plotting_dataset_bounds
         else:
             xrange = list(act.GetXRange())
             yrange = list(act.GetYRange())
             wc = [xrange[0], xrange[1], yrange[0], yrange[1]]
 
-        if (transform and kargs.get('ratio', '0') == 'autot'):
-            returned['ratio_autot_viewport'] = self._processRatioAutot(tmpl, grid)
-
-        vp = returned.get('ratio_autot_viewport',
-                          [tmpl.data.x1, tmpl.data.x2, tmpl.data.y1, tmpl.data.y2])
+        vp = self._resultDict.get('ratio_autot_viewport',
+                                  [self._template.data.x1, self._template.data.x2,
+                                   self._template.data.y1, self._template.data.y2])
         # look for previous dataset_bounds different than ours and
         # modify the viewport so that the datasets are alligned
         # Hack to fix the case when the user does not specify gm.datawc_...
@@ -200,31 +154,29 @@ class VectorPipeline(Pipeline):
         dataset_renderer, xScale, yScale = self._context().fitToViewport(
             act, vp,
             wc=wc,
-            priority=tmpl.data.priority,
+            priority=self._template.data.priority,
             create_renderer=True)
-        returned['dataset_renderer'] = dataset_renderer
-        returned['dataset_scale'] = (xScale, yScale)
-        bounds = [min(xm, xM), max(xm, xM), min(ym, yM), max(ym, yM)]
-        kwargs = {'vtk_backend_grid': grid,
-                  'dataset_bounds': bounds,
+        kwargs = {'vtk_backend_grid': self._vtkDataSet,
+                  'dataset_bounds': self._vtkDataSetBounds,
                   'plotting_dataset_bounds': plotting_dataset_bounds}
-        if ('ratio_autot_viewport' in returned):
+        if ('ratio_autot_viewport' in self._resultDict):
             kwargs["ratio_autot_viewport"] = vp
-        returned.update(self._context().renderTemplate(
-            tmpl, data1,
+        self._resultDict.update(self._context().renderTemplate(
+            self._template, self._data1,
             self._gm, taxis, zaxis, **kwargs))
 
         if self._context().canvas._continents is None:
-            continents = False
-        if continents:
+            self._useContinents = False
+        if self._useContinents:
             continents_renderer, xScale, yScale = self._context().plotContinents(
                 plotting_dataset_bounds, projection,
-                self._dataWrapModulo, vp, tmpl.data.priority,
-                vtk_backend_grid=grid,
-                dataset_bounds=bounds)
-            returned["continents_renderer"] = continents_renderer
-        returned["vtk_backend_actors"] = [[act, plotting_dataset_bounds]]
-        returned["vtk_backend_glyphfilters"] = [glyphFilter]
-        returned["vtk_backend_luts"] = [[None, None]]
-
-        return returned
+                self._dataWrapModulo, vp, self._template.data.priority,
+                vtk_backend_grid=self._vtkDataSet,
+                dataset_bounds=self._vtkDataSetBounds)
+        self._resultDict["vtk_backend_actors"] = [[act, plotting_dataset_bounds]]
+        self._resultDict["vtk_backend_glyphfilters"] = [glyphFilter]
+        self._resultDict["vtk_backend_luts"] = [[None, None]]
+
+    def _updateContourLevelsAndColors(self):
+        """Overrides baseclass implementation."""
+        pass
diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index 9e8cf78e3..fd253ac23 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -947,33 +947,22 @@ cdat_add_test(test_vcs_colorpicker_appearance
   ${BASELINE_DIR}/test_vcs_colorpicker_appearance.png
 )
 
-cdat_add_test(test_vcs_click_info
-  "${PYTHON_EXECUTABLE}"
-  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_click_info.py
-  ${BASELINE_DIR}/test_vcs_click_info.png
-  a_boxfill
-)
-
-cdat_add_test(test_vcs_click_info_mollweide_boxfill
-  "${PYTHON_EXECUTABLE}"
-  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_click_info.py
-  ${BASELINE_DIR}/test_vcs_click_info_mollweide_boxfill.png
-  a_mollweide_boxfill
-)
-
-cdat_add_test(test_vcs_click_info_meshfill
-  "${PYTHON_EXECUTABLE}"
-  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_click_info.py
-  ${BASELINE_DIR}/test_vcs_click_info_meshfill.png
-  a_meshfill
-)
 
-cdat_add_test(test_vcs_click_info_robinson_meshfill
-  "${PYTHON_EXECUTABLE}"
-  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_click_info.py
-  ${BASELINE_DIR}/test_vcs_click_info_robinson_meshfill.png
-  a_robinson_meshfill
-)
+foreach(plot a_boxfill a_mollweide_boxfill a_meshfill a_robinson_meshfill
+        a_isofill a_isoline vector_default)
+  string(SUBSTRING ${plot} 0 2 plot_prefix)
+  if (${plot_prefix} STREQUAL "a_")
+    string(SUBSTRING ${plot} 2 -1 plot_name)
+  else ()
+    string(REGEX MATCH "[^_]+" plot_name ${plot})
+  endif ()
+  cdat_add_test(test_vcs_click_info_${plot_name}
+    "${PYTHON_EXECUTABLE}"
+    ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_click_info.py
+    "${BASELINE_DIR}/test_vcs_click_info_${plot_name}.png"
+    ${plot}
+    )
+endforeach()
 
 
 cdat_add_test(test_vcs_mercator_edge
diff --git a/testing/vcs/test_vcs_click_info.py b/testing/vcs/test_vcs_click_info.py
index f37ee651a..8d55e77c6 100644
--- a/testing/vcs/test_vcs_click_info.py
+++ b/testing/vcs/test_vcs_click_info.py
@@ -2,6 +2,9 @@ import os, sys, cdms2, vcs, testing.regression as regression
 
 testConfig = {'a_boxfill': ('clt.nc', 'clt', (200, 200)),
               'a_mollweide_boxfill': ('clt.nc', 'clt', (222, 322)),
+              'a_isofill': ('clt.nc', 'clt', (200, 200)),
+              'a_isoline': ('clt.nc', 'clt', (200, 200)),
+              'vector_default': ('clt.nc', ('u', 'v'), (200, 200)),
               'a_meshfill': ('sampleCurveGrid4.nc', 'sample', (222, 322)),
               'a_robinson_meshfill': ('sampleCurveGrid4.nc', 'sample', (222, 322))}
 
@@ -10,21 +13,32 @@ src = sys.argv[1]
 plot = sys.argv[2]
 x = regression.init(bg=False, geometry=(800, 600))
 
-# data
-f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0])
-s = f(testConfig[plot][1])
-
+vector = False
 # graphics method
 if (plot.find('boxfill') != -1):
     gm = x.getboxfill(plot)
 elif (plot.find('meshfill') != -1):
     gm = x.getmeshfill(plot)
+elif (plot.find('isofill') != -1):
+    gm = x.getisofill(plot)
+elif (plot.find('isoline') != -1):
+    gm = x.getisoline(plot)
+elif (plot.find('vector') != -1):
+    gm = x.getvector(plot[plot.index('_') + 1:])
+    vector = True
 else:
     print "Invalid plot"
     sys.exit(13)
 
-# Has to plot in foreground to simulate a click
-x.plot(s, gm)
+# data
+f = cdms2.open(vcs.sample_data + "/" + testConfig[plot][0])
+if (vector):
+    u = f(testConfig[plot][1][0])
+    v = f(testConfig[plot][1][1])
+    x.plot(u, v, gm)
+else:
+    s = f(testConfig[plot][1])
+    x.plot(s, gm)
 
 # Simulate a click -- VTK Specific
 location = testConfig[plot][2]
-- 
GitLab


From 2dd2b3554fabbd1ec63e8e2c877f05cad4c61ecf Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Thu, 12 May 2016 11:34:31 -0400
Subject: [PATCH 47/68] Reenable autot_axis tests. Keep max Y to 500.

---
 Packages/testing/regression.py            |  3 +-
 testing/vcs/CMakeLists.txt                | 35 ++++++++++++-----------
 testing/vcs/test_vcs_autot_axis_titles.py |  9 ++++--
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py
index 68ded76d9..b9cd2cdeb 100644
--- a/Packages/testing/regression.py
+++ b/Packages/testing/regression.py
@@ -24,7 +24,8 @@ def init(*args, **kwargs):
     vcsinst.setantialiasing(0)
     vcsinst.drawlogooff()
 
-    if ('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs):
+    if ((('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs)) and
+        ('geometry' not in kwargs)):
         vcsinst.setbgoutputdimensions(1200, 1091, units="pixels")
     return vcsinst
 
diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index fd253ac23..c6ccf8517 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -983,23 +983,24 @@ cdat_add_test(test_vcs_large_pattern_hatch
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_large_pattern_hatch.py
   ${BASELINE_DIR}/test_vcs_large_pattern_hatch.png
 )
-# crashes on mac commenting out for release`
-#foreach(x_over_y 0.5 2)
-#  # a_meshfill does not work yet, as meshfills are wrapped which is not known to VCS
-#  foreach(plot a_boxfill a_mollweide_boxfill a_robinson_meshfill a_lambert_isofill a_robinson_isoline)
-#    foreach(mode foreground background)
-#      string(SUBSTRING ${plot} 2 -1 plot_name)
-#      cdat_add_test(test_vcs_autot_axis_titles_${mode}_${plot_name}_${x_over_y}
-#        "${PYTHON_EXECUTABLE}"
-#        ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_autot_axis_titles.py
-#        "${BASELINE_DIR}/test_vcs_autot_axis_titles_${plot_name}_${x_over_y}.png"
-#        ${mode}
-#        ${plot}
-#        ${x_over_y}
-#        )
-#    endforeach()
-#  endforeach()
-#endforeach()
+
+foreach(x_over_y 0.5 2)
+ # a_meshfill does not work yet, as meshfills are wrapped which is not known to VCS
+ foreach(plot a_boxfill a_mollweide_boxfill a_robinson_meshfill a_lambert_isofill a_robinson_isoline)
+   foreach(mode foreground background)
+     string(SUBSTRING ${plot} 2 -1 plot_name)
+     cdat_add_test(test_vcs_autot_axis_titles_${mode}_${plot_name}_${x_over_y}
+       "${PYTHON_EXECUTABLE}"
+       ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_autot_axis_titles.py
+       "${BASELINE_DIR}/test_vcs_autot_axis_titles_${plot_name}_${x_over_y}.png"
+       ${mode}
+       ${plot}
+       ${x_over_y}
+       )
+   endforeach()
+ endforeach()
+endforeach()
+
 cdat_add_test(test_vcs_boxfill_lambert_crash
   "${PYTHON_EXECUTABLE}"
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_boxfill_lambert_crash.py
diff --git a/testing/vcs/test_vcs_autot_axis_titles.py b/testing/vcs/test_vcs_autot_axis_titles.py
index dcc0f00b1..2728cbd6d 100644
--- a/testing/vcs/test_vcs_autot_axis_titles.py
+++ b/testing/vcs/test_vcs_autot_axis_titles.py
@@ -8,11 +8,14 @@ testConfig = {'a_boxfill': ('clt.nc', 'clt'),
               'a_robinson_isoline': ('clt.nc', 'clt')}
 
 # Tests if ratio=autot works correctly for background and foreground plots
+bg = 1
+if (sys.argv[2] == 'foreground'):
+    bg = 0
 plot = sys.argv[3]
 x_over_y = sys.argv[4]
 if (x_over_y == '0.5'):
-    xSize = 400
-    ySize = 800
+    xSize = 250
+    ySize = 500
 else:
     xSize = 800
     ySize = 400
@@ -39,5 +42,5 @@ else:
 x.setantialiasing(0)
 x.drawlogooff()
 x.plot(s, gm, ratio="autot")
-name = "test_autot_axis_titles_" + plot[2:] + "_" + x_over_y + "_" + str(bg) + ".png"
+name = "test_vcs_autot_axis_titles_" + plot[2:] + "_" + x_over_y + "_" + str(bg) + ".png"
 regression.run(x, name, sys.argv[1])
\ No newline at end of file
-- 
GitLab


From f91b6b89d29293266c9de2deb367349bd4b57052 Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Thu, 19 May 2016 14:34:34 -0400
Subject: [PATCH 48/68] BUG #1959: Fix memory override for vtkContourFiler in
 isofillpipeline.

This resulted in vtkStripper to generate double coverage of isocountours which resulted in
messed-up patterns.
Also adjusted plot patterns to easier to discriminate.
---
 Packages/vcs/vcs/vcs2vtk.py                |  8 ++++----
 Packages/vcs/vcs/vcsvtk/isolinepipeline.py |  1 -
 testing/vcs/CMakeLists.txt                 |  7 +++++++
 testing/vcs/test_vcs_line_patterns.py      | 22 ++++++++++++++++++++++
 4 files changed, 33 insertions(+), 5 deletions(-)
 create mode 100755 testing/vcs/test_vcs_line_patterns.py

diff --git a/Packages/vcs/vcs/vcs2vtk.py b/Packages/vcs/vcs/vcs2vtk.py
index aa4a228ac..81142492c 100644
--- a/Packages/vcs/vcs/vcs2vtk.py
+++ b/Packages/vcs/vcs/vcs2vtk.py
@@ -1581,16 +1581,16 @@ def __build_ld__():
 
 def stippleLine(prop, line_type):
     if line_type == 'long-dash':
-        prop.SetLineStipplePattern(int('1111111100000000', 2))
+        prop.SetLineStipplePattern(int('0000111111111111', 2))
         prop.SetLineStippleRepeatFactor(1)
     elif line_type == 'dot':
-        prop.SetLineStipplePattern(int('1010101010101010', 2))
+        prop.SetLineStipplePattern(int('0101010101010101', 2))
         prop.SetLineStippleRepeatFactor(1)
     elif line_type == 'dash':
-        prop.SetLineStipplePattern(int('1111000011110000', 2))
+        prop.SetLineStipplePattern(int('0001111100011111', 2))
         prop.SetLineStippleRepeatFactor(1)
     elif line_type == 'dash-dot':
-        prop.SetLineStipplePattern(int('0011110000110011', 2))
+        prop.SetLineStipplePattern(int('0101111101011111', 2))
         prop.SetLineStippleRepeatFactor(1)
     elif line_type == 'solid':
         prop.SetLineStipplePattern(int('1111111111111111', 2))
diff --git a/Packages/vcs/vcs/vcsvtk/isolinepipeline.py b/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
index 1560de7c1..3406824f0 100644
--- a/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/isolinepipeline.py
@@ -144,7 +144,6 @@ class IsolinePipeline(Pipeline2D):
 
             for n in range(numLevels):
                 cot.SetValue(n, l[n])
-            cot.SetValue(numLevels, l[-1])
             # TODO remove update
             cot.Update()
 
diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index c6ccf8517..fbd89a10f 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -1007,6 +1007,13 @@ cdat_add_test(test_vcs_boxfill_lambert_crash
   "${BASELINE_DIR}/test_vcs_boxfill_lambert_crash.png"
   "${UVCDAT_GIT_TESTDATA_DIR}/data/NCEP_09_climo.nc"
 )
+
+cdat_add_test(test_vcs_line_patterns
+  "${PYTHON_EXECUTABLE}"
+  ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_line_patterns.py
+  "${BASELINE_DIR}/test_vcs_line_patterns.png"
+)
+
 cdat_add_test(test_vcs_init_open_sizing
   "${PYTHON_EXECUTABLE}"
   ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_init_open_sizing.py
diff --git a/testing/vcs/test_vcs_line_patterns.py b/testing/vcs/test_vcs_line_patterns.py
new file mode 100755
index 000000000..7597403fc
--- /dev/null
+++ b/testing/vcs/test_vcs_line_patterns.py
@@ -0,0 +1,22 @@
+import vcs
+import cdms2
+import sys
+import os
+import testing.regression as regression
+
+
+pth = os.path.join(os.path.dirname(__file__), "..")
+sys.path.append(pth)
+
+import checkimage
+
+x = regression.init(bg=1, geometry=(1620, 1080))
+
+f = cdms2.open(vcs.sample_data + "/clt.nc")
+s = f('clt')
+iso = x.createisoline()
+iso.level=[5, 50, 70, 95]
+iso.line = ['dot', 'dash', 'dash-dot', 'long-dash']
+x.plot(s,iso,continents=0)
+name = "test_vcs_line_patterns.png"
+regression.run(x, name)
-- 
GitLab


From 1129e5b4c949a305fb26f355d50252877ced9067 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Mon, 23 May 2016 14:42:12 -0400
Subject: [PATCH 49/68] Compute vector scaling correctly

VTK does clamping and not remapping of input range to desired
range which leads to undesirable visual effects.
---
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py | 39 ++++++++++++++++++-----
 1 file changed, 31 insertions(+), 8 deletions(-)

diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index 0badc60b4..0dee32da4 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -84,25 +84,48 @@ class VectorPipeline(Pipeline2D):
         arrow.SetOutputPointsPrecision(vtk.vtkAlgorithm.DOUBLE_PRECISION)
         arrow.FilledOff()
 
+        polydata = self._vtkPolyDataFilter.GetOutput()
+        vectors = polydata.GetPointData().GetVectors()
+        vectorsRangeX = vectors.GetRange(0)
+        vectorsRangeY = vectors.GetRange(1)
+        vectorsRange = []
+        vectorsRange.insert(0, vectorsRangeY[0] if
+            (vectorsRangeX[0] > vectorsRangeY[0])  else vectorsRangeX[0])
+        vectorsRange.insert(1, vectorsRangeY[1]
+            if (vectorsRangeX[1] > vectorsRangeY[1])  else vectorsRangeX[1])
+
+        scalarArray = vtk.vtkDoubleArray()
+        scalarArray.SetNumberOfComponents(1)
+        scalarArray.SetNumberOfValues(vectors.GetNumberOfTuples())
+
+        oldRange = vectorsRange[1] - vectorsRange[0]
+        newRange = 1.0 - 0.1
+
+        for i in range (0, vectors.GetNumberOfTuples()):
+            norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
+            newValue = (((norm - vectorsRange[0]) * newRange) / oldRange) + 0.1
+            scalarArray.SetValue(i, newValue)
+
+        polydata.GetPointData().SetScalars(scalarArray)
+
         glyphFilter = vtk.vtkGlyph2D()
-        glyphFilter.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
+        # glyphFilter.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
+        glyphFilter.SetInputData(polydata)
         glyphFilter.SetInputArrayToProcess(1, 0, 0, 0, "vector")
         glyphFilter.SetSourceConnection(arrow.GetOutputPort())
         glyphFilter.SetVectorModeToUseVector()
 
         # Rotate arrows to match vector data:
         glyphFilter.OrientOn()
+        glyphFilter.ScalingOn()
 
         # Scale to vector magnitude:
-        glyphFilter.SetScaleModeToScaleByVector()
+        # NOTE: Currently we compute our own scaling factor since VTK does
+        # it by clamping the values > max to max  and values < min to min
+        # and not remap the range.
+        glyphFilter.SetScaleModeToScaleByScalar()
         glyphFilter.SetScaleFactor(scale * 2.0 * self._gm.scale)
 
-        # These are some unfortunately named methods. It does *not* clamp the
-        # scale range to [min, max], but rather remaps the range
-        # [min, max] --> [0, 1].
-        glyphFilter.ClampingOn()
-        glyphFilter.SetRange(0.01, 1.0)
-
         mapper = vtk.vtkPolyDataMapper()
 
         glyphFilter.Update()
-- 
GitLab


From 9589f126db667b2a836e0f8d1fe06e8f94ae3cfd Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Mon, 23 May 2016 15:51:10 -0400
Subject: [PATCH 50/68] Set default to 1 for range

---
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index 0dee32da4..d6b395da2 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -99,6 +99,7 @@ class VectorPipeline(Pipeline2D):
         scalarArray.SetNumberOfValues(vectors.GetNumberOfTuples())
 
         oldRange = vectorsRange[1] - vectorsRange[0]
+        oldRange = 1.0 if oldRange == 0.0 else oldRange
         newRange = 1.0 - 0.1
 
         for i in range (0, vectors.GetNumberOfTuples()):
-- 
GitLab


From 9648e967b9802360adac06c860d4790a93ad0e40 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Mon, 23 May 2016 15:58:18 -0400
Subject: [PATCH 51/68] Using descriptive variable names

---
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index d6b395da2..dc5a9701a 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -100,11 +100,15 @@ class VectorPipeline(Pipeline2D):
 
         oldRange = vectorsRange[1] - vectorsRange[0]
         oldRange = 1.0 if oldRange == 0.0 else oldRange
-        newRange = 1.0 - 0.1
+
+        # New range min, max.
+        newRangeValues = [0.0, 1.0]
+
+        newRange = newRangeValues[1] - newRangeValues[0]
 
         for i in range (0, vectors.GetNumberOfTuples()):
             norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
-            newValue = (((norm - vectorsRange[0]) * newRange) / oldRange) + 0.1
+            newValue = (((norm - vectorsRange[0]) * newRange) / oldRange) + newRangeValues[0]
             scalarArray.SetValue(i, newValue)
 
         polydata.GetPointData().SetScalars(scalarArray)
-- 
GitLab


From 2a4089ea74d32fe96c49a065ee7bc6aab99ecc2a Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Mon, 23 May 2016 17:39:03 -0400
Subject: [PATCH 52/68] Fixed flake8 test

---
 Packages/vcs/vcs/VTKPlots.py              |  4 ++--
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py | 10 +++++-----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index fb34a4c26..814719536 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -546,9 +546,9 @@ class VTKVCSBackend(object):
 
     def geometry(self, *args):
         if len(args) == 0:
-            return self._geometry;
+            return self._geometry
         if len(args) < 2:
-            raise TypeError("Function takes zero or two <width, height> " \
+            raise TypeError("Function takes zero or two <width, height> "
                             "or more than two arguments. Got " + len(*args))
         x = args[0]
         y = args[1]
diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index dc5a9701a..10161a52f 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -89,10 +89,10 @@ class VectorPipeline(Pipeline2D):
         vectorsRangeX = vectors.GetRange(0)
         vectorsRangeY = vectors.GetRange(1)
         vectorsRange = []
-        vectorsRange.insert(0, vectorsRangeY[0] if
-            (vectorsRangeX[0] > vectorsRangeY[0])  else vectorsRangeX[0])
-        vectorsRange.insert(1, vectorsRangeY[1]
-            if (vectorsRangeX[1] > vectorsRangeY[1])  else vectorsRangeX[1])
+        vectorsRange.insert(0, vectorsRangeY[0] if (vectorsRangeX[0] > vectorsRangeY[0])
+                            else vectorsRangeX[0])
+        vectorsRange.insert(1, vectorsRangeY[1] if (vectorsRangeX[1] > vectorsRangeY[1])
+                            else vectorsRangeX[1])
 
         scalarArray = vtk.vtkDoubleArray()
         scalarArray.SetNumberOfComponents(1)
@@ -106,7 +106,7 @@ class VectorPipeline(Pipeline2D):
 
         newRange = newRangeValues[1] - newRangeValues[0]
 
-        for i in range (0, vectors.GetNumberOfTuples()):
+        for i in range(0, vectors.GetNumberOfTuples()):
             norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
             newValue = (((norm - vectorsRange[0]) * newRange) / oldRange) + newRangeValues[0]
             scalarArray.SetValue(i, newValue)
-- 
GitLab


From 7102a1da891048c5d755579e44ec50f1cc2bb44f Mon Sep 17 00:00:00 2001
From: Dan Lipsa <dan.lipsa@kitware.com>
Date: Tue, 24 May 2016 15:12:30 -0400
Subject: [PATCH 53/68] Fix flake8 warnings and a test generated file

---
 Packages/vcs/vcs/VTKPlots.py                  | 4 ++--
 testing/vcs/test_vcs_isoline_width_stipple.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/Packages/vcs/vcs/VTKPlots.py b/Packages/vcs/vcs/VTKPlots.py
index fb34a4c26..814719536 100644
--- a/Packages/vcs/vcs/VTKPlots.py
+++ b/Packages/vcs/vcs/VTKPlots.py
@@ -546,9 +546,9 @@ class VTKVCSBackend(object):
 
     def geometry(self, *args):
         if len(args) == 0:
-            return self._geometry;
+            return self._geometry
         if len(args) < 2:
-            raise TypeError("Function takes zero or two <width, height> " \
+            raise TypeError("Function takes zero or two <width, height> "
                             "or more than two arguments. Got " + len(*args))
         x = args[0]
         y = args[1]
diff --git a/testing/vcs/test_vcs_isoline_width_stipple.py b/testing/vcs/test_vcs_isoline_width_stipple.py
index 5da8f91f4..20a7e5c4f 100644
--- a/testing/vcs/test_vcs_isoline_width_stipple.py
+++ b/testing/vcs/test_vcs_isoline_width_stipple.py
@@ -25,4 +25,4 @@ isoline.linewidths = (1, 2, 3, 4, 1)
 isoline.line = ('dot', 'dash', 'solid', 'dash-dot', 'long-dash', 'dot', 'dash')
 # Next plot the isolines with labels
 canvas.plot(data, isoline, bg=1)
-regression.run(canvas, "test_isoline_width_stipple.png")
+regression.run(canvas, "test_vcs_isoline_width_stipple.png")
-- 
GitLab


From 2513a0c8327c93e4c0c49e6cb3a0b69d3d2c929f Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Tue, 24 May 2016 15:00:40 -0400
Subject: [PATCH 54/68] Added scale options to vector graphic method

---
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py |  87 +++++++++++-------
 Packages/vcs/vcs/vector.py                | 105 ++++++++++++++--------
 2 files changed, 127 insertions(+), 65 deletions(-)

diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index 10161a52f..dd3b7ba04 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -19,6 +19,8 @@ class VectorPipeline(Pipeline2D):
         # Preserve time and z axis for plotting these inof in rendertemplate
         projection = vcs.elements["projection"][self._gm.projection]
         taxis = self._originalData1.getTime()
+        scaleFactor = 1.0
+
         if self._originalData1.ndim > 2:
             zaxis = self._originalData1.getAxis(-3)
         else:
@@ -84,37 +86,20 @@ class VectorPipeline(Pipeline2D):
         arrow.SetOutputPointsPrecision(vtk.vtkAlgorithm.DOUBLE_PRECISION)
         arrow.FilledOff()
 
+
         polydata = self._vtkPolyDataFilter.GetOutput()
         vectors = polydata.GetPointData().GetVectors()
         vectorsRangeX = vectors.GetRange(0)
         vectorsRangeY = vectors.GetRange(1)
-        vectorsRange = []
-        vectorsRange.insert(0, vectorsRangeY[0] if (vectorsRangeX[0] > vectorsRangeY[0])
-                            else vectorsRangeX[0])
-        vectorsRange.insert(1, vectorsRangeY[1] if (vectorsRangeX[1] > vectorsRangeY[1])
-                            else vectorsRangeX[1])
-
-        scalarArray = vtk.vtkDoubleArray()
-        scalarArray.SetNumberOfComponents(1)
-        scalarArray.SetNumberOfValues(vectors.GetNumberOfTuples())
-
-        oldRange = vectorsRange[1] - vectorsRange[0]
-        oldRange = 1.0 if oldRange == 0.0 else oldRange
-
-        # New range min, max.
-        newRangeValues = [0.0, 1.0]
 
-        newRange = newRangeValues[1] - newRangeValues[0]
-
-        for i in range(0, vectors.GetNumberOfTuples()):
-            norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
-            newValue = (((norm - vectorsRange[0]) * newRange) / oldRange) + newRangeValues[0]
-            scalarArray.SetValue(i, newValue)
-
-        polydata.GetPointData().SetScalars(scalarArray)
+        if self._gm.scaletype == 'constant' or\
+           self._gm.scaletype == 'constantNNormalize' or\
+           self._gm.scaletype == 'constantNLinear':
+            scaleFactor = scale * 2.0 * self._gm.scale
+        else:
+            scaleFactor = 1.0
 
         glyphFilter = vtk.vtkGlyph2D()
-        # glyphFilter.SetInputConnection(self._vtkPolyDataFilter.GetOutputPort())
         glyphFilter.SetInputData(polydata)
         glyphFilter.SetInputArrayToProcess(1, 0, 0, 0, "vector")
         glyphFilter.SetSourceConnection(arrow.GetOutputPort())
@@ -124,12 +109,54 @@ class VectorPipeline(Pipeline2D):
         glyphFilter.OrientOn()
         glyphFilter.ScalingOn()
 
-        # Scale to vector magnitude:
-        # NOTE: Currently we compute our own scaling factor since VTK does
-        # it by clamping the values > max to max  and values < min to min
-        # and not remap the range.
-        glyphFilter.SetScaleModeToScaleByScalar()
-        glyphFilter.SetScaleFactor(scale * 2.0 * self._gm.scale)
+        glyphFilter.SetScaleModeToScaleByVector()
+
+        if self._gm.scaletype == 'normalize' or self._gm.scaletype == 'linear' or\
+           self._gm.scaletype == 'constantNNormalize' or self._gm.scaletype == 'constantNLinear':
+
+            # Find the min and max vector magnitudes
+            minNorm = None
+            maxNorm = None
+
+            for i in range(0, vectors.GetNumberOfTuples()):
+                norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
+
+                if (minNorm is None or norm < minNorm):
+                    minNorm = norm
+                if (maxNorm is None or norm > maxNorm):
+                    maxNorm = norm
+
+            if maxNorm == 0:
+                maxNorm = 1.0
+
+            if self._gm.scaletype == 'normalize' or self._gm.scaletype == 'constantNNormalize':
+                scaleFactor /= maxNorm
+
+            if self._gm.scaletype == 'linear' or self._gm.scaletype == 'constantNLinear':
+                scalarArray = vtk.vtkDoubleArray()
+                scalarArray.SetNumberOfComponents(1)
+                scalarArray.SetNumberOfValues(vectors.GetNumberOfTuples())
+
+                oldRange = maxNorm - minNorm
+                oldRange = 1.0 if oldRange == 0.0 else oldRange
+
+                # New range min, max.
+                newRangeValues = self._gm.scalerange
+                newRange = newRangeValues[1] - newRangeValues[0]
+
+                for i in range(0, vectors.GetNumberOfTuples()):
+                    norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
+                    newValue = (((norm - minNorm) * newRange) / oldRange) + newRangeValues[0]
+                    scalarArray.SetValue(i, newValue)
+                    polydata.GetPointData().SetScalars(scalarArray)
+
+                # Scale to vector magnitude:
+                # NOTE: Currently we compute our own scaling factor since VTK does
+                # it by clamping the values > max to max  and values < min to min
+                # and not remap the range.
+                glyphFilter.SetScaleModeToScaleByScalar()
+
+        glyphFilter.SetScaleFactor(scaleFactor)
 
         mapper = vtk.vtkPolyDataMapper()
 
diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index acea94c04..b48d74116 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -131,7 +131,7 @@ def process_src(nm, code):
 class Gv(object):
 
     """
- Class:	Gv				# Vector
+ Class: Gv              # Vector
 
  Description of Gv Class:
     The vector graphics method displays a vector plot of a 2D vector field. Vectors
@@ -145,76 +145,76 @@ class Gv(object):
     entry.
 
  Other Useful Functions:
-         a=vcs.init()			# Constructor
-         a.show('vector')		# Show predefined vector graphics methods
-         a.show('line')			# Show predefined VCS line objects
-         a.setcolormap("AMIP")		# Change the VCS color Map
-         a.vector(s1, s2, v,'default')	# Plot data 's1', and 's2' with vector 'v'
+         a=vcs.init()           # Constructor
+         a.show('vector')       # Show predefined vector graphics methods
+         a.show('line')         # Show predefined VCS line objects
+         a.setcolormap("AMIP")      # Change the VCS color Map
+         a.vector(s1, s2, v,'default')  # Plot data 's1', and 's2' with vector 'v'
                                          and 'default' template
-         a.update()		 	# Updates the VCS Canvas at user's request
-         a.mode=1, or 0 	 	# If 1, then automatic update, else if
+         a.update()         # Updates the VCS Canvas at user's request
+         a.mode=1, or 0         # If 1, then automatic update, else if
                                           0, then use update function to
                                           update the VCS Canvas.
 
  Example of Use:
     a=vcs.init()
     To Create a new instance of vector use:
-     vc=a.createvector('new','quick')	# Copies content of 'quick' to 'new'
-     vc=a.createvector('new') 		# Copies content of 'default' to 'new'
+     vc=a.createvector('new','quick')   # Copies content of 'quick' to 'new'
+     vc=a.createvector('new')       # Copies content of 'default' to 'new'
 
     To Modify an existing vector use:
      vc=a.getvector('AMIP_psl')
 
-    vc.list()  				# Will list all the vector attribute values
-    vc.projection='linear'   		# Can only be 'linear'
+    vc.list()               # Will list all the vector attribute values
+    vc.projection='linear'          # Can only be 'linear'
     lon30={-180:'180W',-150:'150W',0:'Eq'}
     vc.xticlabels1=lon30
     vc.xticlabels2=lon30
-    vc.xticlabels(lon30, lon30)  	# Will set them both
+    vc.xticlabels(lon30, lon30)     # Will set them both
     vc.xmtics1=''
     vc.xmtics2=''
-    vc.xmtics(lon30, lon30)  		# Will set them both
+    vc.xmtics(lon30, lon30)         # Will set them both
     vc.yticlabels1=lat10
     vc.yticlabels2=lat10
-    vc.yticlabels(lat10, lat10)  	# Will set them both
+    vc.yticlabels(lat10, lat10)     # Will set them both
     vc.ymtics1=''
     vc.ymtics2=''
-    vc.ymtics(lat10, lat10)  		# Will set them both
+    vc.ymtics(lat10, lat10)         # Will set them both
     vc.datawc_y1=-90.0
     vc.datawc_y2=90.0
     vc.datawc_x1=-180.0
     vc.datawc_x2=180.0
-    vc.datawc(-90, 90, -180, 180)  	# Will set them all
+    vc.datawc(-90, 90, -180, 180)   # Will set them all
     xaxisconvert='linear'
     yaxisconvert='linear'
-    vc.xyscale('linear', 'area_wt')  	# Will set them both
+    vc.xyscale('linear', 'area_wt')     # Will set them both
 
     Specify the line style:
-     vc.line=0 				# Same as vc.line='solid'
-     vc.line=1 				# Same as vc.line='dash'
-     vc.line=2 				# Same as vc.line='dot'
-     vc.line=3 				# Same as vc.line='dash-dot'
-     vc.line=4 				# Same as vc.line='long-dot'
+     vc.line=0              # Same as vc.line='solid'
+     vc.line=1              # Same as vc.line='dash'
+     vc.line=2              # Same as vc.line='dot'
+     vc.line=3              # Same as vc.line='dash-dot'
+     vc.line=4              # Same as vc.line='long-dot'
 
     Specify the line color of the vectors:
-     vc.linecolor=16   			# Color range: 16 to 230, default line color is black
-     vc.linewidth=1   			# Width range: 1 to 100, default size is 1
+     vc.linecolor=16            # Color range: 16 to 230, default line color is black
+     vc.linewidth=1             # Width range: 1 to 100, default size is 1
 
     Specify the vector scale factor:
-     vc.scale=2.0   			# Can be an integer or float
+     vc.scale=2.0               # Can be an integer or float
 
     Specify the vector alignment:
-     vc.alignment=0			# Same as vc.alignment='head'
-     vc.alignment=1			# Same as vc.alignment='center'
-     vc.alignment=2			# Same as vc.alignment='tail'
+     vc.alignment=0         # Same as vc.alignment='head'
+     vc.alignment=1         # Same as vc.alignment='center'
+     vc.alignment=2         # Same as vc.alignment='tail'
 
     Specify the vector type:
-      vc.type=0   			# Same as vc.type='arrow head'
-      vc.type=1   			# Same as vc.type='wind barbs'
-      vc.type=2   			# Same as vc.type='solid arrow head'
+      vc.type=0             # Same as vc.type='arrow head'
+      vc.type=1             # Same as vc.type='wind barbs'
+      vc.type=2             # Same as vc.type='solid arrow head'
 
     Specify the vector reference:
-      vc.reference=4    		# Can be an integer or float
+      vc.reference=4            # Can be an integer or float
 """
     __slots__ = [
         'name',
@@ -244,6 +244,9 @@ class Gv(object):
         'type',
         'reference',
         'colormap',
+        'scaleoptions',
+        'scaletype',
+        'scalerange',
         '_name',
         '_xaxisconvert',
         '_yaxisconvert',
@@ -270,9 +273,13 @@ class Gv(object):
         '_type',
         '_reference',
         '_colormap',
+        '_scaleoptions',
+        '_scaletype',
+        '_scalerange',
     ]
 
     colormap = VCS_validation_functions.colormap
+    scaleoptions = ('off', 'constant', 'normalize', 'linear', 'constantNNormalize', 'constantNLinear')
 
     def _getname(self):
         return self._name
@@ -528,6 +535,25 @@ class Gv(object):
         self._alignment = value
     alignment = property(_getalignment, _setalignment)
 
+
+    def _getscaletype(self):
+        return self._scaletype
+
+    def _setscaletype(self, value):
+        if value in self.scaleoptions:
+            self._scaletype = value
+        else:
+            raise ValueError('Invalid value '+ value + ' expected ' + self.scaleoptions)
+    scaletype = property(_getscaletype, _setscaletype)
+
+    def _getscalerange(self):
+        return self._scalerange
+
+    def _setscalerange(self, value):
+        self._scalerange = value
+    scalerange = property(_getscalerange, _setscalerange)
+
+
     def __init__(self, Gv_name, Gv_name_src='default'):
                 #                                                         #
                 ###########################################################
@@ -568,6 +594,8 @@ class Gv(object):
             self._datawc_timeunits = "days since 2000"
             self._datawc_calendar = 135441
             self._colormap = None
+            self._scaletype = self.scaleoptions[5]
+            self._scalerange = [0.1, 1.0]
         else:
             if isinstance(Gv_name_src, Gv):
                 Gv_name_src = Gv_name_src.name
@@ -583,7 +611,9 @@ class Gv(object):
                         'datawc_x2', 'xaxisconvert', 'yaxisconvert',
                         'line', 'linecolor', 'linewidth',
                         'datawc_timeunits', 'datawc_calendar', 'colormap',
-                        'scale', 'alignment', 'type', 'reference']:
+                        'scale', 'alignment', 'type', 'reference', 'scaletype',
+                        'scalerange']:
+
                 setattr(self, att, getattr(src, att))
         # Ok now we need to stick in the elements
         vcs.elements["vector"][Gv_name] = self
@@ -660,6 +690,8 @@ class Gv(object):
         print "alignment = ", self.alignment
         print "type = ", self.type
         print "reference = ", self.reference
+        print "scaletype = ", self.scaletype
+        print "scalerange = ", self.scalerange
 
     ##########################################################################
     #                                                                           #
@@ -798,6 +830,9 @@ class Gv(object):
             fp.write("%s.linecolor = %s\n" % (unique_name, self.linecolor))
             fp.write("%s.linewidth = %s\n" % (unique_name, self.linewidth))
             fp.write("%s.scale = %s\n" % (unique_name, self.scale))
+            fp.write("%s.scaletype = %s\n" % (unique_name, self.scaletype))
+            fp.write("%s.scalerange = %s\n" % (unique_name, self.scalerange))
+            fp.write("%s.scaleoptions = %s\n" % (unique_name, self.scaleoptions))
             fp.write("%s.alignment = '%s'\n" % (unique_name, self.alignment))
             fp.write("%s.type = '%s'\n" % (unique_name, self.type))
             fp.write("%s.reference = %s\n\n" % (unique_name, self.reference))
@@ -814,5 +849,5 @@ class Gv(object):
 
 
 ###############################################################################
-#        END OF FILE							      #
+#        END OF FILE                                  #
 ###############################################################################
-- 
GitLab


From e1d77e43c389af4f649e3399a5b346eea5f5845d Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 25 May 2016 08:47:58 -0400
Subject: [PATCH 55/68] Added check for valid range

---
 Packages/vcs/vcs/vector.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index b48d74116..dd06f6b0b 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -550,6 +550,8 @@ class Gv(object):
         return self._scalerange
 
     def _setscalerange(self, value):
+        value = VCS_validation_functions.checkListOfNumbers(self, 'scalerange',
+                    value, minvalue=0.0, minelements=2, maxelements=2)
         self._scalerange = value
     scalerange = property(_getscalerange, _setscalerange)
 
@@ -594,7 +596,7 @@ class Gv(object):
             self._datawc_timeunits = "days since 2000"
             self._datawc_calendar = 135441
             self._colormap = None
-            self._scaletype = self.scaleoptions[5]
+            self._scaletype = self.scaleoptions[4]
             self._scalerange = [0.1, 1.0]
         else:
             if isinstance(Gv_name_src, Gv):
-- 
GitLab


From f00bea8901ba156b9ca388af9fdccadb55898f57 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 25 May 2016 11:18:48 -0400
Subject: [PATCH 56/68] Added test for new scale options

---
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py     |  6 +-
 testing/vcs/CMakeLists.txt                    | 10 ++++
 testing/vcs/test_vcs_vectors_scale_options.py | 59 +++++++++++++++++++
 3 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 testing/vcs/test_vcs_vectors_scale_options.py

diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index dd3b7ba04..b0f1cfd1e 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -118,8 +118,10 @@ class VectorPipeline(Pipeline2D):
             minNorm = None
             maxNorm = None
 
+            noOfComponents = vectors.GetNumberOfComponents()
+
             for i in range(0, vectors.GetNumberOfTuples()):
-                norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
+                norm = vtk.vtkMath.Norm(vectors.GetTuple(i), noOfComponents)
 
                 if (minNorm is None or norm < minNorm):
                     minNorm = norm
@@ -145,7 +147,7 @@ class VectorPipeline(Pipeline2D):
                 newRange = newRangeValues[1] - newRangeValues[0]
 
                 for i in range(0, vectors.GetNumberOfTuples()):
-                    norm = vtk.vtkMath.Norm(vectors.GetTuple(i))
+                    norm = vtk.vtkMath.Norm(vectors.GetTuple(i), noOfComponents)
                     newValue = (((norm - minNorm) * newRange) / oldRange) + newRangeValues[0]
                     scalarArray.SetValue(i, newValue)
                     polydata.GetPointData().SetScalars(scalarArray)
diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index cadb80cc9..e65b3ca43 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -904,6 +904,16 @@ cdat_add_test(test_vcs_settings_color_name_rgba
       ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_vectors_robinson_wrap.py
       "${BASELINE_DIR}/test_vcs_vectors_robinson_wrap.png"
       )
+    cdat_add_test(test_vcs_vectors_scale_options
+      "${PYTHON_EXECUTABLE}"
+      ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_vectors_scale_options.py
+      "${BASELINE_DIR}/test_vcs_vector_scale_options_off.png"
+      "${BASELINE_DIR}/test_vcs_vector_scale_options_constant.png"
+      "${BASELINE_DIR}/test_vcs_vector_scale_options_linear.png"
+      "${BASELINE_DIR}/test_vcs_vector_scale_options_normalize.png"
+      "${BASELINE_DIR}/test_vcs_vector_scale_options_constantNLinear.png"
+      "${BASELINE_DIR}/test_vcs_vector_scale_options_constantNNormalize.png"
+      )
   endif()
 endif()
 
diff --git a/testing/vcs/test_vcs_vectors_scale_options.py b/testing/vcs/test_vcs_vectors_scale_options.py
new file mode 100644
index 000000000..5dff25d3f
--- /dev/null
+++ b/testing/vcs/test_vcs_vectors_scale_options.py
@@ -0,0 +1,59 @@
+import sys, cdms2, vcs, testing.regression as regression
+
+data = cdms2.open(vcs.sample_data+"/clt.nc")
+v = data['v'][...,::10,::10]
+u = data['u'][...,::10,::10]
+
+canvas = regression.init()
+gv = vcs.createvector()
+
+gv.scaletype = 'off'
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_off.png'
+canvas.png(outFilename)
+ret = regression.check_result_image(outFilename, sys.argv[1])
+canvas.clear()
+
+v = data['v'][...,::4,::4]
+u = data['u'][...,::4,::4]
+gv.scaletype = 'constant'
+gv.scale = 0.1
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_constant.png'
+canvas.png(outFilename)
+ret += regression.check_result_image(outFilename, sys.argv[2])
+canvas.clear()
+
+v = data['v']
+u = data['u']
+gv.scale = 1.0
+
+gv.scaletype = 'normalize'
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_normalize.png'
+canvas.png(outFilename)
+ret += regression.check_result_image(outFilename, sys.argv[2])
+canvas.clear()
+
+gv.scaletype = 'linear'
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_linear.png'
+canvas.png(outFilename)
+ret += regression.check_result_image(outFilename, sys.argv[3])
+canvas.clear()
+
+gv.scaletype = 'constantNNormalize'
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_constantNNormalize.png'
+canvas.png(outFilename)
+ret += regression.check_result_image(outFilename, sys.argv[4])
+canvas.clear()
+
+gv.scaletype = 'constantNLinear'
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_constantNLinear.png'
+canvas.png(outFilename)
+ret += regression.check_result_image(outFilename, sys.argv[5])
+canvas.clear()
+
+sys.ecanvasit(ret)
-- 
GitLab


From 9404c34157ededc830a4287d35e6082e55edf6bf Mon Sep 17 00:00:00 2001
From: Bryce Sampson <sampson.bryce@yahoo.com>
Date: Wed, 25 May 2016 13:58:38 -0700
Subject: [PATCH 57/68] Added missing graphics method types to
 creategraphicsmethod

---
 Packages/vcs/vcs/utils.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Packages/vcs/vcs/utils.py b/Packages/vcs/vcs/utils.py
index 6b94f4352..e69466eab 100644
--- a/Packages/vcs/vcs/utils.py
+++ b/Packages/vcs/vcs/utils.py
@@ -1629,7 +1629,7 @@ def getgraphicsmethod(type, name):
     return copy_mthd
 
 
-def creategraphicsmethod(gtype, name):
+def creategraphicsmethod(gtype, gname='default', name=None):
     if gtype in ['isoline', 'Gi']:
         func = vcs.createisoline
     elif gtype in ['isofill', 'Gfi']:
@@ -1652,11 +1652,17 @@ def creategraphicsmethod(gtype, name):
         func = vcs.createvector
     elif gtype in ['taylordiagram', 'Gtd']:
         func = vcs.createtaylordiagram
-    elif isinstance(type, vcsaddons.core.VCSaddon):
-        func = type.creategm
+    elif gtype == '3d_scalar':
+        func = vcs.create3d_scalar
+    elif gtype == '3d_dual_scalar':
+        func = vcs.create3d_dual_scalar
+    elif gtype == '3d_vector':
+        func = vcs.create3d_vector
+    elif isinstance(gtype, vcsaddons.core.VCSaddon):
+        func = gtype.creategm
     else:
         return None
-    copy_mthd = func(source=name)
+    copy_mthd = func(name=name, source=gname)
     return copy_mthd
 
 
-- 
GitLab


From db669a6b5af83c129e3e1307b9cdd920ce9ab8a2 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 25 May 2016 20:55:14 -0400
Subject: [PATCH 58/68] Using vtkDataArray GetMaxNorm for performance

---
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py | 28 +++++++++++++----------
 Packages/vcs/vcs/vector.py                |  3 ++-
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index b0f1cfd1e..896e32a8e 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -115,18 +115,7 @@ class VectorPipeline(Pipeline2D):
            self._gm.scaletype == 'constantNNormalize' or self._gm.scaletype == 'constantNLinear':
 
             # Find the min and max vector magnitudes
-            minNorm = None
-            maxNorm = None
-
-            noOfComponents = vectors.GetNumberOfComponents()
-
-            for i in range(0, vectors.GetNumberOfTuples()):
-                norm = vtk.vtkMath.Norm(vectors.GetTuple(i), noOfComponents)
-
-                if (minNorm is None or norm < minNorm):
-                    minNorm = norm
-                if (maxNorm is None or norm > maxNorm):
-                    maxNorm = norm
+            maxNorm = vectors.GetMaxNorm()
 
             if maxNorm == 0:
                 maxNorm = 1.0
@@ -135,6 +124,21 @@ class VectorPipeline(Pipeline2D):
                 scaleFactor /= maxNorm
 
             if self._gm.scaletype == 'linear' or self._gm.scaletype == 'constantNLinear':
+                minNorm = None
+                maxNorm = None
+
+                noOfComponents = vectors.GetNumberOfComponents()
+                for i in range(0, vectors.GetNumberOfTuples()):
+                    norm = vtk.vtkMath.Norm(vectors.GetTuple(i), noOfComponents)
+
+                    if (minNorm is None or norm < minNorm):
+                        minNorm = norm
+                    if (maxNorm is None or norm > maxNorm):
+                        maxNorm = norm
+
+                if maxNorm == 0:
+                    maxNorm = 1.0
+
                 scalarArray = vtk.vtkDoubleArray()
                 scalarArray.SetNumberOfComponents(1)
                 scalarArray.SetNumberOfValues(vectors.GetNumberOfTuples())
diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index dd06f6b0b..5d65fb4ad 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -543,7 +543,8 @@ class Gv(object):
         if value in self.scaleoptions:
             self._scaletype = value
         else:
-            raise ValueError('Invalid value '+ value + ' expected ' + self.scaleoptions)
+            VCS_validation_functions.checkedRaise(self, value, ValueError,
+                'Invalid value '+ value + '. Valid options are: ' + ','.join(self.scaleoptions))
     scaletype = property(_getscaletype, _setscaletype)
 
     def _getscalerange(self):
-- 
GitLab


From 06bc68d0c4ec89b16463f8c977acd91dfddbf1ac Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 25 May 2016 20:57:42 -0400
Subject: [PATCH 59/68] Fixed typo in the test

---
 testing/vcs/test_vcs_vectors_scale_options.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testing/vcs/test_vcs_vectors_scale_options.py b/testing/vcs/test_vcs_vectors_scale_options.py
index 5dff25d3f..a4574bfdd 100644
--- a/testing/vcs/test_vcs_vectors_scale_options.py
+++ b/testing/vcs/test_vcs_vectors_scale_options.py
@@ -56,4 +56,4 @@ canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[5])
 canvas.clear()
 
-sys.ecanvasit(ret)
+sys.exit(ret)
-- 
GitLab


From bd610acc966443e5d227694f0a553843fa08e636 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 25 May 2016 22:08:59 -0400
Subject: [PATCH 60/68] Added method to check for valid option

---
 Packages/vcs/vcs/VCS_validation_functions.py | 12 ++++++++++++
 Packages/vcs/vcs/vector.py                   |  8 +++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/Packages/vcs/vcs/VCS_validation_functions.py b/Packages/vcs/vcs/VCS_validation_functions.py
index 7595d900e..db848b968 100644
--- a/Packages/vcs/vcs/VCS_validation_functions.py
+++ b/Packages/vcs/vcs/VCS_validation_functions.py
@@ -243,6 +243,18 @@ def checkListOfNumbers(self, name, value, minvalue=None,
     return list(value)
 
 
+def checkValidOption(self, name, value, options):
+    checkName(self, name, value)
+    if value not in options:
+        VCS_validation_functions.checkedRaise(
+            self,
+            value,
+            ValueError,
+            'Invalid value '+ value + '. Valid options are: ' +
+            ','.join(self.scaleoptions))
+    return value
+
+
 def checkFont(self, name, value):
     if (value is None):
         pass
diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index 5d65fb4ad..db681cc78 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -540,11 +540,9 @@ class Gv(object):
         return self._scaletype
 
     def _setscaletype(self, value):
-        if value in self.scaleoptions:
-            self._scaletype = value
-        else:
-            VCS_validation_functions.checkedRaise(self, value, ValueError,
-                'Invalid value '+ value + '. Valid options are: ' + ','.join(self.scaleoptions))
+        value = VCS_validation_functions.checkValidOption(self, 'scaletype',
+                    value, self.scaleoptions)
+        self._scaletype = value
     scaletype = property(_getscaletype, _setscaletype)
 
     def _getscalerange(self):
-- 
GitLab


From b69d09d59a2d07853c5f4f2fe6987610d141b07a Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Wed, 25 May 2016 22:20:47 -0400
Subject: [PATCH 61/68] Fixed using wrong baseline image

---
 testing/vcs/test_vcs_vectors_scale_options.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/testing/vcs/test_vcs_vectors_scale_options.py b/testing/vcs/test_vcs_vectors_scale_options.py
index a4574bfdd..ce48b63c1 100644
--- a/testing/vcs/test_vcs_vectors_scale_options.py
+++ b/testing/vcs/test_vcs_vectors_scale_options.py
@@ -28,13 +28,6 @@ v = data['v']
 u = data['u']
 gv.scale = 1.0
 
-gv.scaletype = 'normalize'
-canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_normalize.png'
-canvas.png(outFilename)
-ret += regression.check_result_image(outFilename, sys.argv[2])
-canvas.clear()
-
 gv.scaletype = 'linear'
 canvas.plot(u, v, gv)
 outFilename = 'test_vcs_vector_scale_options_linear.png'
@@ -42,9 +35,9 @@ canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[3])
 canvas.clear()
 
-gv.scaletype = 'constantNNormalize'
+gv.scaletype = 'normalize'
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_constantNNormalize.png'
+outFilename = 'test_vcs_vector_scale_options_normalize.png'
 canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[4])
 canvas.clear()
@@ -56,4 +49,11 @@ canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[5])
 canvas.clear()
 
+gv.scaletype = 'constantNNormalize'
+canvas.plot(u, v, gv)
+outFilename = 'test_vcs_vector_scale_options_constantNNormalize.png'
+canvas.png(outFilename)
+ret += regression.check_result_image(outFilename, sys.argv[6])
+canvas.clear()
+
 sys.exit(ret)
-- 
GitLab


From c30239c24c6ec90e5b9393c7d869151fe902d4a0 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Fri, 27 May 2016 13:12:11 -0400
Subject: [PATCH 62/68] Fixed flake8

---
 Packages/vcs/vcs/VCS_validation_functions.py |  4 ++--
 Packages/vcs/vcs/vcsvtk/vectorpipeline.py    |  3 ---
 Packages/vcs/vcs/vector.py                   | 16 ++++++++++------
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Packages/vcs/vcs/VCS_validation_functions.py b/Packages/vcs/vcs/VCS_validation_functions.py
index db848b968..33d554f27 100644
--- a/Packages/vcs/vcs/VCS_validation_functions.py
+++ b/Packages/vcs/vcs/VCS_validation_functions.py
@@ -246,11 +246,11 @@ def checkListOfNumbers(self, name, value, minvalue=None,
 def checkValidOption(self, name, value, options):
     checkName(self, name, value)
     if value not in options:
-        VCS_validation_functions.checkedRaise(
+        self.checkedRaise(
             self,
             value,
             ValueError,
-            'Invalid value '+ value + '. Valid options are: ' +
+            'Invalid value ' + value + '. Valid options are: ' +
             ','.join(self.scaleoptions))
     return value
 
diff --git a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
index 896e32a8e..642884bc6 100644
--- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
+++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py
@@ -86,11 +86,8 @@ class VectorPipeline(Pipeline2D):
         arrow.SetOutputPointsPrecision(vtk.vtkAlgorithm.DOUBLE_PRECISION)
         arrow.FilledOff()
 
-
         polydata = self._vtkPolyDataFilter.GetOutput()
         vectors = polydata.GetPointData().GetVectors()
-        vectorsRangeX = vectors.GetRange(0)
-        vectorsRangeY = vectors.GetRange(1)
 
         if self._gm.scaletype == 'constant' or\
            self._gm.scaletype == 'constantNNormalize' or\
diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index db681cc78..9976fae44 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -535,13 +535,14 @@ class Gv(object):
         self._alignment = value
     alignment = property(_getalignment, _setalignment)
 
-
     def _getscaletype(self):
         return self._scaletype
 
     def _setscaletype(self, value):
-        value = VCS_validation_functions.checkValidOption(self, 'scaletype',
-                    value, self.scaleoptions)
+        value = VCS_validation_functions.checkValidOption(self,
+                                                          'scaletype',
+                                                          value,
+                                                          self.scaleoptions)
         self._scaletype = value
     scaletype = property(_getscaletype, _setscaletype)
 
@@ -549,12 +550,15 @@ class Gv(object):
         return self._scalerange
 
     def _setscalerange(self, value):
-        value = VCS_validation_functions.checkListOfNumbers(self, 'scalerange',
-                    value, minvalue=0.0, minelements=2, maxelements=2)
+        value = VCS_validation_functions.checkListOfNumbers(self,
+                                                            'scalerange',
+                                                            value,
+                                                            minvalue=0.0,
+                                                            minelements=2,
+                                                            maxelements=2)
         self._scalerange = value
     scalerange = property(_getscalerange, _setscalerange)
 
-
     def __init__(self, Gv_name, Gv_name_src='default'):
                 #                                                         #
                 ###########################################################
-- 
GitLab


From 9a2d02d9c8b78479ca07411a3fd7baf43d82f96a Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Fri, 27 May 2016 13:32:48 -0400
Subject: [PATCH 63/68] Updated method name for consistency

---
 Packages/vcs/vcs/VCS_validation_functions.py | 2 +-
 Packages/vcs/vcs/vector.py                   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Packages/vcs/vcs/VCS_validation_functions.py b/Packages/vcs/vcs/VCS_validation_functions.py
index 33d554f27..2968d7832 100644
--- a/Packages/vcs/vcs/VCS_validation_functions.py
+++ b/Packages/vcs/vcs/VCS_validation_functions.py
@@ -243,7 +243,7 @@ def checkListOfNumbers(self, name, value, minvalue=None,
     return list(value)
 
 
-def checkValidOption(self, name, value, options):
+def checkInStringList(self, name, value, options):
     checkName(self, name, value)
     if value not in options:
         self.checkedRaise(
diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index 9976fae44..9ed8bfbef 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -539,7 +539,7 @@ class Gv(object):
         return self._scaletype
 
     def _setscaletype(self, value):
-        value = VCS_validation_functions.checkValidOption(self,
+        value = VCS_validation_functions.checkInStringList(self,
                                                           'scaletype',
                                                           value,
                                                           self.scaleoptions)
-- 
GitLab


From a7f5b860ff1408282431b70890044f956396c320 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Sat, 28 May 2016 03:52:42 -0400
Subject: [PATCH 64/68] Made background rendering default for testing

---
 Packages/testing/regression.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Packages/testing/regression.py b/Packages/testing/regression.py
index b9cd2cdeb..25255fdc0 100644
--- a/Packages/testing/regression.py
+++ b/Packages/testing/regression.py
@@ -20,13 +20,15 @@ def init(*args, **kwargs):
     testingDir = os.path.join(os.path.dirname(__file__), "..")
     sys.path.append(testingDir)
 
-    vcsinst = vcs.init(*args, **kwargs)
-    vcsinst.setantialiasing(0)
-    vcsinst.drawlogooff()
-
     if ((('bg' in kwargs and kwargs['bg']) or ('bg' not in kwargs)) and
         ('geometry' not in kwargs)):
+        vcsinst = vcs.init(*args, **dict(kwargs, bg=1))
         vcsinst.setbgoutputdimensions(1200, 1091, units="pixels")
+    else:
+        vcsinst = vcs.init(*args, **dict(kwargs, bg=0))
+
+    vcsinst.setantialiasing(0)
+    vcsinst.drawlogooff()
     return vcsinst
 
 def run(vcsinst, fname, baseline=sys.argv[1], threshold=defaultThreshold):
-- 
GitLab


From b59d84e4807a5efa678338aaa7cf6cbd1454beca Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Sat, 28 May 2016 04:16:31 -0400
Subject: [PATCH 65/68] Using consistent naming scheme

---
 testing/vcs/CMakeLists.txt                    | 12 ++++++------
 testing/vcs/test_vcs_vectors_scale_options.py | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt
index d15355ce4..bee8b9a45 100644
--- a/testing/vcs/CMakeLists.txt
+++ b/testing/vcs/CMakeLists.txt
@@ -907,12 +907,12 @@ cdat_add_test(test_vcs_settings_color_name_rgba
     cdat_add_test(test_vcs_vectors_scale_options
       "${PYTHON_EXECUTABLE}"
       ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_vectors_scale_options.py
-      "${BASELINE_DIR}/test_vcs_vector_scale_options_off.png"
-      "${BASELINE_DIR}/test_vcs_vector_scale_options_constant.png"
-      "${BASELINE_DIR}/test_vcs_vector_scale_options_linear.png"
-      "${BASELINE_DIR}/test_vcs_vector_scale_options_normalize.png"
-      "${BASELINE_DIR}/test_vcs_vector_scale_options_constantNLinear.png"
-      "${BASELINE_DIR}/test_vcs_vector_scale_options_constantNNormalize.png"
+      "${BASELINE_DIR}/test_vcs_vectors_scale_options_off.png"
+      "${BASELINE_DIR}/test_vcs_vectors_scale_options_constant.png"
+      "${BASELINE_DIR}/test_vcs_vectors_scale_options_linear.png"
+      "${BASELINE_DIR}/test_vcs_vectors_scale_options_normalize.png"
+      "${BASELINE_DIR}/test_vcs_vectors_scale_options_constantNLinear.png"
+      "${BASELINE_DIR}/test_vcs_vectors_scale_options_constantNNormalize.png"
       )
   endif()
 endif()
diff --git a/testing/vcs/test_vcs_vectors_scale_options.py b/testing/vcs/test_vcs_vectors_scale_options.py
index ce48b63c1..32898d129 100644
--- a/testing/vcs/test_vcs_vectors_scale_options.py
+++ b/testing/vcs/test_vcs_vectors_scale_options.py
@@ -9,7 +9,7 @@ gv = vcs.createvector()
 
 gv.scaletype = 'off'
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_off.png'
+outFilename = 'test_vcs_vectors_scale_options_off.png'
 canvas.png(outFilename)
 ret = regression.check_result_image(outFilename, sys.argv[1])
 canvas.clear()
@@ -19,7 +19,7 @@ u = data['u'][...,::4,::4]
 gv.scaletype = 'constant'
 gv.scale = 0.1
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_constant.png'
+outFilename = 'test_vcs_vectors_scale_options_constant.png'
 canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[2])
 canvas.clear()
@@ -30,28 +30,28 @@ gv.scale = 1.0
 
 gv.scaletype = 'linear'
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_linear.png'
+outFilename = 'test_vcs_vectors_scale_options_linear.png'
 canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[3])
 canvas.clear()
 
 gv.scaletype = 'normalize'
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_normalize.png'
+outFilename = 'test_vcs_vectors_scale_options_normalize.png'
 canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[4])
 canvas.clear()
 
 gv.scaletype = 'constantNLinear'
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_constantNLinear.png'
+outFilename = 'test_vcs_vectors_scale_options_constantNLinear.png'
 canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[5])
 canvas.clear()
 
 gv.scaletype = 'constantNNormalize'
 canvas.plot(u, v, gv)
-outFilename = 'test_vcs_vector_scale_options_constantNNormalize.png'
+outFilename = 'test_vcs_vectors_scale_options_constantNNormalize.png'
 canvas.png(outFilename)
 ret += regression.check_result_image(outFilename, sys.argv[6])
 canvas.clear()
-- 
GitLab


From c8befa3b19aab92a53ad644a6113f816965b5d98 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Sat, 28 May 2016 04:26:50 -0400
Subject: [PATCH 66/68] Fixed another flake8 issue

---
 Packages/vcs/vcs/vector.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Packages/vcs/vcs/vector.py b/Packages/vcs/vcs/vector.py
index 9ed8bfbef..2c49bfd30 100755
--- a/Packages/vcs/vcs/vector.py
+++ b/Packages/vcs/vcs/vector.py
@@ -540,9 +540,9 @@ class Gv(object):
 
     def _setscaletype(self, value):
         value = VCS_validation_functions.checkInStringList(self,
-                                                          'scaletype',
-                                                          value,
-                                                          self.scaleoptions)
+                                                           'scaletype',
+                                                           value,
+                                                           self.scaleoptions)
         self._scaletype = value
     scaletype = property(_getscaletype, _setscaletype)
 
-- 
GitLab


From e3f7ede95f7fb84f144e6942c9e5dbe0eb1f5a9f Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Sat, 28 May 2016 04:33:32 -0400
Subject: [PATCH 67/68] Using more generic name for testing

---
 testing/vcs/test_vcs_dump_json.json | 24 ++++++++++++------------
 testing/vcs/test_vcs_dump_json.py   | 26 +++++++++++++-------------
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/testing/vcs/test_vcs_dump_json.json b/testing/vcs/test_vcs_dump_json.json
index b79b1319c..fdd28171b 100644
--- a/testing/vcs/test_vcs_dump_json.json
+++ b/testing/vcs/test_vcs_dump_json.json
@@ -1,6 +1,6 @@
 {
  "G1d": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "colormap": null, 
    "datawc_calendar": 135441, 
    "datawc_timeunits": "days since 2000", 
@@ -29,7 +29,7 @@
   }
  }, 
  "Gfb": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "boxfill_type": "linear", 
    "color_1": 16, 
    "color_2": 239, 
@@ -70,7 +70,7 @@
   }
  }, 
  "Gfi": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "colormap": null, 
    "datawc_calendar": 135441, 
    "datawc_timeunits": "days since 2000", 
@@ -110,7 +110,7 @@
   }
  }, 
  "Gfm": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "colormap": null, 
    "datawc_calendar": 135441, 
    "datawc_timeunits": "days since 2000", 
@@ -153,7 +153,7 @@
   }
  }, 
  "Gi": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "angle": [
     35.0
    ], 
@@ -211,7 +211,7 @@
   }
  }, 
  "P": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "box1": {
     "line": "default", 
     "priority": 1, 
@@ -579,7 +579,7 @@
   }
  }, 
  "Proj": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "parameters": [
     1e+20, 
     1e+20, 
@@ -601,7 +601,7 @@
   }
  }, 
  "Tf": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "color": [
     1
    ], 
@@ -632,7 +632,7 @@
   }
  }, 
  "Tl": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "color": [
     1
    ], 
@@ -662,7 +662,7 @@
   }
  }, 
  "Tm": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "color": [
     1
    ], 
@@ -691,7 +691,7 @@
   }
  }, 
  "To": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "angle": 0, 
    "halign": 0, 
    "height": 14, 
@@ -700,7 +700,7 @@
   }
  }, 
  "Tt": {
-  "Charles.Doutriaux": {
+  "vcs_instance": {
    "backgroundcolor": 0, 
    "backgroundopacity": 0, 
    "color": 1, 
diff --git a/testing/vcs/test_vcs_dump_json.py b/testing/vcs/test_vcs_dump_json.py
index aca6215b8..9247b2d38 100644
--- a/testing/vcs/test_vcs_dump_json.py
+++ b/testing/vcs/test_vcs_dump_json.py
@@ -1,33 +1,33 @@
 
 import filecmp
 import vcs,numpy,os,sys
-src=sys.argv[1]
+src = sys.argv[1]
 if os.path.exists("test_vcs_dump_json.json"):
     os.remove("test_vcs_dump_json.json")
 
-b = vcs.createboxfill("Charles.Doutriaux")
+b = vcs.createboxfill("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createisofill("Charles.Doutriaux")
+b = vcs.createisofill("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createisoline("Charles.Doutriaux")
+b = vcs.createisoline("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createmeshfill("Charles.Doutriaux")
+b = vcs.createmeshfill("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.create1d("Charles.Doutriaux")
+b = vcs.create1d("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createfillarea("Charles.Doutriaux")
+b = vcs.createfillarea("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createtext("Charles.Doutriaux")
+b = vcs.createtext("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createline("Charles.Doutriaux")
+b = vcs.createline("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createmarker("Charles.Doutriaux")
+b = vcs.createmarker("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createtemplate("Charles.Doutriaux")
+b = vcs.createtemplate("vcs_instance")
 b.script("test_vcs_dump_json","a")
-b = vcs.createprojection("Charles.Doutriaux")
+b = vcs.createprojection("vcs_instance")
 b.script("test_vcs_dump_json","a")
 
-assert(filecmp.cmp("test_vcs_dump_json.json",src))
+assert(filecmp.cmp("test_vcs_dump_json.json", src))
 
 
-- 
GitLab


From 8c05ac458f0fbc5b325ff8373197e96555ac20a0 Mon Sep 17 00:00:00 2001
From: Aashish Chaudhary <aashish.chaudhary@kitware.com>
Date: Sat, 28 May 2016 04:49:13 -0400
Subject: [PATCH 68/68] Added vector method for testing

---
 testing/vcs/test_vcs_dump_json.json | 42 +++++++++++++++++++++++++++++
 testing/vcs/test_vcs_dump_json.py   |  2 ++
 2 files changed, 44 insertions(+)

diff --git a/testing/vcs/test_vcs_dump_json.json b/testing/vcs/test_vcs_dump_json.json
index fdd28171b..d40844987 100644
--- a/testing/vcs/test_vcs_dump_json.json
+++ b/testing/vcs/test_vcs_dump_json.json
@@ -210,6 +210,48 @@
    "yticlabels2": "*"
   }
  }, 
+ "Gv": {
+  "vcs_instance": {
+   "alignment": "center", 
+   "colormap": null, 
+   "datawc_calendar": 135441, 
+   "datawc_timeunits": "days since 2000", 
+   "datawc_x1": 1e+20, 
+   "datawc_x2": 1e+20, 
+   "datawc_y1": 1e+20, 
+   "datawc_y2": 1e+20, 
+   "line": null, 
+   "linecolor": null, 
+   "linewidth": null, 
+   "projection": "linear", 
+   "reference": 1e+20, 
+   "scale": 1.0, 
+   "scaleoptions": [
+    "off", 
+    "constant", 
+    "normalize", 
+    "linear", 
+    "constantNNormalize", 
+    "constantNLinear"
+   ], 
+   "scalerange": [
+    0.1, 
+    1.0
+   ], 
+   "scaletype": "constantNNormalize", 
+   "type": "arrows", 
+   "xaxisconvert": "linear", 
+   "xmtics1": "", 
+   "xmtics2": "", 
+   "xticlabels1": "*", 
+   "xticlabels2": "*", 
+   "yaxisconvert": "linear", 
+   "ymtics1": "", 
+   "ymtics2": "", 
+   "yticlabels1": "*", 
+   "yticlabels2": "*"
+  }
+ }, 
  "P": {
   "vcs_instance": {
    "box1": {
diff --git a/testing/vcs/test_vcs_dump_json.py b/testing/vcs/test_vcs_dump_json.py
index 9247b2d38..421606c4d 100644
--- a/testing/vcs/test_vcs_dump_json.py
+++ b/testing/vcs/test_vcs_dump_json.py
@@ -17,6 +17,8 @@ b = vcs.create1d("vcs_instance")
 b.script("test_vcs_dump_json","a")
 b = vcs.createfillarea("vcs_instance")
 b.script("test_vcs_dump_json","a")
+b = vcs.createvector("vcs_instance")
+b.script("test_vcs_dump_json","a")
 b = vcs.createtext("vcs_instance")
 b.script("test_vcs_dump_json","a")
 b = vcs.createline("vcs_instance")
-- 
GitLab