Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed doWrap method for vectors #1602

Merged
merged 6 commits into from
Oct 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions Packages/vcs/Lib/vcsvtk/vectorpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from vcs import vcs2vtk
import vtk

import math


class VectorPipeline(Pipeline):

Expand Down Expand Up @@ -41,9 +39,6 @@ def plot(self, data1, data2, tmpl, grid, transform):
if lonAccesrsor:
lon = lonAccesrsor[:]

if None not in (projection, lat, lon):
scale = (lat.max() - lat.min()) * (lon.max() - lon.min())

gridGenDict = vcs2vtk.genGridOnPoints(data1, self._gm, deep=False, grid=grid,
geo=transform, data2=data2)

Expand All @@ -68,9 +63,20 @@ def plot(self, data1, data2, tmpl, grid, transform):
gridGenDict['ym'], gridGenDict['yM']])
dimMin = [0, 0, 0]
dimMax = [0, 0, 0]

newv.GetTupleValue(0, dimMin)
newv.GetTupleValue(1, dimMax)
scale = (dimMax[1] - dimMin[1]) * (dimMax[0] - dimMin[0])/scale

maxDimX = max(dimMin[0], dimMax[0])
maxDimY = max(dimMin[1], dimMax[1])

if lat.max() != 0.0:
scale = abs((maxDimY / lat.max()))

if lon.max() != 0.0:
temp = abs((maxDimX / lon.max()))
if scale < temp:
scale = temp
else:
scale = 1.0

Expand Down Expand Up @@ -121,7 +127,7 @@ def plot(self, data1, data2, tmpl, grid, transform):

# Scale to vector magnitude:
glyphFilter.SetScaleModeToScaleByVector()
glyphFilter.SetScaleFactor(math.sqrt(scale) * 2.0 * self._gm.scale)
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
Expand All @@ -147,10 +153,11 @@ def plot(self, data1, data2, tmpl, grid, transform):
if geo is None:
wc = [x1, x2, y1, y2]
else:
wc = None
xrange = list(act.GetXRange())
yrange = list(act.GetYRange())
wc = [xrange[0], xrange[1], yrange[0], yrange[1]]

# TODO: doWrap is broken for vectors
# act = vcs2vtk.doWrap(act, [x1, x2, y1, y2], self._dataWrapModulo)
act = vcs2vtk.doWrap(act, wc, self._dataWrapModulo)

self._context().fitToViewport(act, [tmpl.data.x1, tmpl.data.x2,
tmpl.data.y1, tmpl.data.y2],
Expand Down
5 changes: 5 additions & 0 deletions testing/vcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,11 @@ cdat_add_test(vcs_test_taylor_2_quads
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_vectors_robinson.py
"${BASELINE_DIR}/test_vcs_vectors_robinson.png"
)
cdat_add_test(vcs_test_vectors_robinson_wrap
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_vectors_robinson_wrap.py
"${BASELINE_DIR}/test_vcs_vectors_robinson_wrap.png"
)
endif()
endif()

Expand Down
3 changes: 1 addition & 2 deletions testing/vcs/test_vcs_vectors_robinson.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
sys.path.append(pth)
import checkimage

x = vcs.init()
x = vcs.init()
x.setantialiasing(0)
x.drawlogooff()
Expand All @@ -18,7 +17,7 @@
V.projection = p
x.plot(u,v,V, bg=1)

fnm= "test_vcs_vectors_robinson.png"
fnm = "test_vcs_vectors_robinson.png"
x.png(fnm)
ret = checkimage.check_result_image(fnm, src, checkimage.defaultThreshold)
sys.exit(ret)
26 changes: 26 additions & 0 deletions testing/vcs/test_vcs_vectors_robinson_wrap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import vcs, cdms2, 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")
f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
lon1 = -180
u = f("clt")
v = f("clt")
u = u(longitude=(lon1,lon1+360.))
v = v(longitude=(lon1,lon1+360.))
V = x.createvector()
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)