From 22418d85c0f7bc468273712b9c643205a4163e61 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Wed, 30 Jan 2019 15:40:37 -0800 Subject: [PATCH] Vcs templates (#384) * fix #380 * no pribt debug * renamed Share to share * trying to use dan mac build and do linkage * correct job name * downgrade conda * Shre is now share * ok animation zvalue is not correct need to add this tomorrow * baselines, and beg of flake8 * flake8 passes again * all tests pass on my mac py3 * correct prefix * correct the typo * on my mac no need to do the ln if mesalib * try to get the mesalib version and only run mac py3 * seems to not trigger... * ok... still no trigger, removing all comemnts * ok putting all jobs back in... * trying to use 1/26 mesalib with symlinking * correct sign for version * correct symlinking? * fine tuning doc strings * new flake8 on linux picked these up * missed one new flake8 failure --- .circleci/config.yml | 18 ++- run_tests.py | 2 +- setup.py | 38 +++--- {Share => share}/cdat.png | Bin {Share => share}/cvi_tip_lib.js | 0 {Share => share}/data_continent_coarse | 0 {Share => share}/data_continent_fine | 0 {Share => share}/data_continent_other7 | 0 {Share => share}/data_continent_political | 0 {Share => share}/data_continent_river | 0 {Share => share}/data_continent_states | 0 {Share => share}/fill_icon.png | Bin {Share => share}/fonts | 0 {Share => share}/initial.attributes | 0 {Share => share}/line_icon.png | Bin {Share => share}/mapper.js | 0 {Share => share}/marker_icon.png | Bin {Share => share}/modal.js | 0 {Share => share}/sample_files.txt | 0 {Share => share}/test_data_files.txt | 0 {Share => share}/text_icon.png | Bin {Share => share}/tooltip.css | 0 {Share => share}/vcs | 0 {Share => share}/wmo_symbols.json | 0 .../share/template_test_associated_dump.json | 18 +-- vcs/Canvas.py | 14 +-- vcs/Pformat.py | 3 + vcs/Ptext.py | 8 +- vcs/VCS_validation_functions.py | 4 +- vcs/VTKPlots.py | 2 + vcs/colormap.py | 18 +-- vcs/displayplot.py | 16 +-- vcs/fillarea.py | 16 +-- vcs/isofill.py | 16 +-- vcs/isoline.py | 16 +-- vcs/line.py | 16 +-- vcs/meshfill.py | 12 +- vcs/streamline.py | 18 +-- vcs/template.py | 117 ++++++++++-------- vcs/texttable.py | 18 +-- vcs/unified1D.py | 18 +-- vcs/utils.py | 2 +- vcs/vcsvtk/boxfillpipeline.py | 7 +- vcs/vcsvtk/isofillpipeline.py | 7 +- vcs/vcsvtk/isolinepipeline.py | 7 +- vcs/vcsvtk/meshfillpipeline.py | 7 +- vcs/vcsvtk/pipeline.py | 10 ++ vcs/vcsvtk/streamlinepipeline.py | 6 +- vcs/vcsvtk/vectorpipeline.py | 8 +- vcs/vector.py | 18 +-- vcs/xmldocs.py | 10 +- 51 files changed, 243 insertions(+), 227 deletions(-) rename {Share => share}/cdat.png (100%) rename {Share => share}/cvi_tip_lib.js (100%) rename {Share => share}/data_continent_coarse (100%) rename {Share => share}/data_continent_fine (100%) rename {Share => share}/data_continent_other7 (100%) rename {Share => share}/data_continent_political (100%) rename {Share => share}/data_continent_river (100%) rename {Share => share}/data_continent_states (100%) rename {Share => share}/fill_icon.png (100%) rename {Share => share}/fonts (100%) rename {Share => share}/initial.attributes (100%) rename {Share => share}/line_icon.png (100%) rename {Share => share}/mapper.js (100%) rename {Share => share}/marker_icon.png (100%) rename {Share => share}/modal.js (100%) rename {Share => share}/sample_files.txt (100%) rename {Share => share}/test_data_files.txt (100%) rename {Share => share}/text_icon.png (100%) rename {Share => share}/tooltip.css (100%) rename {Share => share}/vcs (100%) rename {Share => share}/wmo_symbols.json (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9a0120d30..4d1f34019 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,16 +22,17 @@ aliases: name: create_conda_env environment: CHANNELS: "-c cdat/label/nightly -c conda-forge -c cdat" - PKGS: "cdms2 cdat_info udunits2 testsrunner mesalib matplotlib image-compare genutil dv3d cdutil cdtime nbformat 'vtk-cdat>8.1' 'proj4<5' 'numpy>1.14' ghostscript" + PKGS: "cdms2 cdat_info udunits2 testsrunner mesalib matplotlib image-compare genutil dv3d cdutil cdtime nbformat 'vtk-cdat<8.2.0.rc2.289.8.0.2019.01.28.16' 'proj4<5' 'numpy>1.14' ghostscript" command: | export PATH=$WORKDIR/miniconda/bin:$PATH conda config --set always_yes yes --set changeps1 no conda update -y -q conda + conda install -n base "conda<4.6" conda config --set anaconda_upload no if [[ $PY_VER = "py2" ]]; then - conda create -q -n $PY_VER $CHANNELS $PKGS $TEMP_PKGS "python<3" + conda create -q -n $PY_VER $CUSTOM_CHANNELS $CHANNELS $PKGS $TEMP_PKGS "python<3" else - conda create -q -n $PY_VER $CHANNELS $PKGS $TEMP_PKGS "python>3" nbsphinx easydev $COVERAGE_PKGS + conda create -q -n $PY_VER $CUSTOM_CHANNELS $CHANNELS $PKGS $TEMP_PKGS "python>3" nbsphinx easydev $COVERAGE_PKGS fi - &setup_vcs @@ -70,6 +71,14 @@ aliases: fi exit $RESULT + - &templink + name: templink + command: | + export PATH=$WORKDIR/miniconda/bin:$PATH + source activate $PY_VER + rm ${WORKDIR}/miniconda/envs/$PY_VER/bin/python + ln -s $(pwd)/$WORKDIR/miniconda/envs/$PY_VER/bin/vtkpython $(pwd)/$WORKDIR/miniconda/envs/$PY_VER/bin/python + - &conda_upload name: conda_upload environment: @@ -120,6 +129,7 @@ jobs: OS: "osx-64" PY_VER: "py2" TEMP_PKGS: "'ffmpeg>4' 'libpng>1.6.34'" + CUSTOM_CHANNELS: "-c danlipsa" steps: - checkout - run: *setup_miniconda @@ -142,11 +152,13 @@ jobs: OS: "osx-64" PY_VER: "py3" TEMP_PKGS: "'ffmpeg>4' 'libpng>1.6.34'" + CUSTOM_CHANNELS: "-c danlipsa" steps: - checkout - run: *setup_miniconda - run: *get_testdata - run: *create_conda_env + - run: *templink - run: *setup_vcs - run: *run_vcs_tests - store_artifacts: diff --git a/run_tests.py b/run_tests.py index af5bb2039..97c76c081 100755 --- a/run_tests.py +++ b/run_tests.py @@ -21,7 +21,7 @@ def _prep_nose_options(self): runner = VCSTestRunner(test_suite_name, options=["--no-vtk-ui", "--vtk"], options_files=["tests/vcs_runtests.json"], get_sample_data=True, - test_data_files_info="Share/test_data_files.txt") + test_data_files_info="share/test_data_files.txt") ret_code = runner.run(workdir) sys.exit(ret_code) diff --git a/setup.py b/setup.py index 306d6854b..c08297b80 100755 --- a/setup.py +++ b/setup.py @@ -34,25 +34,25 @@ #package_dir={'vcs': 'vcs'}, scripts= ["scripts/vcs_download_sample_data"], zip_safe=True, - data_files=[('share/vcs', ('Share/wmo_symbols.json', - 'Share/data_continent_coarse', - 'Share/data_continent_political', - 'Share/data_continent_river', - 'Share/data_continent_states', - 'Share/data_continent_other7', - 'Share/data_continent_fine', - 'Share/initial.attributes', - 'Share/cdat.png', - 'Share/marker_icon.png', - 'Share/text_icon.png', - 'Share/fill_icon.png', - 'Share/line_icon.png', - 'Share/sample_files.txt', - 'Share/mapper.js', - 'Share/cvi_tip_lib.js', - 'Share/tooltip.css', - 'Share/modal.js', - 'Share/test_data_files.txt')), + data_files=[('share/vcs', ('share/wmo_symbols.json', + 'share/data_continent_coarse', + 'share/data_continent_political', + 'share/data_continent_river', + 'share/data_continent_states', + 'share/data_continent_other7', + 'share/data_continent_fine', + 'share/initial.attributes', + 'share/cdat.png', + 'share/marker_icon.png', + 'share/text_icon.png', + 'share/fill_icon.png', + 'share/line_icon.png', + 'share/sample_files.txt', + 'share/mapper.js', + 'share/cvi_tip_lib.js', + 'share/tooltip.css', + 'share/modal.js', + 'share/test_data_files.txt')), ('share/vcs/fonts', ('Fonts/Adelon_Regular.ttf', 'Fonts/Arabic.ttf', 'Fonts/Athens_Greek.ttf', diff --git a/Share/cdat.png b/share/cdat.png similarity index 100% rename from Share/cdat.png rename to share/cdat.png diff --git a/Share/cvi_tip_lib.js b/share/cvi_tip_lib.js similarity index 100% rename from Share/cvi_tip_lib.js rename to share/cvi_tip_lib.js diff --git a/Share/data_continent_coarse b/share/data_continent_coarse similarity index 100% rename from Share/data_continent_coarse rename to share/data_continent_coarse diff --git a/Share/data_continent_fine b/share/data_continent_fine similarity index 100% rename from Share/data_continent_fine rename to share/data_continent_fine diff --git a/Share/data_continent_other7 b/share/data_continent_other7 similarity index 100% rename from Share/data_continent_other7 rename to share/data_continent_other7 diff --git a/Share/data_continent_political b/share/data_continent_political similarity index 100% rename from Share/data_continent_political rename to share/data_continent_political diff --git a/Share/data_continent_river b/share/data_continent_river similarity index 100% rename from Share/data_continent_river rename to share/data_continent_river diff --git a/Share/data_continent_states b/share/data_continent_states similarity index 100% rename from Share/data_continent_states rename to share/data_continent_states diff --git a/Share/fill_icon.png b/share/fill_icon.png similarity index 100% rename from Share/fill_icon.png rename to share/fill_icon.png diff --git a/Share/fonts b/share/fonts similarity index 100% rename from Share/fonts rename to share/fonts diff --git a/Share/initial.attributes b/share/initial.attributes similarity index 100% rename from Share/initial.attributes rename to share/initial.attributes diff --git a/Share/line_icon.png b/share/line_icon.png similarity index 100% rename from Share/line_icon.png rename to share/line_icon.png diff --git a/Share/mapper.js b/share/mapper.js similarity index 100% rename from Share/mapper.js rename to share/mapper.js diff --git a/Share/marker_icon.png b/share/marker_icon.png similarity index 100% rename from Share/marker_icon.png rename to share/marker_icon.png diff --git a/Share/modal.js b/share/modal.js similarity index 100% rename from Share/modal.js rename to share/modal.js diff --git a/Share/sample_files.txt b/share/sample_files.txt similarity index 100% rename from Share/sample_files.txt rename to share/sample_files.txt diff --git a/Share/test_data_files.txt b/share/test_data_files.txt similarity index 100% rename from Share/test_data_files.txt rename to share/test_data_files.txt diff --git a/Share/text_icon.png b/share/text_icon.png similarity index 100% rename from Share/text_icon.png rename to share/text_icon.png diff --git a/Share/tooltip.css b/share/tooltip.css similarity index 100% rename from Share/tooltip.css rename to share/tooltip.css diff --git a/Share/vcs b/share/vcs similarity index 100% rename from Share/vcs rename to share/vcs diff --git a/Share/wmo_symbols.json b/share/wmo_symbols.json similarity index 100% rename from Share/wmo_symbols.json rename to share/wmo_symbols.json diff --git a/tests/share/template_test_associated_dump.json b/tests/share/template_test_associated_dump.json index 7534fd602..985c83e51 100644 --- a/tests/share/template_test_associated_dump.json +++ b/tests/share/template_test_associated_dump.json @@ -195,7 +195,7 @@ "y": 0.922999978065 }, "tname": { - "priority": 1, + "priority": 0, "textorientation": "default", "texttable": "default", "x": 0.0, @@ -217,7 +217,7 @@ }, "tvalue": { "format": "default", - "priority": 1, + "priority": 0, "textorientation": "default", "texttable": "default", "x": 0.800000011921, @@ -274,15 +274,15 @@ "y2": 0.871999979019 }, "xunits": { - "priority": 1, + "priority": 0, "textorientation": "default", "texttable": "default", "x": 0.600000023842, - "y": 0.277000010014 + "y": 0.21 }, "xvalue": { "format": "default", - "priority": 1, + "priority": 0, "textorientation": "default", "texttable": "default", "x": 0.800000011921, @@ -332,15 +332,15 @@ "x2": 0.959999978542 }, "yunits": { - "priority": 1, - "textorientation": "default", + "priority": 0, + "textorientation": "defup", "texttable": "default", - "x": 0.019999999553, + "x": 0.006, "y": 0.658999979496 }, "yvalue": { "format": "default", - "priority": 1, + "priority": 0, "textorientation": "default", "texttable": "default", "x": 0.800000011921, diff --git a/vcs/Canvas.py b/vcs/Canvas.py index 34aeb0f55..74f0113a9 100644 --- a/vcs/Canvas.py +++ b/vcs/Canvas.py @@ -714,9 +714,9 @@ def _reconstruct_tv(self, arglist, keyargs): isgridded = (grid is not None) # Set the default graphics method if not already set. + # See _determine_arg_list if arglist[GRAPHICS_METHOD] == "default" or\ (arglist[GRAPHICS_METHOD] == 'boxfill' and arglist[GRAPHICS_METHOD + 1] == "default"): - # See _determine_arg_list if grid is None: if tv.ndim == 1: @@ -2823,13 +2823,13 @@ def __new_elts(self, original, new): def __plot(self, arglist, keyargs): - # This routine has five arguments in arglist from _determine_arg_list - # It adds one for bg and passes those on to Canvas.plot as its sixth - # arguments. + # This routine has five arguments in arglist from _determine_arg_list + # It adds one for bg and passes those on to Canvas.plot as its sixth + # arguments. - # First of all let's remember which elets we have before comin in here - # so that anything added (temp objects) can be removed at clear - # time + # First of all let's remember which elets we have before comin in here + # so that anything added (temp objects) can be removed at clear + # time original_elts = {} new_elts = {} for k in list(vcs.elements.keys()): diff --git a/vcs/Pformat.py b/vcs/Pformat.py index 93a2c3db7..75ebf5ac6 100755 --- a/vcs/Pformat.py +++ b/vcs/Pformat.py @@ -133,15 +133,18 @@ def __init__(self, member): if member == "xvalue": self.x = 0.800000011921 self.y = 0.941999971867 + self.priority = 0 elif member == "yvalue": self.x = 0.800000011921 self.y = 0.922999978065 + self.priority = 0 elif member == "zvalue": self.x = 0.800000011921 self.y = 0.902999997139 elif member == "tvalue": self.x = 0.800000011921 self.y = 0.883000016212 + self.priority = 0 elif member == "mean": self.x = 0.0500000007451 self.y = 0.899999976158 diff --git a/vcs/Ptext.py b/vcs/Ptext.py index 617bd0daa..2805cb0f4 100755 --- a/vcs/Ptext.py +++ b/vcs/Ptext.py @@ -183,12 +183,16 @@ def __init__(self, member): elif member == "tname": self.x = 0. self.y = 0.995000004768 + self.priority = 0 elif member == "xunits": self.x = 0.600000023842 - self.y = 0.277000010014 + self.y = 0.21 + self.priority = 0 elif member == "yunits": - self.x = 0.019999999553 + self.x = 0.006 self.y = 0.658999979496 + self.textorientation = "defup" + self.priority = 0 elif member == "zunits": self.x = 0. self.y = 0.995000004768 diff --git a/vcs/VCS_validation_functions.py b/vcs/VCS_validation_functions.py index 7f2b25b41..0c6e5443e 100644 --- a/vcs/VCS_validation_functions.py +++ b/vcs/VCS_validation_functions.py @@ -118,7 +118,7 @@ def checkContinents(self, value): "data_continent_%s" % nms[value - 1]) if not os.path.exists(path): - # fallback on installed with system one + # fallback on installed with system one path = os.path.join( vcs.vcs_egg_path, "data_continent_%s" % nms[ @@ -365,7 +365,7 @@ def checkMarker(self, name, value): elif value in range(100, 203): value = "w%.2i" % (value - 100) elif (queries.ismarker(value) == 1): - value = value.name + value = value.name else: checkedRaise( diff --git a/vcs/VTKPlots.py b/vcs/VTKPlots.py index 91b8d25ec..e60f0d34e 100644 --- a/vcs/VTKPlots.py +++ b/vcs/VTKPlots.py @@ -1123,6 +1123,8 @@ def renderTemplate(self, tmpl, data, gm, taxis, # ok first basic template stuff, let's store the displays # because we need to return actors for min/max/mean + kargs["taxis"] = taxis + kargs["zaxis"] = zaxis displays = tmpl.plot( self.canvas, data, diff --git a/vcs/colormap.py b/vcs/colormap.py index bbf8508eb..4c0ba32fd 100644 --- a/vcs/colormap.py +++ b/vcs/colormap.py @@ -286,15 +286,15 @@ def setindex(self, value): ########################################################################## def __init__(self, Cp_name, Cp_name_src='default'): - # # - ############################################################### - # Initialize the colormap class and its members # - # # - # The getCpmember function retrieves the values of the # - # colormap members in the C structure and passes back the # - # appropriate Python Object. # - ############################################################### - # # + # # + ############################################################### + # Initialize the colormap class and its members # + # # + # The getCpmember function retrieves the values of the # + # colormap members in the C structure and passes back the # + # appropriate Python Object. # + ############################################################### + # # self.s_name = 'Cp' self._name = Cp_name if Cp_name == "default": diff --git a/vcs/displayplot.py b/vcs/displayplot.py index 8042f1065..b90ab4a12 100755 --- a/vcs/displayplot.py +++ b/vcs/displayplot.py @@ -301,14 +301,14 @@ def _set_backend(self, value): # # ########################################################################## def __init__(self, Dp_name, Dp_name_src='default', parent=None): - # # - ################################################################### - # Initialize the display plot's class and its members # - # The getDpmember function retrieves the values of the # - # display plot members in the C structure and passes back the # - # appropriate Python Object. # - ################################################################### - # # + # # + ################################################################### + # Initialize the display plot's class and its members # + # The getDpmember function retrieves the values of the # + # display plot members in the C structure and passes back the # + # appropriate Python Object. # + ################################################################### + # # self.extradisplays = [] self._name = Dp_name self.s_name = 'Dp' diff --git a/vcs/fillarea.py b/vcs/fillarea.py index 7fb3ab7e6..07179c563 100755 --- a/vcs/fillarea.py +++ b/vcs/fillarea.py @@ -387,14 +387,14 @@ def _sety(self, value): # # def __init__(self, Tf_name=None, Tf_name_src='default'): - # - # - # Initialize the fillarea class and its members # - # The getTfmember function retrieves the values of the # - # fillarea members in the C structure and passes back the # - # appropriate Python Object. # - # - # + # + # + # Initialize the fillarea class and its members # + # The getTfmember function retrieves the values of the # + # fillarea members in the C structure and passes back the # + # appropriate Python Object. # + # + # if isinstance(Tf_name_src, Tf): Tf_name_src = Tf_name_src.name if Tf_name_src != "default" and Tf_name_src not in list(vcs.elements[ diff --git a/vcs/isofill.py b/vcs/isofill.py index 7a265b1d1..5464f7ad0 100755 --- a/vcs/isofill.py +++ b/vcs/isofill.py @@ -574,14 +574,14 @@ def _setdatawc_y2(self, value): levels = VCS_validation_functions.levels def __init__(self, Gfi_name, Gfi_name_src='default'): - # - # - # Initialize the isofill class and its members # - # The getGfimember function retrieves the values of the # - # isofill members in the C structure and passes back the # - # appropriate Python Object. # - # - # + # + # + # Initialize the isofill class and its members # + # The getGfimember function retrieves the values of the # + # isofill members in the C structure and passes back the # + # appropriate Python Object. # + # + # if not isinstance(Gfi_name, str): raise ValueError("Isofill name must be a string") if Gfi_name in list(vcs.elements["isofill"].keys()): diff --git a/vcs/isoline.py b/vcs/isoline.py index f642c46b2..f48d30cdf 100755 --- a/vcs/isoline.py +++ b/vcs/isoline.py @@ -886,14 +886,14 @@ def _setclockwise(self, value): clockwise = property(_getclockwise, _setclockwise) def __init__(self, Gi_name, Gi_name_src='default'): - # # - ########################################################### - # Initialize the isoline class and its members # - # The getGimember function retrieves the values of the # - # isoline members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### - # # + # # + ########################################################### + # Initialize the isoline class and its members # + # The getGimember function retrieves the values of the # + # isoline members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### + # # if not isinstance(Gi_name, str): raise ValueError("Isoline name must be a string") if Gi_name in list(vcs.elements["isoline"].keys()): diff --git a/vcs/line.py b/vcs/line.py index 510af6977..7cebfdbbb 100755 --- a/vcs/line.py +++ b/vcs/line.py @@ -315,14 +315,14 @@ def _sety(self, value): # # ########################################################################## def __init__(self, Tl_name, Tl_name_src='default'): - # # - ########################################################### - # Initialize the line class and its members # - # The getTlmember function retrieves the values of the # - # line members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### - # # + # # + ########################################################### + # Initialize the line class and its members # + # The getTlmember function retrieves the values of the # + # line members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### + # # if Tl_name in list(vcs.elements["line"].keys()): raise ValueError("lineobject '%' already exists" % Tl_name) self._name = Tl_name diff --git a/vcs/meshfill.py b/vcs/meshfill.py index d8695a5d0..6c6c930d2 100644 --- a/vcs/meshfill.py +++ b/vcs/meshfill.py @@ -597,12 +597,12 @@ def _setwrap(self, value): wrap = property(_getwrap, _setwrap) def __init__(self, Gfm_name, Gfm_name_src='default'): - ########################################################### - # Initialize the meshfill class and its members # - # The getGfmmember function retrieves the values of the # - # meshfill members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### + ########################################################### + # Initialize the meshfill class and its members # + # The getGfmmember function retrieves the values of the # + # meshfill members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### if not isinstance(Gfm_name, str): raise ValueError("meshfill name must be a string") diff --git a/vcs/streamline.py b/vcs/streamline.py index 1dbd404ac..5cd3f9189 100644 --- a/vcs/streamline.py +++ b/vcs/streamline.py @@ -744,15 +744,15 @@ def setLineAttributes(self, line): vcs.setLineAttributes(self, line) def __init__(self, Gs_name, Gs_name_src='default'): - # # - ########################################################### - # Initialize the streamline class and its members # - # # - # The getGsmember function retrieves the values of the # - # streamline members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### - # # + # # + ########################################################### + # Initialize the streamline class and its members # + # # + # The getGsmember function retrieves the values of the # + # streamline members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### + # # if Gs_name in vcs.elements["streamline"]: raise ValueError( "The streamline method '%s' already exists" % Gs_name) diff --git a/vcs/template.py b/vcs/template.py index 27d0293bb..3ffaf01ec 100644 --- a/vcs/template.py +++ b/vcs/template.py @@ -275,15 +275,15 @@ def _setOrientation(self, value): # Initialize the template attributes. # def __init__(self, Pic_name=None, Pic_name_src='default'): - # # - ########################################################### - # Initialize the template class and its members # - # # - # The getPmember function retrieves the values of the # - # template members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### - # # + # # + ########################################################### + # Initialize the template class and its members # + # # + # The getPmember function retrieves the values of the # + # template members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### + # # if (Pic_name is None): raise ValueError('Must provide a template name.') if Pic_name_src != "default" and Pic_name_src not in vcs.elements[ @@ -1079,7 +1079,7 @@ def drawTicks(self, slab, gm, x, axis, number, loc = copy.copy(getattr(gm, axis + 'mtics' + number)) # Are they set or do we need to it ? if (loc is None or loc == '*'): - # well i guess we have to do it ! + # well i guess we have to do it ! if axis == 'x': x1 = wc[0] x2 = wc[1] @@ -1429,8 +1429,7 @@ def moveto(self, x, y): def scale(self, scale, axis='xy', font=-1): """Scale a template along the axis 'x' or 'y' by scale - Positive values of scale mean increase. - Negative values of scale mean decrease. + Values of scale greater than 1. mean increase. The reference point is the template's x1 and y1 data. :Example: @@ -1612,7 +1611,7 @@ def drawLinesAndMarkersLegend(self, canvas, :param backgroundcolor: A list indicating the background color of the legended box. Colors are represented as either an int from 0-255, an rgba tuple, or a string color name. - :type markercolors: `list`_ + :type backgroundcolor: `list`_ """ return vcs.utils.drawLinesAndMarkersLegend(canvas, self.legend, @@ -1752,40 +1751,45 @@ def plot(self, x, slab, gm, bg=False, min=None, kargs["donotstoredisplay"] = True if not isinstance(gm, vcs.taylor.Gtd): nms = ["x", "y", "z", "t"] - for i, ax in enumerate(slab.getAxisList()[::-1]): - if nms[i] in ["x", "y"] and hasattr(gm, "projection") and \ - vcs.elements["projection"][gm.projection].type \ - in round_projections: + for i, ax in enumerate(slab.getAxisList()[-2:][::-1] + + [kargs.get("zaxis", None), kargs.get("taxis", None)]): + if (hasattr(gm, "projection") and + vcs.elements["projection"][gm.projection].type + in round_projections) or ax is None: continue - nm = nms[i] + "name" - sub = getattr(self, nm) - tt = x.createtext( - None, - sub.texttable, - None, - sub.textorientation) - if i == 0 and gm.g_name == "G1d": - if gm.flip or hasattr(slab, "_yname"): - tt.string = [slab.id] - else: - tt.string = [ax.id] - elif i == 1 and gm.g_name == "G1d": - if hasattr(slab, "_yname"): - tt.string = [slab._yname] - else: - tt.string = [ax.id] - else: - tt.string = [ax.id] - tt.x = [sub.x, ] - tt.y = [sub.y, ] - tt.priority = sub._priority - # This is the name of the axis. It should be transformed - # through geographic projection but it is not at the moment - displays.append(x.text(tt, bg=bg, **kargs)) - sp = tt.name.split(":::") - del(vcs.elements["texttable"][sp[0]]) - del(vcs.elements["textorientation"][sp[1]]) - del(vcs.elements["textcombined"][tt.name]) + for att in ["name", "units", "value"]: + nm = nms[i] + att + sub = getattr(self, nm) + tt = x.createtext( + None, + sub.texttable, + None, + sub.textorientation) + if att == "name": + if i == 0 and gm.g_name == "G1d": + if gm.flip or hasattr(slab, "_yname"): + tt.string = [slab.id] + else: + tt.string = [ax.id] + elif i == 1 and gm.g_name == "G1d": + if hasattr(slab, "_yname"): + tt.string = [slab._yname] + else: + tt.string = [ax.id] + else: + tt.string = [ax.id] + elif att == "units": + tt.string = [getattr(ax, "units", "")] + tt.x = [sub.x, ] + tt.y = [sub.y, ] + tt.priority = sub._priority + # This is the name of the axis. It should be transformed + # through geographic projection but it is not at the moment + displays.append(x.text(tt, bg=bg, **kargs)) + sp = tt.name.split(":::") + del(vcs.elements["texttable"][sp[0]]) + del(vcs.elements["textorientation"][sp[1]]) + del(vcs.elements["textcombined"][tt.name]) if X is None: X = slab.getAxis(-1) @@ -1970,21 +1974,21 @@ def drawColorBar(self, colors, levels, legend=None, ext_1='n', T = [] # thickness # computes the fillarea coordinates iext = 0 # To know if we changed the dims - if (ext_1 == 'y' or ext_2 == 'y'): # and boxLength < self.legend.arrow * length: + if (ext_1 in ['y', 1, True] or ext_2 in ['y', 1, True]): # and boxLength < self.legend.arrow * length: iext = 1 # one mins changed ext_1 arrowLength = self.legend.arrow * length - if ext_1 == 'y' and ext_2 == 'y': + if ext_1 in ['y', 1, True] and ext_2 in ['y', 1, True]: boxLength = (length - 2. * arrowLength) / (nbox - 2.) iext = 3 # changed both side else: boxLength = (length - arrowLength) / (nbox - 1.) - if ext_2 == 'y': + if ext_2 in ['y', 1, True]: iext = 2 # Loops thru the boxes (i.e colors NOT actual boxes drawn) adjust = 0 for i in range(nbox): - if ext_1 == 'y' and i == 0: + if ext_1 in ['y', 1, True] and i == 0: # Draws the little arrow at the begining # Make sure the triangle goes back to first point # Because used to close the extension @@ -2003,7 +2007,7 @@ def drawColorBar(self, colors, levels, legend=None, ext_1='n', if iext == 1 or iext == 3: startLength = startLength + arrowLength adjust = -1 - elif ext_2 == 'y' and i == nbox - 1: + elif ext_2 in ['y', 1, True] and i == nbox - 1: # Draws the little arrow at the end L.append([ startLength + boxLength * (i + adjust), @@ -2058,13 +2062,13 @@ def drawColorBar(self, colors, levels, legend=None, ext_1='n', Lt = [] # Length ticks location St = [] # String location levelsLength = length # length of the levels area - if ext_1 == 'y': + if ext_1 in ['y', 1, True]: Tl.append(T[0]) Ll.append(L[0]) levels.pop(0) if iext == 1 or iext == 3: levelsLength = levelsLength - arrowLength - if ext_2 == 'y': + if ext_2 in ['y', 1, True]: Tl.append(T[-1]) Ll.append(L[-1]) levels.pop(-1) @@ -2239,7 +2243,7 @@ def ratio_linear_projection(self, lon1, lon2, lat1, lat2, self.ratio(Rwished, Rout, box_and_ticks, x) return - def ratio(self, Rwished, Rout=None, box_and_ticks=0, x=None): + def ratio(self, Rwished, Rout=None, box_and_ticks=True, x=None): """Computes ratio to shrink the data area of a template to have an y/x ratio of Rwished has the least possible deformation in linear projection @@ -2255,12 +2259,15 @@ def ratio(self, Rwished, Rout=None, box_and_ticks=0, x=None): Rwished MUST be provided. :type Rwished: `float`_ or `int`_ - :param Rout: Ratio of output (default is US Letter=11./8.5). + :param Rout: Ratio of output (default is SCREEN). Also you can pass a string: "A4","US LETTER", "X"/"SCREEN", the latest uses the window information box_and_ticks: Also redefine box and ticks to the new region :type Rout: str or None + :param box_and_ticks: Also scale the boxes and ticks default True + :type box_and_ticks: `int` or `bool` + :returns: vcs template object :rtype: vcs.template.P """ diff --git a/vcs/texttable.py b/vcs/texttable.py index 88118deff..88823f360 100755 --- a/vcs/texttable.py +++ b/vcs/texttable.py @@ -399,15 +399,15 @@ def _sety(self, value): # # ########################################################################## def __init__(self, Tt_name=None, Tt_name_src='default'): - # # - ############################################################# - # Initialize the text table class and its members # - # # - # The getTtmember function retrieves the values of the # - # text table members in the C structure and passes back the # - # appropriate Python Object. # - ############################################################# - # # + # # + ############################################################# + # Initialize the text table class and its members # + # # + # The getTtmember function retrieves the values of the # + # text table members in the C structure and passes back the # + # appropriate Python Object. # + ############################################################# + # # if (Tt_name is None): raise ValueError('Must provide a text table name.') if Tt_name in list(vcs.elements["texttable"].keys()): diff --git a/vcs/unified1D.py b/vcs/unified1D.py index 9f0fc5532..48fa91d14 100644 --- a/vcs/unified1D.py +++ b/vcs/unified1D.py @@ -652,15 +652,15 @@ def _gtype(self): g_type = property(_gtype, None, None, "the 1d graphics method type") def __init__(self, name, name_src='default'): - # # - ########################################################### - # Initialize the Yxvsx class and its members # - # # - # The getGYxmember function retrieves the values of the # - # Yxvsx members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### - # # + # # + ########################################################### + # Initialize the Yxvsx class and its members # + # # + # The getGYxmember function retrieves the values of the # + # Yxvsx members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### + # # if name in vcs.elements["1d"]: raise ValueError("The 1D method '%s' already exists") self.g_name = 'G1d' diff --git a/vcs/utils.py b/vcs/utils.py index d77e1970b..30e9bb6c0 100644 --- a/vcs/utils.py +++ b/vcs/utils.py @@ -1952,7 +1952,7 @@ def setTicksandLabels(gm, copy_gm, datawc_x1, datawc_x2, if isinstance(lbls, basestring) and lbls != "*": mticks = vcs.elements["list"][lbls] if lbls is None or lbls == "*": - if location is "x" and x == "longitude" and abs( + if location == "x" and x == "longitude" and abs( datawc_x2 - datawc_x1) > 30: ticks = transformTicks( vcs.elements["list"]["Lon30"], x_forward) diff --git a/vcs/vcsvtk/boxfillpipeline.py b/vcs/vcsvtk/boxfillpipeline.py index 661a8d0ee..880427f58 100644 --- a/vcs/vcsvtk/boxfillpipeline.py +++ b/vcs/vcsvtk/boxfillpipeline.py @@ -208,11 +208,8 @@ def _plotInternal(self): self._resultDict["vtk_backend_actors"] = actors - t = self._originalData1.getTime() - if self._originalData1.ndim > 2: - z = self._originalData1.getAxis(-3) - else: - z = None + z, t = self.getZandT() + kwargs = { "vtk_backend_grid": self._vtkDataSet, "dataset_bounds": self._vtkDataSetBounds, diff --git a/vcs/vcsvtk/isofillpipeline.py b/vcs/vcsvtk/isofillpipeline.py index 7e642eef7..4d6403a86 100644 --- a/vcs/vcsvtk/isofillpipeline.py +++ b/vcs/vcsvtk/isofillpipeline.py @@ -216,11 +216,8 @@ def _plotInternal(self): self._resultDict["vtk_backend_actors"] = actors - t = self._originalData1.getTime() - if self._originalData1.ndim > 2: - z = self._originalData1.getAxis(-3) - else: - z = None + z, t = self.getZandT() + kwargs = { "vtk_backend_grid": self._vtkDataSet, "dataset_bounds": self._vtkDataSetBounds, diff --git a/vcs/vcsvtk/isolinepipeline.py b/vcs/vcsvtk/isolinepipeline.py index 50ae0161e..650073a59 100644 --- a/vcs/vcsvtk/isolinepipeline.py +++ b/vcs/vcsvtk/isolinepipeline.py @@ -333,11 +333,8 @@ def _plotInternal(self): self._resultDict["vtk_backend_actors"] = actors - t = self._originalData1.getTime() - if self._originalData1.ndim > 2: - z = self._originalData1.getAxis(-3) - else: - z = None + z, t = self.getZandT() + kwargs = { "vtk_backend_grid": self._vtkDataSet, "dataset_bounds": self._vtkDataSetBounds, diff --git a/vcs/vcsvtk/meshfillpipeline.py b/vcs/vcsvtk/meshfillpipeline.py index 3f8ffef72..1a97fd189 100644 --- a/vcs/vcsvtk/meshfillpipeline.py +++ b/vcs/vcsvtk/meshfillpipeline.py @@ -263,11 +263,8 @@ def _plotInternal(self): actors.append([patItem, plotting_dataset_bounds]) - t = self._originalData1.getTime() - if self._originalData1.ndim > 2: - z = self._originalData1.getAxis(-3) - else: - z = None + z, t = self.getZandT() + self._resultDict["vtk_backend_actors"] = actors kwargs = { "vtk_backend_grid": self._vtkDataSet, diff --git a/vcs/vcsvtk/pipeline.py b/vcs/vcsvtk/pipeline.py index 4cd87c698..4b2db6f0c 100644 --- a/vcs/vcsvtk/pipeline.py +++ b/vcs/vcsvtk/pipeline.py @@ -86,3 +86,13 @@ def _processRatioAutot(self, template, dataset): viewportBounds[0] = (xMiddle - xSizeHalf) / windowSize[0] viewportBounds[1] = (xMiddle + xSizeHalf) / windowSize[0] return viewportBounds + + def getZandT(self): + t = self._originalData1.getTime() + z = self._originalData1.getLevel() + + if self._originalData1.ndim > 2 and z is None: + z = self._originalData1.getAxis(-3) + if self._originalData1.ndim > 3 and t is None: + t = self._originalData1.getAxis(-4) + return z, t diff --git a/vcs/vcsvtk/streamlinepipeline.py b/vcs/vcsvtk/streamlinepipeline.py index 884f37e14..8d9b5ecdc 100644 --- a/vcs/vcsvtk/streamlinepipeline.py +++ b/vcs/vcsvtk/streamlinepipeline.py @@ -25,12 +25,8 @@ def _plotInternal(self): """Overrides baseclass implementation.""" # Preserve time and z axis for plotting these inof in rendertemplate projection = vcs.elements["projection"][self._gm.projection] - taxis = self._originalData1.getTime() - if self._originalData1.ndim > 2: - zaxis = self._originalData1.getAxis(-3) - else: - zaxis = None + zaxis, taxis = self.getZandT() # Streamline color if (not self._gm.coloredbyvector): diff --git a/vcs/vcsvtk/vectorpipeline.py b/vcs/vcsvtk/vectorpipeline.py index 171bac71f..e1133abbd 100644 --- a/vcs/vcsvtk/vectorpipeline.py +++ b/vcs/vcsvtk/vectorpipeline.py @@ -18,13 +18,7 @@ def _plotInternal(self): """Overrides baseclass implementation.""" # Preserve time and z axis for plotting these inof in rendertemplate projection = vcs.elements["projection"][self._gm.projection] - taxis = self._originalData1.getTime() - - if self._originalData1.ndim > 2: - zaxis = self._originalData1.getAxis(-3) - else: - zaxis = None - + zaxis, taxis = self.getZandT() scale = 1.0 if self._vtkGeoTransform is not None: diff --git a/vcs/vector.py b/vcs/vector.py index 2a530d9ab..d98ae4c67 100755 --- a/vcs/vector.py +++ b/vcs/vector.py @@ -644,15 +644,15 @@ def _setscalerange(self, value): scalerange = property(_getscalerange, _setscalerange) def __init__(self, Gv_name, Gv_name_src='default'): - # # - ########################################################### - # Initialize the vector class and its members # - # # - # The getGvmember function retrieves the values of the # - # vector members in the C structure and passes back the # - # appropriate Python Object. # - ########################################################### - # # + # # + ########################################################### + # Initialize the vector class and its members # + # # + # The getGvmember function retrieves the values of the # + # vector members in the C structure and passes back the # + # appropriate Python Object. # + ########################################################### + # # if Gv_name in vcs.elements["vector"]: raise ValueError("The vector method '%s' already exists" % Gv_name) self.g_name = 'Gv' diff --git a/vcs/xmldocs.py b/vcs/xmldocs.py index 7c2dcf9d1..df39aed56 100644 --- a/vcs/xmldocs.py +++ b/vcs/xmldocs.py @@ -432,7 +432,7 @@ def populate_docstrings(type_dict, target_dict, docstring, method): # section for manageElements 'get' methods if method == 'get': example1 = """>>> ex=vcs.get%(name)s(%(sp_parent)s) # '%(parent)s' %(name)s""" - if d['tc'] is not '': + if d['tc'] != '': example1 = d['tc'] + example1 # set up d['plot'] and d['plot2'] plot = '' @@ -441,7 +441,7 @@ def populate_docstrings(type_dict, target_dict, docstring, method): d['slabs'] = '' d['args'] = '' if numslabs > 0: - if obj_name is "taylordiagram": + if obj_name == "taylordiagram": d['slabs'] = """ >>> slab1 = [[0, 1, 2, 3, 4], [0.1, 0.2, 0.3, 0.4, 0.5]] # data""" else: @@ -475,7 +475,7 @@ def populate_docstrings(type_dict, target_dict, docstring, method): >>> a.plot(ex2%(args)s) # plot %(name)s """ if obj_name.find('3d') >= 0: - if obj_name is "3d_vector": + if obj_name == "3d_vector": plot = "" # >>> a.plot(ex%(args)s) # plot %(name)s # Sample rate: 6 @@ -490,7 +490,7 @@ def populate_docstrings(type_dict, target_dict, docstring, method): # # """ - if d['slabs'] is not '': + if d['slabs'] != '': plot = d['slabs'] + plot example1 += plot d['example'] = example1 % d @@ -537,7 +537,7 @@ def populate_docstrings(type_dict, target_dict, docstring, method): >>> vcs.queries.is%(name)s(ex) 1 """ - if d['tc'] is not '': + if d['tc'] != '': example = d['tc'] + example d['example'] = example % d target_dict[obj_name] = docstring % d