Skip to content

Commit

Permalink
Merge pull request #1296 from UV-CDAT/sync_master
Browse files Browse the repository at this point in the history
Sync master
  • Loading branch information
aashish24 committed May 8, 2015
2 parents 538cf4b + 8a9b545 commit b14e373
Show file tree
Hide file tree
Showing 29 changed files with 514 additions and 105 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
os:
- linux
- osx
# - osx

language: c++

Expand Down
2 changes: 1 addition & 1 deletion CMake/cdat_modules/cdat_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(CDAT_deps ${wget_pkg} ${python_pkg} ${numpy_pkg}
${libcdms_pkg}
${libcf_pkg} ${netcdf_pkg} ${myproxyclient_pkg} ${udunits2_pkg})
if (CDAT_BUILD_GRAPHICS)
if (CDAT_BUILD_PARALLEL)
if (CDAT_BUILD_PARAVIEW)
list(APPEND CDAT_deps ${paraview_pkg})
else()
list(APPEND CDAT_deps ${vtk_pkg})
Expand Down
4 changes: 4 additions & 0 deletions CMake/cdat_modules_extra/runtest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
# source is not portable whereas . is
. "@CMAKE_INSTALL_PREFIX@/bin/setup_runtime.sh"
python@PYVER@ "$@"
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ option(CDAT_BUILD_GUI "Builds GUI-based dependencies (Vistrails, ParaView, VisIt
option(CDAT_BUILD_GRAPHICS "Build graphics-based dependencies (vcs, pyqt, Vistrails, ParaView, VisIt, R, etc.) " ON)
option(CDAT_BUILD_ESGF "Alias for CDAT_BUILD_LEAN" OFF)
option(CDAT_BUILD_UVCMETRICSPKG "Builds uvcmetrics package " ON)
option(CDAT_BUILD_PARAVIEW "Build ParaView rather than just VTK" OFF)

# If ESGF option is on then our build mode is LEAN.
if (CDAT_BUILD_ESGF)
Expand Down Expand Up @@ -498,7 +499,7 @@ include(osmesa_pkg)
include(python_pkg)
include(seawater_pkg)
include(vacumm_pkg)
if (CDAT_BUILD_PARALLEL)
if (CDAT_BUILD_PARAVIEW)
include(paraview_pkg)
else()
include(vtk_pkg)
Expand Down Expand Up @@ -729,6 +730,11 @@ configure_file(${cdat_CMAKE_SOURCE_DIR}/cdat_modules_extra/cdat.in
@ONLY
)

configure_file(${cdat_CMAKE_SOURCE_DIR}/cdat_modules_extra/runtest.in
${CMAKE_INSTALL_PREFIX}/bin/runtest
@ONLY
)


if (BUILD_TESTING)
configure_file(${cdat_CMAKE_SOURCE_DIR}/cdat_modules_extra/runpytest.in
Expand Down
101 changes: 67 additions & 34 deletions Packages/DV3D/MultiVarPointCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def getCoordIndex( self, var, coord ):
return axis_order.index(coord)
except ValueError, err:
print>>sys.stderr, "Can't find axis %s in axis order spec '%s' " % ( coord, axis_order )
return None


def getCoordDataBlock( self, var ):
Expand All @@ -109,42 +110,74 @@ def getCoordDataBlock( self, var ):
def getDataBlock( self, var ):
np_var_data_block = None
iTimeIndex = self.getCoordIndex( var, 't' )
if iTimeIndex <> 0:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
else:
if self.lev == None:
if len( var.shape ) == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep ].data
if self.roi_mask <> None:
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block )
elif len( var.shape ) == 3:
np_var_data_block = var[ self.iTimeStep, :, self.istart::self.istep ].data
np_var_data_block = np_var_data_block.reshape( [ np_var_data_block.shape[0] * np_var_data_block.shape[1], ] )
self.nLevels = 1
try:
if iTimeIndex > 0:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
elif iTimeIndex is None:
if self.lev == None:
if len( var.shape ) == 1:
np_var_data_block = var[ self.istart::self.istep ].data
if self.roi_mask <> None:
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block )
elif len( var.shape ) == 2:
np_var_data_block = var[ :, self.istart::self.istep ].data
np_var_data_block = np_var_data_block.reshape( [ np_var_data_block.shape[0] * np_var_data_block.shape[1], ] )
self.nLevels = 1
else:
iLevIndex = self.getCoordIndex( var, 'z' )
if len( var.shape ) == 2:
if iLevIndex == 0:
np_var_data_block = var[ :, self.istart::self.istep ].data
elif iLevIndex == 1:
np_var_data_block = var[ self.istart::self.istep, : ].data
np_var_data_block = numpy.swapaxes( np_var_data_block, 0, 1 )
else:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
if not isNone( np_var_data_block ):
if not isNone( self.roi_mask ):
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block, axis = 1 )
elif len( var.shape ) == 3:
lev_data_arrays = []
for ilev in range( var.shape[1] ):
data_z_slice = var[ ilev ].flatten()
lev_data_arrays.append( data_z_slice[self.istart::self.istep] )
np_var_data_block = numpy.concatenate( lev_data_arrays ).astype( numpy.float32 )
else:
iLevIndex = self.getCoordIndex( var, 'z' )
if len( var.shape ) == 3:
if iLevIndex == 1:
if self.lev == None:
if len( var.shape ) == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep ].data
if self.roi_mask <> None:
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block )
elif len( var.shape ) == 3:
np_var_data_block = var[ self.iTimeStep, :, self.istart::self.istep ].data
elif iLevIndex == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep, : ].data
np_var_data_block = numpy.swapaxes( np_var_data_block, 0, 1 )
else:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
if not isNone( np_var_data_block ):
if not isNone( self.roi_mask ):
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block, axis = 1 )
elif len( var.shape ) == 4:
lev_data_arrays = []
for ilev in range( var.shape[1] ):
data_z_slice = var[ self.iTimeStep, ilev ].flatten()
lev_data_arrays.append( data_z_slice[self.istart::self.istep] )
np_var_data_block = numpy.concatenate( lev_data_arrays ).astype( numpy.float32 )
# print " GetDataBlock, var.shape = %s, grid = %s, ts = %d, newshape = %s, type = %s " % ( str(var.shape), str((self.istart,self.istep)), self.iTimeStep, str(np_var_data_block.shape), np_var_data_block.__class__.__name__ )

if not isNone( np_var_data_block ):
if self.missing_value: np_var_data_block = numpy.ma.masked_equal( np_var_data_block, self.missing_value, False ).flatten()
else: np_var_data_block = np_var_data_block.flatten()
np_var_data_block = np_var_data_block.reshape( [ np_var_data_block.shape[0] * np_var_data_block.shape[1], ] )
self.nLevels = 1
else:
iLevIndex = self.getCoordIndex( var, 'z' )
if len( var.shape ) == 3:
if iLevIndex == 1:
np_var_data_block = var[ self.iTimeStep, :, self.istart::self.istep ].data
elif iLevIndex == 2:
np_var_data_block = var[ self.iTimeStep, self.istart::self.istep, : ].data
np_var_data_block = numpy.swapaxes( np_var_data_block, 0, 1 )
else:
print>>sys.stderr, "Unimplemented axis order: %s " % var.getOrder()
if not isNone( np_var_data_block ):
if not isNone( self.roi_mask ):
np_var_data_block = numpy.compress( self.roi_mask, np_var_data_block, axis = 1 )
elif len( var.shape ) == 4:
lev_data_arrays = []
for ilev in range( var.shape[1] ):
data_z_slice = var[ self.iTimeStep, ilev ].flatten()
lev_data_arrays.append( data_z_slice[self.istart::self.istep] )
np_var_data_block = numpy.concatenate( lev_data_arrays ).astype( numpy.float32 )
except Exception, err:
print " Error in GetDataBlock, var.shape = %s, grid = %s, ts = %d " % ( str(var.shape), str((self.istart,self.istep)), self.iTimeStep )
print str(err)

if not isNone( np_var_data_block ):
if self.missing_value: np_var_data_block = numpy.ma.masked_equal( np_var_data_block, self.missing_value, False ).flatten()
else: np_var_data_block = np_var_data_block.flatten()

return np_var_data_block

Expand Down
11 changes: 5 additions & 6 deletions Packages/DV3D/StructuredVariableReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from StructuredDataset import *

def getVarName( var ):
if hasattr( var,'outvar'): return var.outvar.name
if hasattr( var,'name'): return var.name
if hasattr( var,'name_in_file'): return var.name_in_file
if hasattr( var,'id'): return var.id
Expand Down Expand Up @@ -110,10 +109,10 @@ def __init__(self, **args):
self.varSpecs = [ var.name_in_file for var in self.vars ]
self.df = cdms2.open( self.fileSpecs )
else:
self.varSpecs = [ var.name for var in self.vars ]
self.varSpecs = [ var.id for var in self.vars ]
plot_attributes = args.get( 'plot_attributes', None )
if plot_attributes <> None:
self.datasetId = plot_attributes.get( 'filename', self.vars[0].name )
self.datasetId = plot_attributes.get( 'filename', self.vars[0].id )
for file_attribute_name in ['url', 'filename', 'file' ]:
self.fileSpecs = plot_attributes.get( file_attribute_name, None )
if self.fileSpecs <> None: break
Expand All @@ -122,8 +121,8 @@ def __init__(self, **args):
print>>sys.stderr, "Warning, can't open data file '%s'" % self.fileSpecs
self.df = None
else:
self.datasetId = self.vars[0].name
self.fileSpecs = self.vars[0].name
self.datasetId = self.vars[0].id
self.fileSpecs = self.vars[0].id
self.df = None

self.referenceTimeUnits = None
Expand Down Expand Up @@ -371,7 +370,7 @@ def getPortData( self, **args ):

def generateVariableOutput( self, cdms_var ):
print str(cdms_var.var)
self.set3DOutput( name=cdms_var.name, output=cdms_var.var )
self.set3DOutput( name=cdms_var.id, output=cdms_var.var )

def refreshVersion(self):
portData = self.getPortData()
Expand Down
16 changes: 16 additions & 0 deletions Packages/DV3D/demo/demo_plots/gallery_vector_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import vcs, cdms2, sys

x = vcs.init()
f = cdms2.open( sys.prefix+"/sample_data/geos5-sample.nc" )
dv3d = vcs.get3d_vector()
dv3d.VerticalScaling = 4.0
dv3d.BasemapOpacity = 0.5
dv3d.ScaleColormap = [50.0, 75.0, 1]
dv3d.ZSlider = [26.0], vcs.on
dv3d.GlyphDensity = 3.0
dv3d.GlyphSize = 0.6
dv3d = vcs.get3d_vector()
v0 = f["uwnd"]
v1 = f["vwnd"]
x.plot( v0, v1, dv3d )
x.interact()
6 changes: 3 additions & 3 deletions Packages/cdms2/Lib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def setNetcdfDeflateFlag(value):
def setNetcdfDeflateLevelFlag(value):
""" Sets NetCDF deflate level flag value"""
if value not in [0,1,2,3,4,5,6,7,8,9]:
raise CDMSError, "Error NetCDF deflate_level flag must be an integer < 10"
raise CDMSError("Error NetCDF deflate_level flag must be an integer < 10")
Cdunif.CdunifSetNCFLAGS("deflate_level",value)

def getNetcdfClassicFlag():
Expand Down Expand Up @@ -245,14 +245,14 @@ def openDataset(uri,mode='r',template=None,dods=1,dpath=None, hostObj=None):
file = CdmsFile(uri,mode)
return file
except:
raise CDMSError("Error in DODS open of: ",uri)
raise CDMSError("Error in DODS open of: "+uri)
else:
try:
datanode = loadURI(uri)
return datanode
except:
datanode = loadURI(uri)
raise CDMSError("Error in loadURI of: ",uri)
raise CDMSError("Error in loadURI of: "+uri)

else:
raise SchemeNotSupported(scheme)
Expand Down
4 changes: 2 additions & 2 deletions Packages/vcs/Lib/Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2727,11 +2727,11 @@ def __plot (self, arglist, keyargs):
xs=arglist[0].getAxis(-1)
ys=arglist[0].getAxis(-2)
if xs.isLongitude() and ys.isLatitude() and isinstance(inGrid,cdms2.grid.TransientRectGrid):
arglist[1]=MV2.array(g.getMesh())
arglist[1]=MV2.array(inGrid.getMesh())
if not 'wrap' in keyargs.keys():
keyargs['wrap']=[0.,360.]
elif ys.isLongitude() and xs.isLatitude() and isinstance(inGrid,cdms2.grid.TransientRectGrid):
arglist[1]=MV2.array(g.getMesh())
arglist[1]=MV2.array(inGrid.getMesh())
if not 'wrap' in keyargs.keys():
keyargs['wrap']=[360.,0.]
else:
Expand Down
2 changes: 2 additions & 0 deletions Packages/vcs/Lib/VTKPlots.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ def hideGUI(self):
if manager_exists(self.renWin.GetInteractor()):
manager = get_manager(self.renWin.GetInteractor())
self.renWin.RemoveRenderer(manager.renderer)
self.renWin.RemoveRenderer(manager.actor_renderer)

def showGUI(self, render=True):
plot = self.get3DPlot()
Expand All @@ -764,6 +765,7 @@ def showGUI(self, render=True):
if manager_exists(self.renWin.GetInteractor()):
manager = get_manager(self.renWin.GetInteractor())
self.renWin.AddRenderer(manager.renderer)
self.renWin.AddRenderer(manager.actor_renderer)
# Bring the manager's renderer to the top of the stack
manager.elevate()
if render:
Expand Down
4 changes: 2 additions & 2 deletions Packages/vcs/Lib/colorpicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def cancel(self, state):
self.close()

def selectCell(self, cellId):
if cellId == -1:
if cellId in (None, -1):
return
ids = vtk.vtkIdTypeArray();
ids.SetNumberOfComponents(1);
Expand Down Expand Up @@ -152,7 +152,7 @@ def clickEvent(self, obj, event):

x, y = inter.GetEventPosition()

renderer = self.topRendererAtPoint(x, y)
renderer = self.color_renderer

if renderer:
picker = vtk.vtkCellPicker()
Expand Down
3 changes: 2 additions & 1 deletion Packages/vcs/Lib/dv3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def list(self):
print 'name =',self.name
print 'axes =',self.axes
for pname in self.parameter_names:
print ' = '.join( [ pname, self.getParameter( pname ) ] )
pval = self.getParameter( pname )
print pname,'=',repr(pval)

class Gf3Dvector(Gfdv3d):

Expand Down
17 changes: 11 additions & 6 deletions Packages/vcs/Lib/vtk_ui/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,20 @@ def add_state(self, label=None, image=None, bgcolor=None, fgcolor=None, opacity=
self.states.append(ButtonState(label=label, image=image, bgcolor=bgcolor, fgcolor=fgcolor, opacity=opacity))

def place(self):

width, height = self.get_dimensions()
x, y = self.get_position()
bounds = (x, x + width, y - height, y, 0, 0)

self.repr.SetPlaceFactor(1)
self.repr.PlaceWidget(bounds)
self.repr.Modified()
if self.showing():
# This One Weird Hack will make your Buttons Go In the Right Place - Developers hate it!
# Buttons weren't always getting properly placed (toolbars in toolbars being the canonical example)
# This makes them show up correctly. Weird, but it works.
h_state = self.repr.GetHighlightState()
self.repr.Highlight((h_state + 1) % 3)
self.repr.Highlight(h_state)

text_width, text_height = self.text_widget.get_dimensions()
swidth, sheight = self.interactor.GetRenderWindow().GetSize()
Expand Down Expand Up @@ -289,7 +297,7 @@ def in_bounds(self, x, y):
def __advance__(self, point):
state = self.repr.GetState()
self.set_state( (state + 1) % len(self.states) )
#self.clicked(self.widget, "StateChangedEvent") Do we need to call this? I bet we don't.
self.clicked(self.widget, "StateChangedEvent")

def clicked(self, obj, event):
state = self.get_state()
Expand Down Expand Up @@ -332,10 +340,7 @@ def __init__(self, interactor, label, on=None, off=None, corner_radius=5, width=
self.label = label

def get_text(self):
if self.get_state() == 0:
return self.label.get_text()[len(on_prefix):]
else:
return self.label.get_text()[len(off_prefix):]
return self.label

def toggle(self, state):
if state == 1:
Expand Down
Loading

0 comments on commit b14e373

Please sign in to comment.