Skip to content

Commit

Permalink
Improved computation of scaling that works across various projections
Browse files Browse the repository at this point in the history
  • Loading branch information
aashish24 committed Oct 14, 2015
1 parent f28ff5d commit cb57da0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Packages/vcs/Lib/vcsvtk/vectorpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,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 +65,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 +129,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 Down

0 comments on commit cb57da0

Please sign in to comment.