Skip to content

Commit

Permalink
Merge branch 'master' into issue_2031_seasons_broke
Browse files Browse the repository at this point in the history
  • Loading branch information
doutriaux1 authored Jun 22, 2016
2 parents 8e7d4fb + b6308cc commit db293fa
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMake/cdat_modules_extra/install_cdat_from_conda.bash.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

@CONDA@ create -y -n @CONDA_ENVIRONMENT_NAME@ -c @CONDA_CHANNEL_UVCDAT@ hdf5 libnetcdf lapack clapack ossuuid libcf esmf jasper g2clib yasm x264 ffmpeg cmor proj4>=4.9.2 vtk==uvcdat libcdms cdat_info flake8 requests numpy==1.9.2 matplotlib --show-channel-urls --copy
@CONDA@ create -y -n @CONDA_ENVIRONMENT_NAME@ -c @CONDA_CHANNEL_UVCDAT@ hdf5 libnetcdf lapack clapack ossuuid libcf esmf jasper g2clib yasm x264 ffmpeg cmor proj4>=4.9.2 vtk libcdms cdat_info flake8 requests numpy==1.9.2 matplotlib --show-channel-urls --copy

source @ACTIVATE@ @CONDA_ENVIRONMENT_NAME@
for pkg in testing cdtime regrid2 cdms2 esg DV3D vcs vcsaddons cdutil unidata xmgrace genutil Thermo WK distarray; do
Expand Down
35 changes: 20 additions & 15 deletions Packages/vcs/vcs/vcs2vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ def setArray(grid, array, arrayName, isCellData, isScalars):


def putMaskOnVTKGrid(data, grid, actorColor=None, cellData=True, deep=True):
# Ok now looking
msk = data.mask
mapper = None
if msk is not numpy.ma.nomask and not numpy.allclose(msk, False):
if actorColor is not None:
flatIMask = msk.astype(numpy.int).flat
flatIMask = msk.astype(numpy.double).flat
if grid.IsA("vtkStructuredGrid"):
grid2 = vtk.vtkStructuredGrid()
vtkmask = numpy_to_vtk_wrapper(flatIMask, deep=deep)
vtkmask = numpy_to_vtk_wrapper(flatIMask, deep=deep, array_type=vtk.VTK_DOUBLE)
attributes2 = grid2.GetCellData() if cellData else grid2.GetPointData()
else:
grid2 = vtk.vtkUnstructuredGrid()
Expand All @@ -114,26 +113,32 @@ def putMaskOnVTKGrid(data, grid, actorColor=None, cellData=True, deep=True):
attributes = grid.GetPointData()
if (attributes.GetPedigreeIds()):
attributes2.SetPedigreeIds(attributes.GetPedigreeIds())
vtkmask = vtk.vtkIntArray()
pedigreeId = attributes2.GetPedigreeIds()
vtkmask = vtk.vtkDoubleArray()
vtkmask.SetNumberOfTuples(attributes2.GetPedigreeIds().GetNumberOfTuples())
for i in range(0, vtkmask.GetNumberOfTuples()):
vtkmask.SetValue(i, flatIMask[pedigreeId.GetValue(i)])
else:
# the unstructured grid is not wrapped
vtkmask = numpy_to_vtk_wrapper(flatIMask, deep=deep)
vtkmask = numpy_to_vtk_wrapper(flatIMask, deep=deep, array_type=vtk.VTK_DOUBLE)
vtkmask.SetName("scalar")
attributes2.RemoveArray(vtk.vtkDataSetAttributes.GhostArrayName())
attributes2.SetScalars(vtkmask)
grid2.CopyStructure(grid)
setArray(grid2, flatIMask, "scalar", isCellData=cellData,
isScalars=True)
geoFilter = vtk.vtkDataSetSurfaceFilter()
lut = vtk.vtkLookupTable()
r, g, b, a = actorColor
lut.SetNumberOfTableValues(2)
geoFilter.SetInputData(grid2)
if not cellData:
lut.SetTableValue(0, r / 100., g / 100., b / 100., a / 100.)
lut.SetTableValue(1, r / 100., g / 100., b / 100., a / 100.)
pointToCell = vtk.vtkPointDataToCellData()
pointToCell.SetInputConnection(geoFilter.GetOutputPort())
geoFilter = pointToCell
lut.SetNumberOfTableValues(256)
lut.SetTableValue(0, 1., 1., 1., 1.)
for i in range(1, 256):
lut.SetTableValue(i, r / 100., g / 100., b / 100., a / 100.)
else:
lut.SetNumberOfTableValues(2)
lut.SetTableValue(0, r / 100., g / 100., b / 100., 0.)
lut.SetTableValue(1, r / 100., g / 100., b / 100., 1.)
geoFilter.Update()
Expand Down Expand Up @@ -642,9 +647,9 @@ def projectArray(w, projection, wc, geo=None):

for i in range(0, w.GetNumberOfTuples()):
tuple = [0, 0, 0]
w.GetTupleValue(i, tuple)
w.GetTypedTuple(i, tuple)
geo.TransformPoint(tuple, tuple)
w.SetTupleValue(i, tuple)
w.SetTypedTuple(i, tuple)


# Geo projection
Expand Down Expand Up @@ -1291,9 +1296,9 @@ def prepFillarea(renWin, farea, cmap=None):
if opacity is not None:
color[-1] = opacity
color = [int(C / 100. * 255) for C in color]
colors.SetTupleValue(cellId, color)
colors.SetTypedTuple(cellId, color)
else:
color_arr.SetTupleValue(cellId, [255, 255, 255, 0])
color_arr.SetTypedTuple(cellId, [255, 255, 255, 0])

if st != "solid":
# Patterns/hatches support
Expand Down Expand Up @@ -1701,7 +1706,7 @@ def prepLine(renWin, line, cmap=None):
pts.InsertNextPoint(tmpx, tmpy, 0.)
n2 += 1
for j in range(n2):
colors.InsertNextTupleValue(vtk_color)
colors.InsertNextTypedTuple(vtk_color)
l = vtk.vtkLine()
l.GetPointIds().SetId(0, j + point_offset)
l.GetPointIds().SetId(1, j + point_offset + 1)
Expand Down
8 changes: 7 additions & 1 deletion Packages/vcs/vcs/vcsvtk/isofillpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ def _plotInternal(self):
lut.SetTableValue(j, 1., 1., 1., 0.)
luts.append([lut, [0, len(l) - 1, True]])
mapper.SetLookupTable(lut)
mapper.SetScalarRange(0, len(l) - 1)
minRange = 0
maxRange = len(l) - 1
if (i == 0 and self._scalarRange[0] < l[0]):
# band 0 is from self._scalarRange[0] to l[0]
# we don't show band 0
minRange += 1
mapper.SetScalarRange(minRange, maxRange)
mapper.SetScalarModeToUseCellData()
mappers.append(mapper)

Expand Down
8 changes: 4 additions & 4 deletions Packages/vcs/vcs/vcsvtk/vectorpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ def _plotInternal(self):
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])
newv.InsertTypedTuple(0, [lon.min(), lat.min(), 0])
newv.InsertTypedTuple(1, [lon.max(), lat.max(), 0])

vcs2vtk.projectArray(newv, projection, self._vtkDataSetBounds)
dimMin = [0, 0, 0]
dimMax = [0, 0, 0]

newv.GetTupleValue(0, dimMin)
newv.GetTupleValue(1, dimMax)
newv.GetTypedTuple(0, dimMin)
newv.GetTypedTuple(1, dimMax)

maxDimX = max(dimMin[0], dimMax[0])
maxDimY = max(dimMin[1], dimMax[1])
Expand Down
11 changes: 11 additions & 0 deletions testing/vcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,17 @@ cdat_add_test(test_vcs_settings_color_name_rgba
--bigvalues
"--source=${BASELINE_DIR}/test_vcs_basic_isofill_bigvalues.png"
)

foreach(level 0 1 2)
cdat_add_test(test_vcs_isofill_level${level}
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_isofill_levels.py
"${BASELINE_DIR}/test_vcs_isofill_level${level}.png"
"${UVCDAT_GIT_TESTDATA_DIR}/data/HadSST1870to99.nc"
${level}
)
endforeach()

cdat_add_test(test_vcs_issue_960_labels
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_issue_960_labels.py
Expand Down
19 changes: 19 additions & 0 deletions testing/vcs/test_vcs_isofill_levels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import cdms2
import os
import sys
import testing.regression as regression
import vcs

data = sys.argv[2]
level = sys.argv[3]
levels = {'0': range(-5,36,5),
'1': [-1000, -15, 35],
'2': [-300, -15, 0, 15, 25]}

x=regression.init(bg=1)
f=cdms2.open(data)
s=f("sst")
iso=x.createisofill()
iso.levels=levels[level]
x.plot(s,iso)
regression.run(x, "test_vcs_isofill_level%s.png"%level)

0 comments on commit db293fa

Please sign in to comment.