Skip to content

Commit cc0a870

Browse files
authored
Merge pull request #2025 from UV-CDAT/vcsaddons_histo_polar
Vcsaddons histo polar
2 parents c28d151 + c0ddfc1 commit cc0a870

22 files changed

+1425
-131
lines changed

Packages/vcs/vcs/Canvas.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
plot_2_1D_options
6969
gui_canvas_closed = 0
7070
canvas_closed = 0
71-
import vcsaddons # noqa
7271
import vcs.manageElements # noqa
7372
import configurator # noqa
7473
from projection import no_deformation_projections # noqa
@@ -127,7 +126,7 @@ def dictionarytovcslist(dictionary, name):
127126

128127
def _determine_arg_list(g_name, actual_args):
129128
"Determine what is in the argument list for plotting graphics methods"
130-
129+
import vcsaddons
131130
itemplate_name = 2
132131
igraphics_method = 3
133132
igraphics_option = 4
@@ -2449,14 +2448,15 @@ def __new_elts(self, original, new):
24492448
return new
24502449

24512450
def __plot(self, arglist, keyargs):
2451+
import vcsaddons
24522452

2453-
# This routine has five arguments in arglist from _determine_arg_list
2454-
# It adds one for bg and passes those on to Canvas.plot as its sixth
2455-
# arguments.
2453+
# This routine has five arguments in arglist from _determine_arg_list
2454+
# It adds one for bg and passes those on to Canvas.plot as its sixth
2455+
# arguments.
24562456

2457-
# First of all let's remember which elets we have before comin in here
2458-
# so that anything added (temp objects) can be removed at clear
2459-
# time
2457+
# First of all let's remember which elets we have before comin in here
2458+
# so that anything added (temp objects) can be removed at clear
2459+
# time
24602460
original_elts = {}
24612461
new_elts = {}
24622462
for k in vcs.elements.keys():
@@ -3493,9 +3493,14 @@ def set_convert_labels(copy_mthd, test=0):
34933493
tp = "boxfill"
34943494
elif tp in ("xvsy", "xyvsy", "yxvsx", "scatter"):
34953495
tp = "1d"
3496-
gm = vcs.elements[tp][arglist[4]]
3496+
if tp in vcsaddons.gms:
3497+
gm = vcsaddons.gms[tp][arglist[4]]
3498+
arglist[3] = gm
3499+
else:
3500+
gm = vcs.elements[tp][arglist[4]]
34973501
if hasattr(gm, "priority") and gm.priority == 0:
34983502
return
3503+
34993504
p = self.getprojection(gm.projection)
35003505
if p.type in no_deformation_projections and (
35013506
doratio == "0" or doratio[:4] == "auto"):
@@ -3710,20 +3715,22 @@ def set_convert_labels(copy_mthd, test=0):
37103715
del(keyargs["bg"])
37113716
if isinstance(arglist[3], vcsaddons.core.VCSaddon):
37123717
if arglist[1] is None:
3713-
dn = arglist[3].plot(
3718+
dn = arglist[3].plot_internal(
37143719
arglist[0],
37153720
template=arglist[2],
37163721
bg=bg,
37173722
x=self,
37183723
**keyargs)
37193724
else:
3720-
dn = arglist[3].plot(
3725+
dn = arglist[3].plot_internal(
37213726
arglist[0],
37223727
arglist[1],
37233728
template=arglist[2],
37243729
bg=bg,
37253730
x=self,
37263731
**keyargs)
3732+
self.display_names.append(dn.name)
3733+
return dn
37273734
else:
37283735
returned_kargs = self.backend.plot(*arglist, **keyargs)
37293736
if not keyargs.get("donotstoredisplay", False):
@@ -4913,7 +4920,6 @@ def _compute_width_height(self, width, height, units, ps=False):
49134920
H = tmp
49144921
return W, H
49154922

4916-
49174923
def postscript(self, file, mode='r', orientation=None, width=None, height=None,
49184924
units='inches', textAsPaths=True):
49194925
"""

Packages/vcs/vcs/displayplot.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,10 @@ def _getg_type(self):
209209
return self._g_type
210210

211211
def _setg_type(self, value):
212+
import vcsaddons
212213
value = VCS_validation_functions.checkString(self, 'g_type', value)
213214
value = value.lower()
214-
if value not in vcs.elements and value != "text":
215+
if value not in vcs.elements and value != "text" and value not in vcsaddons.gms:
215216
raise ValueError(
216217
"invalid g_type '%s' must be one of: %s " %
217218
(value, vcs.elements.keys()))
@@ -259,6 +260,7 @@ def __init__(self, Dp_name, Dp_name_src='default', parent=None):
259260
self._g_name = "default"
260261
self._array = []
261262
self._continents = 1
263+
self._continents_line = "default"
262264
self.ratio = None
263265
else:
264266
src = vcs.elements["display"][Dp_name_src]
@@ -269,6 +271,7 @@ def __init__(self, Dp_name, Dp_name_src='default', parent=None):
269271
self.g_type = src.g_type
270272
self.g_name = src.g_name
271273
self.continents = src.continents
274+
self.continents_line = src.continents_line
272275
self.priority = src.priority
273276
self.ratio = src.ratio
274277

Packages/vcs/vcs/dv3d.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ def __init__(self, Gfdv3d_name, Gfdv3d_name_src='default'):
158158
self.plot_attributes['name'] = self.g_name
159159
self.plot_attributes['template'] = Gfdv3d_name
160160

161-
162161
def setProvenanceHandler(self, provenanceHandler):
163162
self.provenanceHandler = provenanceHandler
164163

Packages/vcs/vcs/queries.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import displayplot
4545
import projection
4646
import vcs
47-
import vcsaddons
4847

4948
from error import vcsError
5049

@@ -69,6 +68,7 @@ def isgraphicsmethod(gobj):
6968
if vcs.isgraphicsmethod(box):
7069
box.list()
7170
"""
71+
import vcsaddons
7272
if (isinstance(gobj, boxfill.Gfb)):
7373
return 1
7474
elif (isinstance(gobj, isofill.Gfi)):
@@ -134,6 +134,7 @@ def graphicsmethodtype(gobj):
134134
print vcs.graphicsmethodtype(ln) # Will print None, because ln is not a
135135
# graphics method
136136
"""
137+
import vcsaddons
137138
if (isinstance(gobj, boxfill.Gfb)):
138139
return 'boxfill'
139140
elif (isinstance(gobj, isofill.Gfi)):

Packages/vcs/vcs/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import json
2121
import os
2222
import tempfile
23-
import vcsaddons
2423
import cdms2
2524
import genutil
2625
import vtk
@@ -1616,6 +1615,7 @@ def monotonic(x):
16161615

16171616

16181617
def getgraphicsmethod(type, name):
1618+
import vcsaddons
16191619
if type == "default":
16201620
type = "boxfill"
16211621
if isinstance(type, vcsaddons.core.VCSaddon):
@@ -1630,6 +1630,7 @@ def getgraphicsmethod(type, name):
16301630

16311631

16321632
def creategraphicsmethod(gtype, gname='default', name=None):
1633+
import vcsaddons
16331634
if gtype in ['isoline', 'Gi']:
16341635
func = vcs.createisoline
16351636
elif gtype in ['isofill', 'Gfi']:

Packages/vcs/vcs/vcs2vtk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,10 +1823,10 @@ def generateVectorArray(data1, data2, vtk_grid):
18231823

18241824
def vtkIterate(iterator):
18251825
iterator.InitTraversal()
1826-
obj = iterator.GetNextItem()
1826+
obj = iterator.GetNextItemAsObject()
18271827
while obj is not None:
18281828
yield obj
1829-
obj = iterator.GetNextItem()
1829+
obj = iterator.GetNextItemAsObject()
18301830

18311831

18321832
def getPlottingBounds(gmbounds, databounds, geo):

Packages/vcsaddons/Lib/__init__.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,129 @@
11
gms = {}
22
import histograms
3+
import polar
34
import EzTemplate
45
import yxvsxfill
56
import continents
7+
import vcs
8+
69

710
def createyxvsxfill(name=None,source='default',x=None,template=None):
811
return yxvsxfill.Gyf(name,source=source,x=x,template=template)
12+
13+
914
def createhistogram(name=None,source='default',x=None,template=None):
1015
return histograms.Ghg(name,source=source,x=x,template=template)
16+
17+
1118
def createusercontinents(name=None,source="default",x=None,template=None):
1219
return continents.Guc(name,source=source,x=x,template=template)
20+
21+
22+
def createpolar(name=None, source="default", x=None, template=None):
23+
if "polar_oned" not in gms:
24+
init_polar()
25+
return polar.Gpo(name, source=source, x=x, template=template)
26+
27+
28+
def getpolar(name=None):
29+
if "polar_oned" not in gms:
30+
init_polar()
31+
if name in gms["polar_oned"]:
32+
return gms["polar_oned"][name]
33+
raise KeyError("No Polar GM exists with name '%s'" % name)
34+
35+
36+
def init_polar():
37+
# Create nice polar template
38+
try:
39+
t = vcs.createtemplate("polar_oned")
40+
t.data.x1 = .2
41+
t.data.x2 = .8
42+
t.data.y1 = .2
43+
t.data.y2 = .8
44+
45+
t.legend.x1 = .85
46+
t.legend.x2 = 1
47+
t.legend.y1 = .15
48+
t.legend.y2 = .85
49+
50+
dash = vcs.createline()
51+
dash.type = "dash"
52+
dot = vcs.createline()
53+
dot.type = "dot"
54+
t.xtic1.line = dash
55+
t.ytic1.line = dot
56+
57+
left_aligned = vcs.createtextorientation()
58+
left_aligned.halign = "left"
59+
left_aligned.valign = "half"
60+
t.legend.textorientation = left_aligned
61+
except vcs.vcsError:
62+
# Template already exists
63+
pass
64+
# Create some nice default polar GMs
65+
degree_polar = polar.Gpo("degrees", template="polar_oned")
66+
degree_polar.datawc_x1 = 0
67+
degree_polar.datawc_x2 = 360
68+
degree_polar.xticlabels1 = {
69+
i: str(i) for i in range(0, 360, 45)
70+
}
71+
72+
clock_24 = polar.Gpo("diurnal", template="polar_oned")
73+
clock_24.datawc_x1 = 0
74+
clock_24.datawc_x2 = 24
75+
clock_24.clockwise = True
76+
# 6 AM on the right
77+
clock_24.theta_offset = -6
78+
clock_24.xticlabels1 = {
79+
i: str(i) for i in range(0, 24, 3)
80+
}
81+
82+
clock_24_meridiem = polar.Gpo("diurnal_12_hour", source="diurnal", template="polar_oned")
83+
clock_24_meridiem.xticlabels1 = {
84+
0: "12 AM",
85+
3: "3 AM",
86+
6: "6 AM",
87+
9: "9 AM",
88+
12: "12 PM",
89+
15: "3 PM",
90+
18: "6 PM",
91+
21: "9 PM"
92+
}
93+
94+
clock_12 = polar.Gpo("semidiurnal", source="diurnal", template="polar_oned")
95+
clock_12.datawc_x2 = 12
96+
clock_12.xticlabels1 = {
97+
i: str(i) for i in range(3, 13, 3)
98+
}
99+
# 3 on the right
100+
clock_12.theta_offset = -3
101+
102+
annual_cycle = polar.Gpo("annual_cycle", template="polar_oned")
103+
annual_cycle.datawc_x1 = 1
104+
annual_cycle.datawc_x2 = 13
105+
annual_cycle.clockwise = True
106+
annual_cycle.xticlabels1 = {
107+
1: "Jan",
108+
2: "Feb",
109+
3: "Mar",
110+
4: "Apr",
111+
5: "May",
112+
6: "Jun",
113+
7: "Jul",
114+
8: "Aug",
115+
9: "Sep",
116+
10: "Oct",
117+
11: "Nov",
118+
12: "Dec"
119+
}
120+
# Put December on the top
121+
annual_cycle.theta_offset = -2
122+
123+
seasonal = polar.Gpo("seasonal", template="polar_oned")
124+
seasonal.datawc_x1 = 0
125+
seasonal.datawc_x2 = 4
126+
seasonal.xticlabels1 = {0: "DJF", 1: "MAM", 2: "JJA", 3: "SON"}
127+
seasonal.clockwise = True
128+
# DJF on top
129+
seasonal.theta_offset = -1

0 commit comments

Comments
 (0)