Skip to content

Commit eeff4dc

Browse files
committed
Merge pull request #880 from UV-CDAT/851-preserve-labels
851 preserve labels
2 parents a2143cc + 7d53ab3 commit eeff4dc

3 files changed

Lines changed: 27 additions & 5 deletions

File tree

Packages/vcs/Lib/VTKPlots.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ def plot2D(self,data1,data2,tmpl,gm):
825825
## ok it's an extension arrow
826826
L=[mn-1.,levs[0][1]]
827827
else:
828-
L = levs[i]
828+
L = list(levs[i])
829829
I = [indices[i],]
830830
else:
831831
if l[0] == L[-1] and I[-1]==indices[i]:
@@ -858,8 +858,9 @@ def plot2D(self,data1,data2,tmpl,gm):
858858
cot.ClippingOn()
859859
cot.SetInputData(sFilter.GetOutput())
860860
cot.SetNumberOfContours(len(l))
861+
cot.SetClipTolerance(0.)
861862
for j,v in enumerate(l):
862-
cot.SetValue(j,v)
863+
cot.SetValue(j,v)
863864
#cot.SetScalarModeToIndex()
864865
cot.Update()
865866
mapper.SetInputConnection(cot.GetOutputPort())
@@ -1027,12 +1028,12 @@ def plot2D(self,data1,data2,tmpl,gm):
10271028
if gm.ext_1 in ["y",1,True] and not numpy.allclose(levs[0],-1.e20):
10281029
if isinstance(levs,numpy.ndarray):
10291030
levs=levs.tolist()
1030-
if not (isinstance(levs[0],list) and numpy.allclose(levs[0][0],-1.e20)):
1031+
if not (isinstance(levs[0],list) and numpy.less_equal(levs[0][0],-1.e20)):
10311032
levs.insert(0,-1.e20)
10321033
if gm.ext_2 in ["y",1,True] and not numpy.allclose(levs[-1],1.e20):
10331034
if isinstance(levs,numpy.ndarray):
10341035
levs=levs.tolist()
1035-
if not (isinstance(levs[-1],list) and numpy.allclose(levs[-1][-1],1.e20)):
1036+
if not (isinstance(levs[-1],list) and numpy.greater_equal(levs[-1][-1],1.e20)):
10361037
levs.append(1.e20)
10371038

10381039
self.renderColorBar(tmpl,levs,cols,legend,cmap)

testing/vcs/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,5 +390,13 @@ add_test(vcs_test_taylor_2_quads
390390
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_close.py
391391
"${BASELINE_DIR}/test_vcs_close.png"
392392
)
393+
394+
add_test(vcs_test_basic_isofill_bigvalues
395+
"${PYTHON_EXECUTABLE}"
396+
"${cdat_SOURCE_DIR}/testing/vcs/test_vcs_basic_gms.py"
397+
--gm_type=isofill
398+
--bigvalues
399+
"--source=${BASELINE_DIR}/test_vcs_basic_isofill_bigvalues.png"
400+
)
393401
endif()
394402

testing/vcs/test_vcs_basic_gms.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
p = argparse.ArgumentParser(description="Basic gm testing code for vcs")
55
p.add_argument("--source", dest="src", help="source image file")
66
p.add_argument("--gm_type", dest="gm", help="gm to test")
7-
p.add_argument("--mask", dest="mask", action="store_true",help="mask out part of data")
87
p.add_argument("--show", dest="show", action="store_true",help="show plots on screen (no bg)")
98
p.add_argument("--projection-type", dest="projtype", default="default", help="use a specific projection type")
109
p.add_argument("--lat1", dest="lat1", default=0, type=float, help="First latitude")
@@ -16,6 +15,10 @@
1615
p.add_argument("--zero", dest="zero", action="store_true", help="Set the data to zero everywhere")
1716
p.add_argument("--keep", dest="keep", action="store_true",help="Save image, even if baseline matches.")
1817

18+
dataMods = p.add_mutually_exclusive_group()
19+
dataMods.add_argument("--mask", dest="mask", action="store_true",help="mask out part of data")
20+
dataMods.add_argument("--bigvalues", dest="bigvalues", action="store_true",help="replace some of the data with 1e40")
21+
1922
args = p.parse_args(sys.argv[1:])
2023

2124
gm_type= args.gm
@@ -87,19 +90,27 @@
8790
gm.mesh=True
8891
if args.mask:
8992
s=MV2.masked_less(s,1150.)
93+
elif args.bigvalues:
94+
s[s < 1150] = 1e40
9095
if args.zero:
9196
s-=s
9297
else:
9398
s=f("clt",**xtra)
9499
if args.mask:
95100
s=MV2.masked_greater(s,78.)
101+
elif args.bigvalues:
102+
s[s > 78] = 1e40
96103
if gm_type in ["1d","yxvsx","xyvsy","xvsy","scatter"]:
97104
s = s(latitude=(20,20,"cob"),longitude=(112,112,"cob"),squeeze=1)
98105
s2=MV2.sin(s)
99106
if args.zero:
100107
s2-=s2
101108
if args.zero:
102109
s-=s
110+
111+
if args.bigvalues:
112+
gm.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1.e36]
113+
103114
if gm_type=="vector":
104115
x.plot(u,v,gm,bg=bg)
105116
elif gm_type in ["scatter","xvsy"]:
@@ -109,6 +120,8 @@
109120
fnm = "test_vcs_basic_%s" % gm_type.lower()
110121
if args.mask:
111122
fnm+="_masked"
123+
elif args.bigvalues:
124+
fnm+="_bigvalues"
112125
if args.projtype!="default":
113126
fnm+="_%s_proj" % args.projtype
114127
if args.zero:

0 commit comments

Comments
 (0)