Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra dims slider #417

Merged
merged 17 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/basevcstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import vcs
import cdms2
import sys
import cdat_info

pth = os.path.dirname(__file__)
sys.path.append(pth)
import cdat_info
# import glob


Expand Down Expand Up @@ -40,11 +41,11 @@ def setUp(self):
if not os.path.exists(self.pngsdir):
try:
os.makedirs(self.pngsdir)
except:
except Exception:
pass
self.basedir = os.path.join("uvcdat-testdata", "baselines", "vcs")
self.basedatadir = os.path.join("uvcdat-testdata", "data")
self.clt = cdms2.open(os.path.join(vcs.sample_data, "clt.nc"))
self.clt = cdms2.open(os.path.join(cdat_info.get_sampledata_path(), "clt.nc"))

def tearDown(self):
os.chdir(self.orig_cwd)
Expand All @@ -57,7 +58,7 @@ def tearDown(self):
def checkImage(self, fnm, src=None, threshold=cdat_info.defaultThreshold,
pngReady=False, pngPathSet=False):
ret = cdat_info.checkImage(fnm, self.x, self.basedir, self.pngsdir, src,
threshold, pngReady, pngPathSet)
threshold, pngReady, pngPathSet)
self.assertEqual(ret, 0)
return ret

Expand Down
4 changes: 3 additions & 1 deletion tests/test_vcs_1D_with_manyDs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy
import MV2
import os

import vcs

class TestVCS1DMany(basevcstest.VCSBaseTest):
def test1DMany(self):
Expand All @@ -15,6 +15,8 @@ def test1DMany(self):

one = self.x.create1d()

print("glob min mac::", vcs.minmax(d))
print("plt minmax: ", vcs.minmax(d[0]))
self.x.plot(d, one, bg=self.bg)

fnm = "test_vcs_1D_with_manyDs.png"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_vcs_animate_isoline_colored.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ def testVCSAnimateIsolineColored(self):
gm.level = levs
# add dummy values to levs to get the correct number of cols
cols = vcs.getcolors(levs + [56, ])
print(levs)
print(cols)
gm.textcolors = cols
gm.linecolors = cols
self.x.plot(s, gm, bg=self.bg)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_vcs_axisconvert_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import vcs
import cdms2
import numpy

import genutil

class TestVCSAxisConvert(basevcstest.VCSBaseTest):
def axisConvertGmLinear(self, method):
Expand Down
53 changes: 53 additions & 0 deletions tests/test_vcs_pick_frame.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import basevcstest
import cdms2
import cdat_info
import os
import vcs


class TestPickFrame(basevcstest.VCSBaseTest):
def testBoxfillPickFrame(self):
f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(), "ta_ncep_87-6-88-4.nc"))
ta = f("ta")
u = self.clt("u")
v = self.clt("v")

f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(), "sampleCurveGrid4.nc"))
mesh = f("sample")
grd = mesh.getGrid()
sh = list(mesh.shape)
print("NESFG SHAPE:",sh)
sh.insert(0,12)
axes = mesh.getAxisList()
mesh = cdms2.MV2.resize(mesh, sh)
mesh.setGrid(grd)
ax = mesh.getAxis(0)
ax.units = "months since 2019"
ax.id = "time"
ax.designateTime()
for i, ax in enumerate(axes):
mesh.setAxis(1+i, ax)
mesh[3] = mesh[3]*3.
gm_types = ["vector", "streamline", "meshfill", "1d", "boxfill", "isofill"]
for gm_type in gm_types:
# skip first time and second level on second time
gm = vcs.getgraphicsmethod(gm_type)
if gm_type in ["vector", "streamline"]:
data1 = u
data2 = v
frame = 1
elif gm_type == "meshfill":
data1 = mesh
data2 = None
frame = 3
else:
data1 = ta
data2 = None
frame = 43
if gm_type == "1d":
frame = 193
elif gm_type == "isofill":
frame = -1
self.x.clear()
self.x.plot(data1, data2, gm, frame=frame, bg=self.bg)
self.checkImage("test_vcs_pick_frame_{}.png".format(gm_type))
29 changes: 29 additions & 0 deletions tests/test_vcs_update_array_extensions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import basevcstest
import cdms2
import cdat_info
import os
import vcs


class TestVCSUpdateArray(basevcstest.VCSBaseTest):
def testUpdateArray(self):
f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(),"ta_ncep_87-6-88-4.nc"))
data = f("ta")
levels = vcs.mkscale(*vcs.minmax(data))
levels.insert(0, 1.e20)
levels.append(1.e20)
colors = vcs.getcolors(levels)
isof = vcs.createisofill()
isof.levels = levels
isof.fillareacolors = colors
isol = vcs.createisoline()
isol.levels = levels
tmpl = self.x.gettemplate("top_of2")
self.x.portrait()
self.x.plot(data, isof, tmpl)
tmpl = self.x.gettemplate("bot_of2")
disp = self.x.plot(data, isof, tmpl)
kw = {"time": slice(3, 4), "level": slice(6, 7)}
new = disp.array[0](**kw)
self.x.backend.update_input(disp.backend, new)
self.checkImage("test_vcs_update_array_extensions.png")
22 changes: 19 additions & 3 deletions vcs/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ def _determine_arg_list(g_name, actual_args):
arglist[igraphics_method] = graphicsmethodtype(args[i])
arglist[igraphics_option] = args[i].name
found_graphics_method = found_graphics_method + 1
elif args[i] is None:
pass
else:
raise vcsError("Unknown type %s of argument to plotting command." %
type(args[i]))
Expand Down Expand Up @@ -389,7 +391,9 @@ class Canvas(vcs.bestMatch):
'__last_plot_keyargs',
'_continents_line',
'_savedcontinentstype',
'_display_target'
'_display_target',
'_display_target_out',
'_display_target_image'
]

# def applicationFocusChanged(self, old, current ):
Expand Down Expand Up @@ -2567,7 +2571,7 @@ def drawtextcombined(self, Tt_name=None, To_name=None, string=None,

_plot_keywords_ = ['variable', 'grid', 'xaxis', 'xarray', 'xrev', 'yaxis', 'yarray', 'yrev', 'continents',
'xbounds', 'ybounds', 'zaxis', 'zarray', 'taxis', 'tarray', 'waxis', 'warray', 'bg', 'ratio',
'donotstoredisplay', 'render', 'continents_line', "display_name"]
'donotstoredisplay', 'render', 'continents_line', "display_name", "frame"]

_deprecated_plot_keywords_ = ["time", "units", "file_comment", "xname", "yname", "zname", "tname", "wname",
"xunits", "yunits", "zunits", "tunits", "wunits", "comment1", "comment2", "comment3",
Expand Down Expand Up @@ -2733,7 +2737,7 @@ def plot(self, *actual_args, **keyargs):

ratio = 1.5|"autot"|"auto"

* Plot the actual grid or the dual grid
* Plot the actual grid or the dual grid (VTK backend only)

.. code-block:: python

Expand All @@ -2752,6 +2756,18 @@ def plot(self, *actual_args, **keyargs):
# if 1, create images in the background (not on canvas)
bg = 0|1

* Data with extra dimensions, picking the frame to plot:

.. code-block:: python

# if not 0 will use extra dimensions to figure which slice of data is expected
# extra dimensions are used in reverse order, e.g
# array of dims time, lev, lat, lon will plot lat/lon slices and frame "1"
# will display the second level for the first time
# Negative values are ok and start from last frame (frame=-1)
frame = 0


:Example:

.. doctest:: canvas_plot
Expand Down
Loading