Skip to content

Commit b460c61

Browse files
committed
BUG #1985: orthographic projection plot is empty
This is because proj4 sets points that are not visisble to infinity. We set those points to 0 and hide them.
1 parent 9d06e08 commit b460c61

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

Packages/vcs/vcs/vcs2vtk.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import numpy
55
import json
66
import os
7+
import math
78
import meshfill
89
from vtk.util import numpy_support as VN
910
import cdms2
@@ -444,6 +445,20 @@ def genGrid(data1, data2, gm, deep=True, grid=None, geo=None, genVectors=False,
444445
data1.getAxis(-2))
445446
geo, geopts = project(pts, projection, getWrappedBounds(
446447
wc, [xm, xM, ym, yM], wrap))
448+
# proj4 returns inf for points that are not visible. Set those to 0
449+
# and hide them.
450+
ghost = vg.AllocatePointGhostArray()
451+
for i in range(vg.GetNumberOfPoints()):
452+
point = geopts.GetPoint(i)
453+
if (math.isinf(point[0]) or math.isinf(point[1])):
454+
newPoint = list(point)
455+
if (math.isinf(point[0])):
456+
newPoint[0] = 0
457+
if (math.isinf(point[1])):
458+
newPoint[1] = 0
459+
geopts.SetPoint(i, newPoint)
460+
ghost.SetValue(i, vtk.vtkDataSetAttributes.HIDDENPOINT)
461+
447462
# Sets the vertics into the grid
448463
vg.SetPoints(geopts)
449464
else:

testing/vcs/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ cdat_add_test(test_vcs_bad_png_path
1111
"${PYTHON_EXECUTABLE}"
1212
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_bad_png_path.py
1313
)
14-
cdat_add_test(test_vcs_boxfill_polar
15-
"${PYTHON_EXECUTABLE}"
16-
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_boxfill_polar.py
17-
"${BASELINE_DIR}/test_vcs_boxfill_polar.png"
18-
)
14+
15+
foreach(projection polar mollweide lambert orthographic mercator polyconic robinson)
16+
cdat_add_test(test_vcs_boxfill_${projection}
17+
"${PYTHON_EXECUTABLE}"
18+
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_boxfill_projection.py
19+
"${BASELINE_DIR}/test_vcs_boxfill_${projection}.png"
20+
${projection}
21+
)
22+
endforeach()
23+
1924
cdat_add_test(test_vcs_create_get
2025
"${PYTHON_EXECUTABLE}"
2126
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_create_get.py
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import os, sys, cdms2, vcs, testing.regression as regression
22

3+
baselineName = sys.argv[1]
4+
projection = sys.argv[2]
5+
36

47
f = cdms2.open(vcs.sample_data + "/clt.nc")
58
a = f("clt")
69

710
x = regression.init()
8-
p = x.getprojection("polar")
11+
p = x.getprojection(projection)
912
b = x.createboxfill()
1013
b.projection = p
1114
x.plot(a(latitude=(90,-90)), b, bg=1)
1215

13-
fileName = os.path.basename(__file__)
16+
fileName = os.path.basename(baselineName)
1417
fileName = os.path.splitext(fileName)[0]
1518
fileName += '.png'
16-
regression.run(x, fileName)
19+
20+
regression.run(x, fileName)

0 commit comments

Comments
 (0)