Skip to content

Commit b70346c

Browse files
committed
Merge pull request #1291 from UV-CDAT/issue_1274_import_missing
Issue 1274 import missing
2 parents 66bab1b + 77efa33 commit b70346c

File tree

6 files changed

+61
-5
lines changed

6 files changed

+61
-5
lines changed

Packages/vcs/Lib/Canvas.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import os
6060
import sys
6161
import random
62-
import genutil
6362
from cdms2.grid import AbstractRectGrid
6463
import shutil, inspect
6564
import VCS_validation_functions
@@ -735,13 +734,16 @@ def _reconstruct_tv(self, arglist, keyargs):
735734
_process_keyword(tv, 'name', 'name', keyargs, default=tv.id)
736735
time = keyargs.get('time')
737736
if time is not None:
738-
ctime = time.tocomp()
739-
ar.date = str(ctime)
737+
if isinstance(time,(str,unicode)):
738+
ctime = cdtime.s2c(str(time))
739+
else:
740+
ctime = time.tocomp()
741+
tv.user_date = str(ctime)
740742
_process_keyword(tv, 'units', 'units', keyargs)
741743
_process_keyword(tv, 'date', 'ymd', keyargs)
742744
# If date has still not been set, try to get it from the first
743745
# time value if present
744-
if not hasattr(tv, 'date') and not hasattr(tv, 'time'):
746+
if not hasattr(tv, 'user_date') and not hasattr(tv, 'date') and not hasattr(tv, 'time'):
745747
change_date_time(tv, 0)
746748

747749
# Draw continental outlines if specified.
@@ -885,8 +887,10 @@ def __init__(self, gui = 0, mode = 1, pause_time=0, call_from_gui=0, size=None,
885887

886888
is_canvas = len(vcs.return_display_names()[0])
887889

890+
## TODO get rid of all these gui_canvas_closed I think the code is not even here anymore
891+
## I believe it was for the old editor style
888892
if gui_canvas_closed == 1:
889-
showerror( "Error Message to User", "There can only be one VCS Canvas GUI opened at any given time and the VCS Canvas GUI cannot operate with other VCS Canvases.")
893+
raise RuntimeError("There can only be one VCS Canvas GUI opened at any given time and the VCS Canvas GUI cannot operate with other VCS Canvases.")
890894
return
891895

892896
self.winfo_id = -99

Packages/vcs/Lib/VTKPlots.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,13 @@ def renderTemplate(self,tmpl,data,gm,taxis,zaxis):
13101310
returned["vtk_backend_%s_text_actor" % d.backend["vtk_backend_template_attribute"]] = t
13111311
self.canvas.display_names.remove(d.name)
13121312
del(vcs.elements["display"][d.name])
1313+
## Sometimes user passes "date" as an attribute to replace date
1314+
if hasattr(data,"user_date"):
1315+
taxis = cdms2.createAxis([cdtime.s2r(data.user_date,"days since 1900").value])
1316+
taxis.designateTime()
1317+
taxis.units="days since 1900"
1318+
if zaxis is not None and zaxis.isTime():
1319+
zaxis=taxis
13131320
if taxis is not None:
13141321
try:
13151322
tstr = str(cdtime.reltime(taxis[0],taxis.units).tocomp(taxis.getCalendar()))

Packages/vcs/Lib/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import colormap
2424
import vcsaddons
2525
import cdms2
26+
import genutil
2627

2728
indent = 1
2829
sort_keys = True

testing/vcs/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,16 @@ cdat_add_test(vcs_test_taylor_2_quads
314314
"${PYTHON_EXECUTABLE}"
315315
${cdat_SOURCE_DIR}/testing/vcs/test_boxfill_number_color_more_than_number_levels.py
316316
)
317+
cdat_add_test(test_vcs_user_passed_date
318+
"${PYTHON_EXECUTABLE}"
319+
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_user_passed_date.py
320+
"${BASELINE_DIR}/test_vcs_user_passed_date.png"
321+
)
322+
cdat_add_test(test_vcs_user_passed_date_as_string
323+
"${PYTHON_EXECUTABLE}"
324+
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_user_passed_date_as_string.py
325+
"${BASELINE_DIR}/test_vcs_user_passed_date_as_string.png"
326+
)
317327
cdat_add_test(test_vcs_auto_time_labels
318328
"${PYTHON_EXECUTABLE}"
319329
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_auto_time_labels.py
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import vcs,cdms2,os,sys,cdtime
2+
src=sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
f=cdms2.open(os.path.join(vcs.prefix,"sample_data","clt.nc"))
7+
s=f("clt",squeeze=1)
8+
x=vcs.init()
9+
x.drawlogooff()
10+
x.setbgoutputdimensions(1200,1091,units="pixels")
11+
x.plot(s,bg=1,time=cdtime.comptime(2015))
12+
fnm = os.path.split(__file__)[1][:-3]+".png"
13+
x.png(fnm)
14+
print "fnm:",fnm
15+
print "src:",src
16+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
17+
sys.exit(ret)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import vcs,cdms2,os,sys,cdtime
2+
src=sys.argv[1]
3+
pth = os.path.join(os.path.dirname(__file__),"..")
4+
sys.path.append(pth)
5+
import checkimage
6+
f=cdms2.open(os.path.join(vcs.prefix,"sample_data","clt.nc"))
7+
s=f("clt",squeeze=1)
8+
x=vcs.init()
9+
x.drawlogooff()
10+
x.setbgoutputdimensions(1200,1091,units="pixels")
11+
x.plot(s,bg=1,time='2015-02-23')
12+
fnm = os.path.split(__file__)[1][:-3]+".png"
13+
x.png(fnm)
14+
print "fnm:",fnm
15+
print "src:",src
16+
ret = checkimage.check_result_image(fnm,src,checkimage.defaultThreshold)
17+
sys.exit(ret)

0 commit comments

Comments
 (0)