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

Continents & Continent Lines #1678

Merged
merged 8 commits into from
Nov 17, 2015
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
11 changes: 5 additions & 6 deletions CMake/cdat_modules_extra/curses_patch_step.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
execute_process(
WORKING_DIRECTORY @curses_source@
COMMAND patch -Np1
INPUT_FILE @cdat_CMAKE_SOURCE_DIR@/curses_gcc5.patch
)

execute_process(
WORKING_DIRECTORY @curses_source@
COMMAND patch -Np1
INPUT_FILE @cdat_CMAKE_SOURCE_DIR@/curses_gcc5.patch
)
7 changes: 3 additions & 4 deletions CMake/curses_gcc5.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ index d8cc3c9..b91398c 100755
--- a/ncurses/base/MKlib_gen.sh
+++ b/ncurses/base/MKlib_gen.sh
@@ -491,11 +492,22 @@ sed -n -f $ED1 \
-e 's/gen_$//' \
-e 's/ / /g' >>$TMP
-e 's/gen_$//' \
-e 's/ / /g' >>$TMP

+cat >$ED1 <<EOF
+s/ / /g
+s/^ //
Expand All @@ -28,4 +28,3 @@ index d8cc3c9..b91398c 100755
| $AWK -f $AW2 \
| sed -f $ED3 \
| sed \

1 change: 0 additions & 1 deletion Packages/cdms2/Lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,3 @@
from restApi import esgfConnection,esgfDataset,FacetConnection

MV = MV2

2 changes: 1 addition & 1 deletion Packages/cdms2/Lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def setNetcdfUseParallelFlag(value):
if not MPI.Is_initialized():
MPI.Init()
rk = MPI.COMM_WORLD.Get_rank()

def getMpiRank():
''' Return number of processor available '''
if CdMpi:
Expand Down
1 change: 0 additions & 1 deletion Packages/regrid2/Lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@
ESMP_HAS_BEEN_INITIALIZED = True
except:
pass

146 changes: 74 additions & 72 deletions Packages/vcs/Lib/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ class Canvas(object):
'__last_plot_actual_args',
'__last_plot_keyargs',
'_continents',
'_continents_line',
'_savedcontinentstype',
'__weakref__',
]
Expand Down Expand Up @@ -798,14 +799,12 @@ def _reconstruct_tv(self, arglist, keyargs):
# Draw continental outlines if specified.
contout = keyargs.get('continents', None)
if contout is None:
# if xdim>=0 and ydim>=0 and isgridded:
# Charles put back the self.isplottinggridded in addition for
# meshfill,
if (xdim >= 0 and ydim >= 0 and tv.getAxis(xdim).isLongitude()
and tv.getAxis(ydim).isLatitude()) or (self.isplottinggridded):
contout = 1
else:
contout = 0

if (isinstance(arglist[GRAPHICS_METHOD], str) and (arglist[GRAPHICS_METHOD]) == 'meshfill') or (
(xdim >= 0 and ydim >= 0 and (contout >= 1) and (contout < 12))):
self.setcontinentstype(contout)
Expand Down Expand Up @@ -949,6 +948,7 @@ def __init__(self, gui=0, mode=1, pause_time=0,
self._animate = self.backend.Animate(self)

self.configurator = None
self.setcontinentsline("default")

# Initial.attributes is being called in main.c, so it is not needed here!
# Actually it is for taylordiagram graphic methods....
Expand Down Expand Up @@ -2240,7 +2240,7 @@ def drawtextcombined(self, Tt_name=None, To_name=None, string=None,
'xbounds', 'ybounds', 'xname', 'yname', 'xunits', 'yunits', 'xweights', 'yweights',
'comment1', 'comment2', 'comment3', 'comment4', 'hms', 'long_name', 'zaxis',
'zarray', 'zname', 'zunits', 'taxis', 'tarray', 'tname', 'tunits', 'waxis', 'warray',
'wname', 'wunits', 'bg', 'ratio', 'donotstoredisplay', 'render']
'wname', 'wunits', 'bg', 'ratio', 'donotstoredisplay', 'render', 'continents_line']

# def replot(self):
# """ Clears and plots with last used plot arguments
Expand Down Expand Up @@ -2386,8 +2386,17 @@ def plot(self, *actual_args, **keyargs):
except:
pass

if "continents_line" in keyargs:
# Stash the current line type
old_line = self.getcontinentsline()
self.setcontinentsline(keyargs["continents_line"])

# Plot the data
a = self.__plot(arglist, keyargs)

if "continents_line" in keyargs:
# Restore the canvas line type
self.setcontinentsline(old_line)
return a
plot.__doc__ = plot.__doc__ % (plot_2_1D_options,
plot_keywords_doc,
Expand Down Expand Up @@ -3452,6 +3461,8 @@ def set_convert_labels(copy_mthd, test=0):
t.plot(arglist[0], canvas=self, template=arglist[2], **keyargs)
nm, src = self.check_name_source(None, "default", "display")
dn = displayplot.Dp(nm)
dn.continents = self.getcontinentstype()
dn.continents_line = self.getcontinentsline()
dn.template = arglist[2]
dn.g_type = arglist[3]
dn.g_name = arglist[4]
Expand Down Expand Up @@ -3668,7 +3679,7 @@ def set_convert_labels(copy_mthd, test=0):
if hasattr(self, '_isplottinggridded'):
del(self._isplottinggridded)
# Get the continents for animation generation
self.animate.continents_value = self.getcontinentstype()
self.animate.continents_value = self._continentspath()

# Get the option for doing graphics in the background.
if bg:
Expand Down Expand Up @@ -3720,6 +3731,8 @@ def set_convert_labels(copy_mthd, test=0):
if dn is not None:
dn._template_origin = template_origin
dn.ratio = Doratio
dn.continents = self.getcontinentstype()
dn.continents_line = self.getcontinentsline()
dn.newelements = self.__new_elts(original_elts, new_elts)

if self.mode != 0:
Expand Down Expand Up @@ -4211,8 +4224,8 @@ def getcontinentstype(self, *args):
Function: getcontinentstype

Description of Function:
Retrieve continents type from VCS. Remember the value can only be between
0 and 11.
Retrieve continents type from VCS; either an integer between 0 and 11 or the
path to a custom continentstype.

Example of Use:
a=vcs.init()
Expand Down Expand Up @@ -5231,9 +5244,41 @@ def setcolorcell(self, *args):
return a

##########################################################################
# #
# Set continents type wrapper for VCS. #
# #
# #
# Set continents line wrapper for VCS. #
# #
##########################################################################
def setcontinentsline(self, line="default"):
"""
Function: setcontinentsline

Description of Function:
One has the option of configuring the appearance of the lines used to
draw continents by providing a VCS Line object.

Example of Use:
a = vcs.init()
line = vcs.createline()
line.width = 5
# Use custom continents line
a.setcontinentsline(line)
# Use default line
a.setcontinentsline("default")
"""
linename = VCS_validation_functions.checkLine(self, "continentsline", line)
line = vcs.getline(linename)
self._continents_line = line

def getcontinentsline(self):
if self._continents_line is None:
return vcs.getline("default")
else:
return self._continents_line

##########################################################################
# #
# Set continents type wrapper for VCS. #
# #
##########################################################################
def setcontinentstype(self, value):
"""
Expand All @@ -5253,79 +5298,36 @@ def setcontinentstype(self, value):
4 signifies "Political Borders" (with "Fine Continents")
5 signifies "Rivers" (with "Fine Continents")

Values 6 through 11 signify the line type defined by the files
data_continent_other7 through data_continent_other12.
6 uses a custom continent set

You can also pass a file
You can also pass a file by path.

Example of Use:
a=vcs.init()
a.setcontinentstype(3)
#a.setcontinentstype(os.environ["HOME"]+"/.uvcdat/data_continents_states")
a.plot(array,'default','isofill','quick')
"""
nms = [
"fine",
"coarse",
"states",
"political",
"river",
"other6",
"other7",
"other8",
"other9",
"other10",
"other11",
"other12"]
if isinstance(value, int):
if value == 0:
self._continents = None
elif 0 < value < 12:
self._continents = os.path.join(
os.environ.get(
"HOME",
""),
os.environ.get(
vcs.getdotdirectory()[1],
vcs.getdotdirectory()[0]),
"data_continent_%s" % nms[
value - 1])
if not os.path.exists(self._continents):
# fallback on installed with system one
self._continents = os.path.join(
vcs.prefix,
"share",
"vcs",
"data_continent_%s" % nms[
value - 1])
else:
raise Exception(
"Error continents value must be file or int < 12")
elif isinstance(value, str):
self._continents = value
else:
self._continents = None
if self._continents is not None and not os.path.exists(
self._continents):
continent_path = VCS_validation_functions.checkContinents(self, value)
self._continents = value
if continent_path is not None and not os.path.exists(
continent_path):
warnings.warn(
"Continents file not found: %s, substituing with coarse continents" %
self._continents)
self._continents = os.path.join(
os.environ.get(
"HOME",
""),
os.environ.get(
vcs.getdotdirectory()[1],
vcs.getdotdirectory()[0]),
"data_continent_coarse")
if not os.path.exists(self._continent):
self._continents = os.path.join(
vcs.prefix,
"share",
"vcs",
"data_continent_coarse")
"Continents file not found: %s, substituing with fine continents" %
continent_path)
self._continents = 1
return

def _continentspath(self):
try:
path = VCS_validation_functions.checkContinents(self, self._continents)
if path is None and self._continents != 0:
return VCS_validation_functions.checkContinents(self, 1)
else:
return path
except:
return VCS_validation_functions.checkContinents(self, 1)

##########################################################################
# #
# Screen GIF wrapper for VCS. #
Expand Down
38 changes: 38 additions & 0 deletions Packages/vcs/Lib/VCS_validation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,44 @@ def checkElements(self, name, value, function):
return value


def checkContinents(self, value):
import os
nms = [
"fine",
"coarse",
"states",
"political",
"river",
"other7"]
path = None
if isinstance(value, int):
if value == 0:
path = None
elif 0 < value < 7:
path = os.path.join(
os.environ.get(
"HOME",
""),
os.environ.get(
vcs.getdotdirectory()[1],
vcs.getdotdirectory()[0]),
"data_continent_%s" % nms[
value - 1])
if not os.path.exists(path):
# fallback on installed with system one
path = os.path.join(
vcs.prefix,
"share",
"vcs",
"data_continent_%s" % nms[
value - 1])
else:
raise ValueError("Continents value must be file or int < 12")
else:
path = value
return path


def checkContType(self, name, value):
checkName(self, name, value)
checkInt(self, name, value, minvalue=0)
Expand Down
32 changes: 26 additions & 6 deletions Packages/vcs/Lib/VTKPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,14 @@ def configureEvent(self, obj, ev):
parg.append(d.g_type)
parg.append(d.g_name)
plots_args.append(parg)
kwarg = {}
if d.ratio is not None:
key_args.append({"ratio": d.ratio})
else:
key_args.append({})
kwarg["ratio"] = d.ratio

kwarg["continents"] = d.continents
kwarg["continents_line"] = d.continents_line

key_args.append(kwarg)

# Have to pull out the UI layer so it doesn't get borked by the clear
self.hideGUI()
Expand Down Expand Up @@ -661,15 +665,15 @@ def onClosing(self, cell):
plot.onClosing(cell)

def plotContinents(self, x1, x2, y1, y2, projection, wrap, tmpl):
contData = vcs2vtk.prepContinents(self.canvas._continents)
contData = vcs2vtk.prepContinents(self.canvas._continentspath())
contMapper = vtk.vtkPolyDataMapper()
contMapper.SetInputData(contData)
contActor = vtk.vtkActor()
contActor.SetMapper(contMapper)
contActor.GetProperty().SetColor(0., 0., 0.)
contActor = vcs2vtk.doWrap(
contActor, [
x1, x2, y1, y2], wrap, fastClip=False)

if projection.type != "linear":
contData = contActor.GetMapper().GetInput()
cpts = contData.GetPoints()
Expand All @@ -679,10 +683,26 @@ def plotContinents(self, x1, x2, y1, y2, projection, wrap, tmpl):
contMapper.SetInputData(contData)
contActor = vtk.vtkActor()
contActor.SetMapper(contMapper)
contActor.GetProperty().SetColor(0., 0., 0.)
else:
geo = None

contLine = self.canvas.getcontinentsline()
line_prop = contActor.GetProperty()

# Width
line_prop.SetLineWidth(contLine.width[0])

# Color
if contLine.colormap:
cmap = vcs.getcolormap(contLine.colormap)
else:
cmap = self.canvas.getcolormap()
color = [c / 100. for c in cmap.index[contLine.color[0]]]
line_prop.SetColor(*color)

# Stippling
vcs2vtk.stippleLine(line_prop, contLine.type[0])

self.fitToViewport(contActor,
[tmpl.data.x1, tmpl.data.x2,
tmpl.data.y1, tmpl.data.y2],
Expand Down
Loading