Skip to content

Commit

Permalink
Merge pull request #1951 from UV-CDAT/cdat-web-plot-subsetting
Browse files Browse the repository at this point in the history
Cdat web plot subsetting
  • Loading branch information
doutriaux1 authored Jun 22, 2016
2 parents 818bcdf + 936600f commit d5537f6
Show file tree
Hide file tree
Showing 46 changed files with 7,051 additions and 6,110 deletions.
425 changes: 217 additions & 208 deletions Packages/cdms2/Lib/CDML.py

Large diffs are not rendered by default.

189 changes: 105 additions & 84 deletions Packages/cdms2/Lib/CDMLParser.py

Large diffs are not rendered by default.

524 changes: 320 additions & 204 deletions Packages/cdms2/Lib/MV2.py

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions Packages/cdms2/Lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
CDMS module-level API
"""
import cdat_info
cdat_info.pingPCMDIdb("cdat","cdms2")
cdat_info.pingPCMDIdb("cdat", "cdms2")

__all__ = ["cdmsobj", "axis", "coord", "grid", "hgrid", "avariable", \
"sliceut", "error", "variable", "fvariable", "tvariable", "dataset", \
"database", "cache", "selectors", "MV2", "convention", "bindex", \
"auxcoord", "gengrid", "gsHost", "gsStaticVariable", "gsTimeVariable", \
"mvBaseWriter", "mvSphereMesh", "mvVsWriter", "mvCdmsRegrid"]
__all__ = ["cdmsobj", "axis", "coord", "grid", "hgrid", "avariable",
"sliceut", "error", "variable", "fvariable", "tvariable", "dataset",
"database", "cache", "selectors", "MV2", "convention", "bindex",
"auxcoord", "gengrid", "gsHost", "gsStaticVariable", "gsTimeVariable",
"mvBaseWriter", "mvSphereMesh", "mvVsWriter", "mvCdmsRegrid"]

# Errors
from error import CDMSError
from .error import CDMSError

# CDMS datatypes
from cdmsobj import CdArray, CdChar, CdByte, CdDouble, CdFloat, CdFromObject, CdInt, CdLong, CdScalar, CdShort, CdString
from .cdmsobj import CdArray, CdChar, CdByte, CdDouble, CdFloat, CdFromObject, CdInt, CdLong, CdScalar, CdShort, CdString

# Functions which operate on all objects or groups of objects
from cdmsobj import Unlimited, getPathFromTemplate, matchPattern, matchingFiles, searchPattern, searchPredicate, setDebugMode
from .cdmsobj import Unlimited, getPathFromTemplate, matchPattern, matchingFiles, searchPattern, searchPredicate, setDebugMode

# Axis functions and classes
from axis import AbstractAxis, axisMatches, axisMatchAxis, axisMatchIndex
from axis import createAxis, createEqualAreaAxis, createGaussianAxis, createUniformLatitudeAxis, createUniformLongitudeAxis, setAutoBounds, getAutoBounds
from .axis import AbstractAxis, axisMatches, axisMatchAxis, axisMatchIndex
from .axis import createAxis, createEqualAreaAxis, createGaussianAxis, createUniformLatitudeAxis, createUniformLongitudeAxis, setAutoBounds, getAutoBounds

# Grid functions
from grid import createGenericGrid, createGlobalMeanGrid, createRectGrid, createUniformGrid, createZonalGrid, setClassifyGrids, createGaussianGrid, writeScripGrid, isGrid
from .grid import createGenericGrid, createGlobalMeanGrid, createRectGrid, createUniformGrid, createZonalGrid, setClassifyGrids, createGaussianGrid, writeScripGrid, isGrid

# Dataset functions
from dataset import createDataset, openDataset, useNetcdf3, \
getNetcdfClassicFlag, getNetcdfShuffleFlag, getNetcdfDeflateFlag, getNetcdfDeflateLevelFlag,\
from .dataset import createDataset, openDataset, useNetcdf3, \
getNetcdfClassicFlag, getNetcdfShuffleFlag, getNetcdfDeflateFlag, getNetcdfDeflateLevelFlag,\
setNetcdfClassicFlag, setNetcdfShuffleFlag, setNetcdfDeflateFlag, setNetcdfDeflateLevelFlag,\
setNetcdfUseNCSwitchModeFlag,getNetcdfUseNCSwitchModeFlag,\
setNetcdfUseNCSwitchModeFlag, getNetcdfUseNCSwitchModeFlag,\
setCompressionWarnings,\
setNetcdf4Flag, getNetcdf4Flag,\
setNetcdfUseParallelFlag, getNetcdfUseParallelFlag, \
Expand All @@ -39,31 +39,31 @@
open = openDataset

# Database functions
from database import connect, Base, Onelevel, Subtree
from .database import connect, Base, Onelevel, Subtree

#Selectors
import selectors
from selectors import longitude, latitude, time, level, required, \
longitudeslice, latitudeslice, levelslice, timeslice
# Selectors
from . import selectors
from .selectors import longitude, latitude, time, level, required, \
longitudeslice, latitudeslice, levelslice, timeslice

from avariable import order2index, orderparse, setNumericCompatibility, getNumericCompatibility
from .avariable import order2index, orderparse, setNumericCompatibility, getNumericCompatibility
# TV
from tvariable import asVariable, createVariable, isVariable
from .tvariable import asVariable, createVariable, isVariable

from mvSphereMesh import SphereMesh
from mvBaseWriter import BaseWriter
from mvVsWriter import VsWriter
from mvVTKSGWriter import VTKSGWriter
from mvVTKUGWriter import VTKUGWriter
from mvCdmsRegrid import CdmsRegrid
from .mvSphereMesh import SphereMesh
from .mvBaseWriter import BaseWriter
from .mvVsWriter import VsWriter
from .mvVTKSGWriter import VTKSGWriter
from .mvVTKUGWriter import VTKUGWriter
from .mvCdmsRegrid import CdmsRegrid

# Gridspec is not installed by default so just pass on if it isn't installed
try:
from gsStaticVariable import StaticFileVariable
from gsTimeVariable import TimeFileVariable
from .gsStaticVariable import StaticFileVariable
from .gsTimeVariable import TimeFileVariable
except:
pass

from restApi import esgfConnection,esgfDataset,FacetConnection
from .restApi import esgfConnection, esgfDataset, FacetConnection

MV = MV2
80 changes: 51 additions & 29 deletions Packages/cdms2/Lib/auxcoord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,62 +4,80 @@
Note: In contrast to Axis objects (concrete classes subclassed from AbstractAxis), auxiliary coordinate variables are not monotonic in value, and do not share a name with the dimension.
"""

## import internattr
from error import CDMSError
from coord import AbstractCoordinateAxis
from fvariable import FileVariable
from variable import DatasetVariable
from tvariable import TransientVariable
from avariable import AbstractVariable
# import internattr
from .error import CDMSError
from .coord import AbstractCoordinateAxis
from .fvariable import FileVariable
from .variable import DatasetVariable
from .tvariable import TransientVariable
from .avariable import AbstractVariable


class AbstractAuxAxis1D(AbstractCoordinateAxis):

def __init__ (self, parent=None, variableNode=None, bounds=None):
AbstractCoordinateAxis.__init__(self, parent, variableNode, bounds=bounds)
def __init__(self, parent=None, variableNode=None, bounds=None):
AbstractCoordinateAxis.__init__(
self,
parent,
variableNode,
bounds=bounds)

def clone (self, copyData=1):
def clone(self, copyData=1):
"""clone (self, copyData=1)
Return a copy of self as a transient axis.
If copyData is 1, make a separate copy of the data."""
result = TransientAuxAxis1D(self[:], copy=copyData, axes=self.getAxisList(), attributes=self.attributes, bounds=self.getBounds())
result = TransientAuxAxis1D(
self[:],
copy=copyData,
axes=self.getAxisList(),
attributes=self.attributes,
bounds=self.getBounds())
return result

def setBounds(self, bounds):
if bounds is not None:
if len(bounds.shape)!=2:
raise CDMSError, 'Bounds must have rank=2'
if bounds.shape[0:1]!=self.shape:
raise CDMSError, 'Bounds shape %s is inconsistent with axis shape %s'%(`bounds.shape`,`self.shape`)
if len(bounds.shape) != 2:
raise CDMSError('Bounds must have rank=2')
if bounds.shape[0:1] != self.shape:
raise CDMSError(
'Bounds shape %s is inconsistent with axis shape %s' %
(repr(bounds.shape), repr(self.shape)))
AbstractCoordinateAxis.setBounds(self, bounds)

def subSlice (self, *specs, **keys):
def subSlice(self, *specs, **keys):
# Take a subslice, returning a TransientAuxAxis1D
avar = AbstractVariable.subSlice(self, *specs, **keys)
bounds = self.getBounds()
if bounds is None:
newbounds = None
else:
newbounds = bounds[specs] # bounds can be a numarray or DatasetVariable
newbounds = bounds[
specs] # bounds can be a numarray or DatasetVariable

# Note: disable axis copy to preserve identity of grid and variable domains
result = TransientAuxAxis1D(avar, bounds=newbounds, copyaxes=0)
# Note: disable axis copy to preserve identity of grid and variable
# domains
result = TransientAuxAxis1D(avar, bounds=newbounds, copyaxes=0)
return result


class DatasetAuxAxis1D(AbstractAuxAxis1D, DatasetVariable):

# Note: node is a VariableNode

def __init__(self, parent, id=None, variableNode=None, bounds=None):
AbstractAuxAxis1D.__init__(self, parent, variableNode, bounds=bounds)
DatasetVariable.__init__(self, parent, id, variableNode)
self._data_ = None # Cached values

def __repr__(self):
if self.parent is not None:
return "<DatasetAuxAxis1D: %s, file: %s, shape: %s>"%(self.id, self.parent.id, `self.shape`)
return "<DatasetAuxAxis1D: %s, file: %s, shape: %s>" % (self.id, self.parent.id, repr(self.shape))
else:
return "<DatasetAuxAxis1D: %s, file: **CLOSED**>"%self.id
return "<DatasetAuxAxis1D: %s, file: **CLOSED**>" % self.id

# internattr.initialize_internal_attributes(DatasetAuxAxis1D) # Copy
# internal attrs from parents

## internattr.initialize_internal_attributes(DatasetAuxAxis1D) # Copy internal attrs from parents

class FileAuxAxis1D(AbstractAuxAxis1D, FileVariable):

Expand All @@ -70,27 +88,31 @@ def __init__(self, parent, id, obj=None, bounds=None):

def __repr__(self):
if self.parent is not None:
return "<FileAuxAxis1D: %s, file: %s, shape: %s>"%(self.id, self.parent.id, `self.shape`)
return "<FileAuxAxis1D: %s, file: %s, shape: %s>" % (self.id, self.parent.id, repr(self.shape))
else:
return "<FileAuxAxis1D: %s, file: **CLOSED**>"%self.id
return "<FileAuxAxis1D: %s, file: **CLOSED**>" % self.id

# internattr.initialize_internal_attributes(FileAuxAxis1D) # Copy internal
# attrs from parents

## internattr.initialize_internal_attributes(FileAuxAxis1D) # Copy internal attrs from parents

class TransientAuxAxis1D(AbstractAuxAxis1D, TransientVariable):

def __init__(self, data, typecode=None, copy=0, savespace=0, mask=None, fill_value=None,
def __init__(
self, data, typecode=None, copy=0, savespace=0, mask=None, fill_value=None,
axes=None, attributes=None, id=None, copyaxes=1, bounds=None):
"""Create a transient, auxiliary 1-D axis.
All arguments are as for TransientVariable.
'bounds' is the bounds array, having shape (m,nvert) where data.shape is (m,) and
nvert is the max number of vertices per cell.
"""
AbstractAuxAxis1D.__init__(self, None, None, bounds=bounds)
TransientVariable.__init__(self, data, typecode=typecode, copy=copy, savespace=savespace,
TransientVariable.__init__(
self, data, typecode=typecode, copy=copy, savespace=savespace,
mask=mask, fill_value=fill_value, axes=axes, attributes=attributes,
id=id, copyaxes=copyaxes)
if axes is not None:
self.setBounds(bounds)

## internattr.initialize_internal_attributes(TransientAuxAxis1D) # Copy internal attrs from parents

# internattr.initialize_internal_attributes(TransientAuxAxis1D) # Copy
# internal attrs from parents
Loading

0 comments on commit d5537f6

Please sign in to comment.