Skip to content

Commit

Permalink
Merge pull request #2025 from UV-CDAT/vcsaddons_histo_polar
Browse files Browse the repository at this point in the history
Vcsaddons histo polar
  • Loading branch information
aashish24 authored Jun 11, 2016
2 parents c28d151 + c0ddfc1 commit cc0a870
Show file tree
Hide file tree
Showing 22 changed files with 1,425 additions and 131 deletions.
30 changes: 18 additions & 12 deletions Packages/vcs/vcs/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
plot_2_1D_options
gui_canvas_closed = 0
canvas_closed = 0
import vcsaddons # noqa
import vcs.manageElements # noqa
import configurator # noqa
from projection import no_deformation_projections # noqa
Expand Down Expand Up @@ -127,7 +126,7 @@ def dictionarytovcslist(dictionary, name):

def _determine_arg_list(g_name, actual_args):
"Determine what is in the argument list for plotting graphics methods"

import vcsaddons
itemplate_name = 2
igraphics_method = 3
igraphics_option = 4
Expand Down Expand Up @@ -2449,14 +2448,15 @@ def __new_elts(self, original, new):
return new

def __plot(self, arglist, keyargs):
import vcsaddons

# 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 vcs.elements.keys():
Expand Down Expand Up @@ -3493,9 +3493,14 @@ def set_convert_labels(copy_mthd, test=0):
tp = "boxfill"
elif tp in ("xvsy", "xyvsy", "yxvsx", "scatter"):
tp = "1d"
gm = vcs.elements[tp][arglist[4]]
if tp in vcsaddons.gms:
gm = vcsaddons.gms[tp][arglist[4]]
arglist[3] = gm
else:
gm = vcs.elements[tp][arglist[4]]
if hasattr(gm, "priority") and gm.priority == 0:
return

p = self.getprojection(gm.projection)
if p.type in no_deformation_projections and (
doratio == "0" or doratio[:4] == "auto"):
Expand Down Expand Up @@ -3710,20 +3715,22 @@ def set_convert_labels(copy_mthd, test=0):
del(keyargs["bg"])
if isinstance(arglist[3], vcsaddons.core.VCSaddon):
if arglist[1] is None:
dn = arglist[3].plot(
dn = arglist[3].plot_internal(
arglist[0],
template=arglist[2],
bg=bg,
x=self,
**keyargs)
else:
dn = arglist[3].plot(
dn = arglist[3].plot_internal(
arglist[0],
arglist[1],
template=arglist[2],
bg=bg,
x=self,
**keyargs)
self.display_names.append(dn.name)
return dn
else:
returned_kargs = self.backend.plot(*arglist, **keyargs)
if not keyargs.get("donotstoredisplay", False):
Expand Down Expand Up @@ -4913,7 +4920,6 @@ def _compute_width_height(self, width, height, units, ps=False):
H = tmp
return W, H


def postscript(self, file, mode='r', orientation=None, width=None, height=None,
units='inches', textAsPaths=True):
"""
Expand Down
5 changes: 4 additions & 1 deletion Packages/vcs/vcs/displayplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ def _getg_type(self):
return self._g_type

def _setg_type(self, value):
import vcsaddons
value = VCS_validation_functions.checkString(self, 'g_type', value)
value = value.lower()
if value not in vcs.elements and value != "text":
if value not in vcs.elements and value != "text" and value not in vcsaddons.gms:
raise ValueError(
"invalid g_type '%s' must be one of: %s " %
(value, vcs.elements.keys()))
Expand Down Expand Up @@ -259,6 +260,7 @@ def __init__(self, Dp_name, Dp_name_src='default', parent=None):
self._g_name = "default"
self._array = []
self._continents = 1
self._continents_line = "default"
self.ratio = None
else:
src = vcs.elements["display"][Dp_name_src]
Expand All @@ -269,6 +271,7 @@ def __init__(self, Dp_name, Dp_name_src='default', parent=None):
self.g_type = src.g_type
self.g_name = src.g_name
self.continents = src.continents
self.continents_line = src.continents_line
self.priority = src.priority
self.ratio = src.ratio

Expand Down
1 change: 0 additions & 1 deletion Packages/vcs/vcs/dv3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def __init__(self, Gfdv3d_name, Gfdv3d_name_src='default'):
self.plot_attributes['name'] = self.g_name
self.plot_attributes['template'] = Gfdv3d_name


def setProvenanceHandler(self, provenanceHandler):
self.provenanceHandler = provenanceHandler

Expand Down
3 changes: 2 additions & 1 deletion Packages/vcs/vcs/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import displayplot
import projection
import vcs
import vcsaddons

from error import vcsError

Expand All @@ -69,6 +68,7 @@ def isgraphicsmethod(gobj):
if vcs.isgraphicsmethod(box):
box.list()
"""
import vcsaddons
if (isinstance(gobj, boxfill.Gfb)):
return 1
elif (isinstance(gobj, isofill.Gfi)):
Expand Down Expand Up @@ -134,6 +134,7 @@ def graphicsmethodtype(gobj):
print vcs.graphicsmethodtype(ln) # Will print None, because ln is not a
# graphics method
"""
import vcsaddons
if (isinstance(gobj, boxfill.Gfb)):
return 'boxfill'
elif (isinstance(gobj, isofill.Gfi)):
Expand Down
3 changes: 2 additions & 1 deletion Packages/vcs/vcs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import json
import os
import tempfile
import vcsaddons
import cdms2
import genutil
import vtk
Expand Down Expand Up @@ -1616,6 +1615,7 @@ def monotonic(x):


def getgraphicsmethod(type, name):
import vcsaddons
if type == "default":
type = "boxfill"
if isinstance(type, vcsaddons.core.VCSaddon):
Expand All @@ -1630,6 +1630,7 @@ def getgraphicsmethod(type, name):


def creategraphicsmethod(gtype, gname='default', name=None):
import vcsaddons
if gtype in ['isoline', 'Gi']:
func = vcs.createisoline
elif gtype in ['isofill', 'Gfi']:
Expand Down
4 changes: 2 additions & 2 deletions Packages/vcs/vcs/vcs2vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,10 +1823,10 @@ def generateVectorArray(data1, data2, vtk_grid):

def vtkIterate(iterator):
iterator.InitTraversal()
obj = iterator.GetNextItem()
obj = iterator.GetNextItemAsObject()
while obj is not None:
yield obj
obj = iterator.GetNextItem()
obj = iterator.GetNextItemAsObject()


def getPlottingBounds(gmbounds, databounds, geo):
Expand Down
117 changes: 117 additions & 0 deletions Packages/vcsaddons/Lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,129 @@
gms = {}
import histograms
import polar
import EzTemplate
import yxvsxfill
import continents
import vcs


def createyxvsxfill(name=None,source='default',x=None,template=None):
return yxvsxfill.Gyf(name,source=source,x=x,template=template)


def createhistogram(name=None,source='default',x=None,template=None):
return histograms.Ghg(name,source=source,x=x,template=template)


def createusercontinents(name=None,source="default",x=None,template=None):
return continents.Guc(name,source=source,x=x,template=template)


def createpolar(name=None, source="default", x=None, template=None):
if "polar_oned" not in gms:
init_polar()
return polar.Gpo(name, source=source, x=x, template=template)


def getpolar(name=None):
if "polar_oned" not in gms:
init_polar()
if name in gms["polar_oned"]:
return gms["polar_oned"][name]
raise KeyError("No Polar GM exists with name '%s'" % name)


def init_polar():
# Create nice polar template
try:
t = vcs.createtemplate("polar_oned")
t.data.x1 = .2
t.data.x2 = .8
t.data.y1 = .2
t.data.y2 = .8

t.legend.x1 = .85
t.legend.x2 = 1
t.legend.y1 = .15
t.legend.y2 = .85

dash = vcs.createline()
dash.type = "dash"
dot = vcs.createline()
dot.type = "dot"
t.xtic1.line = dash
t.ytic1.line = dot

left_aligned = vcs.createtextorientation()
left_aligned.halign = "left"
left_aligned.valign = "half"
t.legend.textorientation = left_aligned
except vcs.vcsError:
# Template already exists
pass
# Create some nice default polar GMs
degree_polar = polar.Gpo("degrees", template="polar_oned")
degree_polar.datawc_x1 = 0
degree_polar.datawc_x2 = 360
degree_polar.xticlabels1 = {
i: str(i) for i in range(0, 360, 45)
}

clock_24 = polar.Gpo("diurnal", template="polar_oned")
clock_24.datawc_x1 = 0
clock_24.datawc_x2 = 24
clock_24.clockwise = True
# 6 AM on the right
clock_24.theta_offset = -6
clock_24.xticlabels1 = {
i: str(i) for i in range(0, 24, 3)
}

clock_24_meridiem = polar.Gpo("diurnal_12_hour", source="diurnal", template="polar_oned")
clock_24_meridiem.xticlabels1 = {
0: "12 AM",
3: "3 AM",
6: "6 AM",
9: "9 AM",
12: "12 PM",
15: "3 PM",
18: "6 PM",
21: "9 PM"
}

clock_12 = polar.Gpo("semidiurnal", source="diurnal", template="polar_oned")
clock_12.datawc_x2 = 12
clock_12.xticlabels1 = {
i: str(i) for i in range(3, 13, 3)
}
# 3 on the right
clock_12.theta_offset = -3

annual_cycle = polar.Gpo("annual_cycle", template="polar_oned")
annual_cycle.datawc_x1 = 1
annual_cycle.datawc_x2 = 13
annual_cycle.clockwise = True
annual_cycle.xticlabels1 = {
1: "Jan",
2: "Feb",
3: "Mar",
4: "Apr",
5: "May",
6: "Jun",
7: "Jul",
8: "Aug",
9: "Sep",
10: "Oct",
11: "Nov",
12: "Dec"
}
# Put December on the top
annual_cycle.theta_offset = -2

seasonal = polar.Gpo("seasonal", template="polar_oned")
seasonal.datawc_x1 = 0
seasonal.datawc_x2 = 4
seasonal.xticlabels1 = {0: "DJF", 1: "MAM", 2: "JJA", 3: "SON"}
seasonal.clockwise = True
# DJF on top
seasonal.theta_offset = -1
Loading

0 comments on commit cc0a870

Please sign in to comment.