From 1129e5b4c949a305fb26f355d50252877ced9067 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Mon, 23 May 2016 14:42:12 -0400 Subject: [PATCH 01/18] 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 0badc60b48..0dee32da45 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -84,25 +84,48 @@ def _plotInternal(self): 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() From 9589f126db667b2a836e0f8d1fe06e8f94ae3cfd Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Mon, 23 May 2016 15:51:10 -0400 Subject: [PATCH 02/18] 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 0dee32da45..d6b395da2d 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -99,6 +99,7 @@ def _plotInternal(self): 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()): From 9648e967b9802360adac06c860d4790a93ad0e40 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Mon, 23 May 2016 15:58:18 -0400 Subject: [PATCH 03/18] 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 d6b395da2d..dc5a9701a7 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -100,11 +100,15 @@ def _plotInternal(self): 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) From 2a4089ea74d32fe96c49a065ee7bc6aab99ecc2a Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Mon, 23 May 2016 17:39:03 -0400 Subject: [PATCH 04/18] 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 fb34a4c260..814719536b 100644 --- a/Packages/vcs/vcs/VTKPlots.py +++ b/Packages/vcs/vcs/VTKPlots.py @@ -546,9 +546,9 @@ def isopened(self): 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 " \ + raise TypeError("Function takes zero or two " "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 dc5a9701a7..10161a52f4 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -89,10 +89,10 @@ def _plotInternal(self): 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 @@ def _plotInternal(self): 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) From 2513a0c8327c93e4c0c49e6cb3a0b69d3d2c929f Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Tue, 24 May 2016 15:00:40 -0400 Subject: [PATCH 05/18] 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 10161a52f4..dd3b7ba04a 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -19,6 +19,8 @@ def _plotInternal(self): # 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 @@ def _plotInternal(self): 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 @@ def _plotInternal(self): 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 acea94c047..b48d741160 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 @@ def _setalignment(self, value): 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 @@ def __init__(self, Gv_name, Gv_name_src='default'): 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 @@ def __init__(self, Gv_name, Gv_name_src='default'): '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 @@ def list(self): print "alignment = ", self.alignment print "type = ", self.type print "reference = ", self.reference + print "scaletype = ", self.scaletype + print "scalerange = ", self.scalerange ########################################################################## # # @@ -798,6 +830,9 @@ def script(self, script_filename=None, mode=None): 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 @@ def script(self, script_filename=None, mode=None): ############################################################################### -# END OF FILE # +# END OF FILE # ############################################################################### From e1d77e43c389af4f649e3399a5b346eea5f5845d Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 25 May 2016 08:47:58 -0400 Subject: [PATCH 06/18] 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 b48d741160..dd06f6b0bf 100755 --- a/Packages/vcs/vcs/vector.py +++ b/Packages/vcs/vcs/vector.py @@ -550,6 +550,8 @@ def _getscalerange(self): 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 @@ def __init__(self, Gv_name, Gv_name_src='default'): 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): From f00bea8901ba156b9ca388af9fdccadb55898f57 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 25 May 2016 11:18:48 -0400 Subject: [PATCH 07/18] 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 dd3b7ba04a..b0f1cfd1e6 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -118,8 +118,10 @@ def _plotInternal(self): 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 @@ def _plotInternal(self): 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 cadb80cc9b..e65b3ca436 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 0000000000..5dff25d3ff --- /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) From db669a6b5af83c129e3e1307b9cdd920ce9ab8a2 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 25 May 2016 20:55:14 -0400 Subject: [PATCH 08/18] 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 b0f1cfd1e6..896e32a8ec 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -115,18 +115,7 @@ def _plotInternal(self): 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 @@ def _plotInternal(self): 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 dd06f6b0bf..5d65fb4ad6 100755 --- a/Packages/vcs/vcs/vector.py +++ b/Packages/vcs/vcs/vector.py @@ -543,7 +543,8 @@ def _setscaletype(self, value): 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): From 06bc68d0c4ec89b16463f8c977acd91dfddbf1ac Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 25 May 2016 20:57:42 -0400 Subject: [PATCH 09/18] 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 5dff25d3ff..a4574bfdd7 100644 --- a/testing/vcs/test_vcs_vectors_scale_options.py +++ b/testing/vcs/test_vcs_vectors_scale_options.py @@ -56,4 +56,4 @@ ret += regression.check_result_image(outFilename, sys.argv[5]) canvas.clear() -sys.ecanvasit(ret) +sys.exit(ret) From bd610acc966443e5d227694f0a553843fa08e636 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 25 May 2016 22:08:59 -0400 Subject: [PATCH 10/18] 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 7595d900e3..db848b968b 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 5d65fb4ad6..db681cc781 100755 --- a/Packages/vcs/vcs/vector.py +++ b/Packages/vcs/vcs/vector.py @@ -540,11 +540,9 @@ def _getscaletype(self): 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): From b69d09d59a2d07853c5f4f2fe6987610d141b07a Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Wed, 25 May 2016 22:20:47 -0400 Subject: [PATCH 11/18] 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 a4574bfdd7..ce48b63c18 100644 --- a/testing/vcs/test_vcs_vectors_scale_options.py +++ b/testing/vcs/test_vcs_vectors_scale_options.py @@ -28,13 +28,6 @@ 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 @@ 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 @@ 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) From c30239c24c6ec90e5b9393c7d869151fe902d4a0 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Fri, 27 May 2016 13:12:11 -0400 Subject: [PATCH 12/18] 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 db848b968b..33d554f27b 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 896e32a8ec..642884bc6c 100644 --- a/Packages/vcs/vcs/vcsvtk/vectorpipeline.py +++ b/Packages/vcs/vcs/vcsvtk/vectorpipeline.py @@ -86,11 +86,8 @@ def _plotInternal(self): 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 db681cc781..9976fae44a 100755 --- a/Packages/vcs/vcs/vector.py +++ b/Packages/vcs/vcs/vector.py @@ -535,13 +535,14 @@ def _setalignment(self, value): 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 @@ def _getscalerange(self): 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'): # # ########################################################### From 9a2d02d9c8b78479ca07411a3fd7baf43d82f96a Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Fri, 27 May 2016 13:32:48 -0400 Subject: [PATCH 13/18] 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 33d554f27b..2968d7832f 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 9976fae44a..9ed8bfbefb 100755 --- a/Packages/vcs/vcs/vector.py +++ b/Packages/vcs/vcs/vector.py @@ -539,7 +539,7 @@ def _getscaletype(self): return self._scaletype def _setscaletype(self, value): - value = VCS_validation_functions.checkValidOption(self, + value = VCS_validation_functions.checkInStringList(self, 'scaletype', value, self.scaleoptions) From a7f5b860ff1408282431b70890044f956396c320 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Sat, 28 May 2016 03:52:42 -0400 Subject: [PATCH 14/18] 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 b9cd2cdeb3..25255fdc0d 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): From b59d84e4807a5efa678338aaa7cf6cbd1454beca Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Sat, 28 May 2016 04:16:31 -0400 Subject: [PATCH 15/18] 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 d15355ce46..bee8b9a45f 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 ce48b63c18..32898d129f 100644 --- a/testing/vcs/test_vcs_vectors_scale_options.py +++ b/testing/vcs/test_vcs_vectors_scale_options.py @@ -9,7 +9,7 @@ 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 @@ 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.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() From c8befa3b19aab92a53ad644a6113f816965b5d98 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Sat, 28 May 2016 04:26:50 -0400 Subject: [PATCH 16/18] 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 9ed8bfbefb..2c49bfd30d 100755 --- a/Packages/vcs/vcs/vector.py +++ b/Packages/vcs/vcs/vector.py @@ -540,9 +540,9 @@ def _getscaletype(self): 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) From e3f7ede95f7fb84f144e6942c9e5dbe0eb1f5a9f Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Sat, 28 May 2016 04:33:32 -0400 Subject: [PATCH 17/18] 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 b79b1319c3..fdd28171b3 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 aca6215b89..9247b2d385 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)) From 8c05ac458f0fbc5b325ff8373197e96555ac20a0 Mon Sep 17 00:00:00 2001 From: Aashish Chaudhary Date: Sat, 28 May 2016 04:49:13 -0400 Subject: [PATCH 18/18] 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 fdd28171b3..d408449871 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 9247b2d385..421606c4d8 100644 --- a/testing/vcs/test_vcs_dump_json.py +++ b/testing/vcs/test_vcs_dump_json.py @@ -17,6 +17,8 @@ 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")