diff --git a/Packages/vcs/Lib/projection.py b/Packages/vcs/Lib/projection.py index 275bd51f3a..a8476a9892 100644 --- a/Packages/vcs/Lib/projection.py +++ b/Packages/vcs/Lib/projection.py @@ -21,6 +21,9 @@ round_projections = ['polar (non gctp)', 'stereographic', 'orthographic', "ortho", ] +no_over_proj4_parameter_projections = round_projections+["aeqd", "lambert conformal c"] +elliptical_projections = ["robinson", "mollweide"] + def process_src(nm, code): try: diff --git a/Packages/vcs/Lib/template.py b/Packages/vcs/Lib/template.py index 62105fbfe4..2928f4ff4a 100644 --- a/Packages/vcs/Lib/template.py +++ b/Packages/vcs/Lib/template.py @@ -37,6 +37,7 @@ import inspect import cdutil from projection import round_projections +from projection import elliptical_projections # Following for class properties @@ -1140,6 +1141,8 @@ def drawTicks(self, slab, gm, x, axis, number, ys.append([obj.y1, obj.y2]) txs.append((l - wc[0]) / dx + vp[0]) tys.append(objlabl.y) + elif vcs.elements["projection"][gm.projection].type in elliptical_projections: + pass else: xs.append([l, l]) end = wc[ diff --git a/Packages/vcs/Lib/vcs2vtk.py b/Packages/vcs/Lib/vcs2vtk.py index 15dfcda6cb..62e6e9bc15 100644 --- a/Packages/vcs/Lib/vcs2vtk.py +++ b/Packages/vcs/Lib/vcs2vtk.py @@ -9,7 +9,7 @@ import cdms2 import warnings import cdtime -from projection import round_projections +from projection import round_projections, no_over_proj4_parameter_projections from vcsvtk import fillareautils f = open(os.path.join(vcs.prefix, "share", "vcs", "wmo_symbols.json")) @@ -555,6 +555,43 @@ def prepContinents(fnm): return poly +def apply_proj_parameters(pd, projection, xm, xM, ym, yM): + pname = projDict.get(projection._type, projection.type) + projName = pname + pd.SetName(projName) + if projection.type == "polar (non gctp)": + if ym < yM: + pd.SetOptionalParameter("lat_0", "-90.") + pd.SetCentralMeridian(xm) + else: + pd.SetOptionalParameter("lat_0", "90.") + pd.SetCentralMeridian(xm + 180.) + else: + if projection.type not in no_over_proj4_parameter_projections: + pd.SetOptionalParameter("over", "true") + else: + pd.SetOptionalParameter("over", "false") + setProjectionParameters(pd, projection) + if (hasattr(projection, 'centralmeridian') and + numpy.allclose(projection.centralmeridian, 1e+20)): + pd.SetCentralMeridian(float(xm + xM) / 2.0) + if (hasattr(projection, 'centerlongitude') and + numpy.allclose(projection.centerlongitude, 1e+20)): + pd.SetOptionalParameter("lon_0", str(float(xm + xM) / 2.0)) + if (hasattr(projection, 'originlatitude') and + numpy.allclose(projection.originlatitude, 1e+20)): + pd.SetOptionalParameter("lat_0", str(float(ym + yM) / 2.0)) + if (hasattr(projection, 'centerlatitude') and + numpy.allclose(projection.centerlatitude, 1e+20)): + pd.SetOptionalParameter("lat_0", str(float(ym + yM) / 2.0)) + if (hasattr(projection, 'standardparallel1') and + numpy.allclose(projection.standardparallel1, 1.e20)): + pd.SetOptionalParameter('lat_1', str(min(ym, yM))) + if (hasattr(projection, 'standardparallel2') and + numpy.allclose(projection.standardparallel2, 1.e20)): + pd.SetOptionalParameter('lat_2', str(max(ym, yM))) + + def projectArray(w, projection, wc, geo=None): xm, xM, ym, yM = wc if isinstance(projection, (str, unicode)): @@ -567,27 +604,8 @@ def projectArray(w, projection, wc, geo=None): ps = vtk.vtkGeoProjection() pd = vtk.vtkGeoProjection() - pname = projDict.get(projection._type, projection.type) - projName = pname - pd.SetName(projName) - if projection.type == 'aeqd': - # this is a temporary branch to keep the same - # baselines - setProjectionParameters(pd, projection) - else: - pd.SetOptionalParameter("over", "true") - if projection.type == "polar (non gctp)": - if ym < yM: - pd.SetOptionalParameter("lat_0", "-90.") - pd.SetCentralMeridian(xm) - else: - pd.SetOptionalParameter("lat_0", "90.") - pd.SetCentralMeridian(xm + 180.) - else: - setProjectionParameters(pd, projection) - if ((not hasattr(projection, 'centralmeridian') or - numpy.allclose(projection.centralmeridian, 1e+20))): - pd.SetCentralMeridian(float(xm + xM) / 2.0) + apply_proj_parameters(pd, projection, xm, xM, ym, yM) + geo.SetSourceProjection(ps) geo.SetDestinationProjection(pd) @@ -610,27 +628,8 @@ def project(pts, projection, wc, geo=None): ps = vtk.vtkGeoProjection() pd = vtk.vtkGeoProjection() - pname = projDict.get(projection._type, projection.type) - projName = pname - pd.SetName(projName) - if projection.type == 'aeqd': - # this is a temporary branch to keep the same - # baselines - setProjectionParameters(pd, projection) - else: - pd.SetOptionalParameter("over", "true") - if projection.type == "polar (non gctp)": - if ym < yM: - pd.SetOptionalParameter("lat_0", "-90.") - pd.SetCentralMeridian(xm) - else: - pd.SetOptionalParameter("lat_0", "90.") - pd.SetCentralMeridian(xm + 180.) - else: - setProjectionParameters(pd, projection) - if (not hasattr(projection, 'centralmeridian') or - numpy.allclose(projection.centralmeridian, 1e+20)): - pd.SetCentralMeridian(float(xm + xM) / 2.0) + apply_proj_parameters(pd, projection, xm, xM, ym, yM) + geo.SetSourceProjection(ps) geo.SetDestinationProjection(pd) geopts = vtk.vtkPoints() @@ -964,7 +963,7 @@ def setClipPlanes(mapper, xmin, xmax, ymin, ymax): # def doClip1(data,value,normal,axis=0): # return data -# # We have the actor, do clipping +# We have the actor, do clipping # clpf = vtk.vtkPlane() # if axis == 0: # clpf.SetOrigin(value,0,0) diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index c79cc944e7..e26b339e78 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -744,7 +744,7 @@ cdat_add_test(test_vcs_set_colors_name_rgba_isofill ENDFOREACH(gm) FOREACH(gm isofill meshfill boxfill) - FOREACH(proj polar robinson mercator mollweide lambert) + FOREACH(proj robinson) cdat_add_test(vcs_test_animate_projected_${gm}_${proj} "${PYTHON_EXECUTABLE}" "${cdat_SOURCE_DIR}/testing/vcs/test_vcs_gms_animate_projected_plots.py" @@ -764,10 +764,18 @@ cdat_add_test(test_vcs_set_colors_name_rgba_isofill ) ENDFOREACH(flip) + if (NOT APPLE) + cdat_add_test(vcs_test_lambert + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_vcs_lambert.py + "${BASELINE_DIR}/test_vcs_lambert.png" + ) + endif() + cdat_add_test(vcs_test_boxfill_lev1_lev2_ta_missing - "${PYTHON_EXECUTABLE}" - ${cdat_SOURCE_DIR}/testing/vcs/test_boxfill_lev1_lev2_ta_missing.py - "${BASELINE_DIR}/test_boxfill_lev1_lev2_ta_missing.png" + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/vcs/test_boxfill_lev1_lev2_ta_missing.py + "${BASELINE_DIR}/test_boxfill_lev1_lev2_ta_missing.png" ) cdat_add_test(vcs_test_close diff --git a/testing/vcs/editors/test_vcs_editor_marker_delete.py b/testing/vcs/editors/test_vcs_editor_marker_delete.py index 814d69e5bc..64f384adff 100644 --- a/testing/vcs/editors/test_vcs_editor_marker_delete.py +++ b/testing/vcs/editors/test_vcs_editor_marker_delete.py @@ -1,12 +1,7 @@ import vcs import sys -x = vcs.init() - -# Needs to set the size of window so it is consistent accross -# test platforms -x.open() -x.geometry(800, 606) +x = vcs.init(geometry=(800,600)) m = x.createmarker() m.x = .1, diff --git a/testing/vcs/test_vcs_basic_gms.py b/testing/vcs/test_vcs_basic_gms.py index 8bafde23b3..daa144d9dd 100644 --- a/testing/vcs/test_vcs_basic_gms.py +++ b/testing/vcs/test_vcs_basic_gms.py @@ -143,7 +143,7 @@ print "src:",src if args.show: raw_input("Press Enter") -ret = checkimage.check_result_image(fnm+'.png',src,checkimage.defaultThreshold, cleanup=not args.keep) +ret = checkimage.check_result_image(fnm+'.png',src,20., cleanup=not args.keep) if args.show: raw_input("Press Enter") sys.exit(ret) diff --git a/testing/vcs/test_vcs_lambert.py b/testing/vcs/test_vcs_lambert.py new file mode 100644 index 0000000000..17a50209f8 --- /dev/null +++ b/testing/vcs/test_vcs_lambert.py @@ -0,0 +1,27 @@ +import vcs,cdms2 +import os,sys +f = cdms2.open(os.path.join(vcs.sample_data, "clt.nc")) +s = f("clt") +x = vcs.init() +x.setantialiasing(0) +x.drawlogooff() +x.setbgoutputdimensions(1200,1090,units="pixels") +iso = x.createisofill() +p=x.createprojection() +p.type="lambert" + +iso.projection = p +x.plot(s(latitude=(20, 60),longitude=(-140,-20)), iso, bg=True) + +# Load the image testing module: +testingDir = os.path.join(os.path.dirname(__file__), "..") +sys.path.append(testingDir) +import checkimage + +# Create the test image and compare: +baseline = sys.argv[1] +testFile = "test_vcs_lambert.png" +x.png(testFile) +ret = checkimage.check_result_image(testFile, baseline, + checkimage.defaultThreshold) +sys.exit(ret) diff --git a/testing/vcs/test_vcs_large_pattern_hatch.py b/testing/vcs/test_vcs_large_pattern_hatch.py index 210c4206fa..3bcf0827da 100644 --- a/testing/vcs/test_vcs_large_pattern_hatch.py +++ b/testing/vcs/test_vcs_large_pattern_hatch.py @@ -10,7 +10,7 @@ canvas = vcs.init() canvas.setantialiasing(0) -canvas.setbgoutputdimensions(792, 611, units="pixels") +canvas.setbgoutputdimensions(1200,1090, units="pixels") canvas.drawlogooff() fillarea = vcs.createfillarea() @@ -20,7 +20,7 @@ fillarea.index = [1, 5, 5] fillarea.color = [50, 50, 50] -canvas.plot(fillarea, bg=1) +canvas.plot(fillarea, bg=True) testImage = os.path.abspath("test_vcs_large_pattern_hatch.png") canvas.png(testImage) diff --git a/testing/vcs/test_vcs_patterns.py b/testing/vcs/test_vcs_patterns.py index f2378c3a19..fed4f41a83 100644 --- a/testing/vcs/test_vcs_patterns.py +++ b/testing/vcs/test_vcs_patterns.py @@ -13,7 +13,7 @@ x = vcs.init() x.setantialiasing(0) x.drawlogooff() -x.setbgoutputdimensions(1200, 1091, units="pixels") +x.setbgoutputdimensions(1200, 1090, units="pixels") iso = vcs.createisofill("isoleg") iso.levels = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] iso.fillareastyle = "pattern"