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

Vcsaddons histo polar #2025

Merged
merged 27 commits into from
Jun 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
10e92c0
Made VCSAddon be a new-style object
Jan 26, 2016
ffe9cff
Flake8'd
Jan 26, 2016
26031e3
Made histogram work and display variance; needs to be cleaned up
Feb 5, 2016
53f54df
Adjusted y scale
Feb 8, 2016
5102300
Fixed vcsaddons to use display plots correctly
Feb 9, 2016
5774998
Added legend, removed print, fixed the attr lengths
Feb 10, 2016
3af99c7
Finishing touch-ups on histo
Feb 10, 2016
4c0e5d7
Made the axis be labeled correctly
Feb 12, 2016
60d6449
Harden histogram a bit
May 12, 2016
182aa07
Merged master
May 12, 2016
ce13552
Added some new tests
May 16, 2016
a5bc559
Fixed some group name retrieval bugs, added colormap support, better …
May 19, 2016
0376fde
Moved vcsaddons imports into functions, to prevent circular dependenc…
May 20, 2016
732c876
Finished polar, added some convenient defaults for it
May 20, 2016
022a3aa
Added tests for polar
May 20, 2016
9835393
Merge branch 'master' into vcsaddons_histo_polar
May 27, 2016
a90268e
Fixed memory leak, added mintic
May 31, 2016
b95883e
Renamed to match scheme
May 31, 2016
6f7c191
Converted to using new testing.regression module
May 31, 2016
d42b63e
Merge branch 'master' of github.com:uv-cdat/uvcdat into vcsaddons_his…
May 31, 2016
8c8aef6
Merge branch 'master' of github.com:uv-cdat/uvcdat into vcsaddons_his…
May 31, 2016
541a590
falke8
Jun 8, 2016
b88ea73
flake8 tests
Jun 8, 2016
ecb985b
Merge branch 'master' into vcsaddons_histo_polar
Jun 10, 2016
64f378e
Fixed style issues
aashish24 Jun 11, 2016
fb306a3
Fixed failing tests
Jun 10, 2016
c0ddfc1
Fixed another failing test
aashish24 Jun 11, 2016
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
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