Skip to content

Commit d5537f6

Browse files
authored
Merge pull request #1951 from UV-CDAT/cdat-web-plot-subsetting
Cdat web plot subsetting
2 parents 818bcdf + 936600f commit d5537f6

46 files changed

Lines changed: 7051 additions & 6110 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Packages/cdms2/Lib/CDML.py

Lines changed: 217 additions & 208 deletions
Large diffs are not rendered by default.

Packages/cdms2/Lib/CDMLParser.py

Lines changed: 105 additions & 84 deletions
Large diffs are not rendered by default.

Packages/cdms2/Lib/MV2.py

Lines changed: 320 additions & 204 deletions
Large diffs are not rendered by default.

Packages/cdms2/Lib/__init__.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
CDMS module-level API
33
"""
44
import cdat_info
5-
cdat_info.pingPCMDIdb("cdat","cdms2")
5+
cdat_info.pingPCMDIdb("cdat", "cdms2")
66

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

1313
# Errors
14-
from error import CDMSError
14+
from .error import CDMSError
1515

1616
# CDMS datatypes
17-
from cdmsobj import CdArray, CdChar, CdByte, CdDouble, CdFloat, CdFromObject, CdInt, CdLong, CdScalar, CdShort, CdString
17+
from .cdmsobj import CdArray, CdChar, CdByte, CdDouble, CdFloat, CdFromObject, CdInt, CdLong, CdScalar, CdShort, CdString
1818

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

2222
# Axis functions and classes
23-
from axis import AbstractAxis, axisMatches, axisMatchAxis, axisMatchIndex
24-
from axis import createAxis, createEqualAreaAxis, createGaussianAxis, createUniformLatitudeAxis, createUniformLongitudeAxis, setAutoBounds, getAutoBounds
23+
from .axis import AbstractAxis, axisMatches, axisMatchAxis, axisMatchIndex
24+
from .axis import createAxis, createEqualAreaAxis, createGaussianAxis, createUniformLatitudeAxis, createUniformLongitudeAxis, setAutoBounds, getAutoBounds
2525

2626
# Grid functions
27-
from grid import createGenericGrid, createGlobalMeanGrid, createRectGrid, createUniformGrid, createZonalGrid, setClassifyGrids, createGaussianGrid, writeScripGrid, isGrid
27+
from .grid import createGenericGrid, createGlobalMeanGrid, createRectGrid, createUniformGrid, createZonalGrid, setClassifyGrids, createGaussianGrid, writeScripGrid, isGrid
2828

2929
# Dataset functions
30-
from dataset import createDataset, openDataset, useNetcdf3, \
31-
getNetcdfClassicFlag, getNetcdfShuffleFlag, getNetcdfDeflateFlag, getNetcdfDeflateLevelFlag,\
30+
from .dataset import createDataset, openDataset, useNetcdf3, \
31+
getNetcdfClassicFlag, getNetcdfShuffleFlag, getNetcdfDeflateFlag, getNetcdfDeflateLevelFlag,\
3232
setNetcdfClassicFlag, setNetcdfShuffleFlag, setNetcdfDeflateFlag, setNetcdfDeflateLevelFlag,\
33-
setNetcdfUseNCSwitchModeFlag,getNetcdfUseNCSwitchModeFlag,\
33+
setNetcdfUseNCSwitchModeFlag, getNetcdfUseNCSwitchModeFlag,\
3434
setCompressionWarnings,\
3535
setNetcdf4Flag, getNetcdf4Flag,\
3636
setNetcdfUseParallelFlag, getNetcdfUseParallelFlag, \
@@ -39,31 +39,31 @@
3939
open = openDataset
4040

4141
# Database functions
42-
from database import connect, Base, Onelevel, Subtree
42+
from .database import connect, Base, Onelevel, Subtree
4343

44-
#Selectors
45-
import selectors
46-
from selectors import longitude, latitude, time, level, required, \
47-
longitudeslice, latitudeslice, levelslice, timeslice
44+
# Selectors
45+
from . import selectors
46+
from .selectors import longitude, latitude, time, level, required, \
47+
longitudeslice, latitudeslice, levelslice, timeslice
4848

49-
from avariable import order2index, orderparse, setNumericCompatibility, getNumericCompatibility
49+
from .avariable import order2index, orderparse, setNumericCompatibility, getNumericCompatibility
5050
# TV
51-
from tvariable import asVariable, createVariable, isVariable
51+
from .tvariable import asVariable, createVariable, isVariable
5252

53-
from mvSphereMesh import SphereMesh
54-
from mvBaseWriter import BaseWriter
55-
from mvVsWriter import VsWriter
56-
from mvVTKSGWriter import VTKSGWriter
57-
from mvVTKUGWriter import VTKUGWriter
58-
from mvCdmsRegrid import CdmsRegrid
53+
from .mvSphereMesh import SphereMesh
54+
from .mvBaseWriter import BaseWriter
55+
from .mvVsWriter import VsWriter
56+
from .mvVTKSGWriter import VTKSGWriter
57+
from .mvVTKUGWriter import VTKUGWriter
58+
from .mvCdmsRegrid import CdmsRegrid
5959

6060
# Gridspec is not installed by default so just pass on if it isn't installed
6161
try:
62-
from gsStaticVariable import StaticFileVariable
63-
from gsTimeVariable import TimeFileVariable
62+
from .gsStaticVariable import StaticFileVariable
63+
from .gsTimeVariable import TimeFileVariable
6464
except:
6565
pass
6666

67-
from restApi import esgfConnection,esgfDataset,FacetConnection
67+
from .restApi import esgfConnection, esgfDataset, FacetConnection
6868

6969
MV = MV2

Packages/cdms2/Lib/auxcoord.py

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,62 +4,80 @@
44
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.
55
"""
66

7-
## import internattr
8-
from error import CDMSError
9-
from coord import AbstractCoordinateAxis
10-
from fvariable import FileVariable
11-
from variable import DatasetVariable
12-
from tvariable import TransientVariable
13-
from avariable import AbstractVariable
7+
# import internattr
8+
from .error import CDMSError
9+
from .coord import AbstractCoordinateAxis
10+
from .fvariable import FileVariable
11+
from .variable import DatasetVariable
12+
from .tvariable import TransientVariable
13+
from .avariable import AbstractVariable
14+
1415

1516
class AbstractAuxAxis1D(AbstractCoordinateAxis):
1617

17-
def __init__ (self, parent=None, variableNode=None, bounds=None):
18-
AbstractCoordinateAxis.__init__(self, parent, variableNode, bounds=bounds)
18+
def __init__(self, parent=None, variableNode=None, bounds=None):
19+
AbstractCoordinateAxis.__init__(
20+
self,
21+
parent,
22+
variableNode,
23+
bounds=bounds)
1924

20-
def clone (self, copyData=1):
25+
def clone(self, copyData=1):
2126
"""clone (self, copyData=1)
2227
Return a copy of self as a transient axis.
2328
If copyData is 1, make a separate copy of the data."""
24-
result = TransientAuxAxis1D(self[:], copy=copyData, axes=self.getAxisList(), attributes=self.attributes, bounds=self.getBounds())
29+
result = TransientAuxAxis1D(
30+
self[:],
31+
copy=copyData,
32+
axes=self.getAxisList(),
33+
attributes=self.attributes,
34+
bounds=self.getBounds())
2535
return result
2636

2737
def setBounds(self, bounds):
2838
if bounds is not None:
29-
if len(bounds.shape)!=2:
30-
raise CDMSError, 'Bounds must have rank=2'
31-
if bounds.shape[0:1]!=self.shape:
32-
raise CDMSError, 'Bounds shape %s is inconsistent with axis shape %s'%(`bounds.shape`,`self.shape`)
39+
if len(bounds.shape) != 2:
40+
raise CDMSError('Bounds must have rank=2')
41+
if bounds.shape[0:1] != self.shape:
42+
raise CDMSError(
43+
'Bounds shape %s is inconsistent with axis shape %s' %
44+
(repr(bounds.shape), repr(self.shape)))
3345
AbstractCoordinateAxis.setBounds(self, bounds)
3446

35-
def subSlice (self, *specs, **keys):
47+
def subSlice(self, *specs, **keys):
3648
# Take a subslice, returning a TransientAuxAxis1D
3749
avar = AbstractVariable.subSlice(self, *specs, **keys)
3850
bounds = self.getBounds()
3951
if bounds is None:
4052
newbounds = None
4153
else:
42-
newbounds = bounds[specs] # bounds can be a numarray or DatasetVariable
54+
newbounds = bounds[
55+
specs] # bounds can be a numarray or DatasetVariable
4356

44-
# Note: disable axis copy to preserve identity of grid and variable domains
45-
result = TransientAuxAxis1D(avar, bounds=newbounds, copyaxes=0)
57+
# Note: disable axis copy to preserve identity of grid and variable
58+
# domains
59+
result = TransientAuxAxis1D(avar, bounds=newbounds, copyaxes=0)
4660
return result
4761

62+
4863
class DatasetAuxAxis1D(AbstractAuxAxis1D, DatasetVariable):
4964

5065
# Note: node is a VariableNode
66+
5167
def __init__(self, parent, id=None, variableNode=None, bounds=None):
5268
AbstractAuxAxis1D.__init__(self, parent, variableNode, bounds=bounds)
5369
DatasetVariable.__init__(self, parent, id, variableNode)
5470
self._data_ = None # Cached values
5571

5672
def __repr__(self):
5773
if self.parent is not None:
58-
return "<DatasetAuxAxis1D: %s, file: %s, shape: %s>"%(self.id, self.parent.id, `self.shape`)
74+
return "<DatasetAuxAxis1D: %s, file: %s, shape: %s>" % (self.id, self.parent.id, repr(self.shape))
5975
else:
60-
return "<DatasetAuxAxis1D: %s, file: **CLOSED**>"%self.id
76+
return "<DatasetAuxAxis1D: %s, file: **CLOSED**>" % self.id
77+
78+
# internattr.initialize_internal_attributes(DatasetAuxAxis1D) # Copy
79+
# internal attrs from parents
6180

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

6482
class FileAuxAxis1D(AbstractAuxAxis1D, FileVariable):
6583

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

7189
def __repr__(self):
7290
if self.parent is not None:
73-
return "<FileAuxAxis1D: %s, file: %s, shape: %s>"%(self.id, self.parent.id, `self.shape`)
91+
return "<FileAuxAxis1D: %s, file: %s, shape: %s>" % (self.id, self.parent.id, repr(self.shape))
7492
else:
75-
return "<FileAuxAxis1D: %s, file: **CLOSED**>"%self.id
93+
return "<FileAuxAxis1D: %s, file: **CLOSED**>" % self.id
94+
95+
# internattr.initialize_internal_attributes(FileAuxAxis1D) # Copy internal
96+
# attrs from parents
7697

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

7999
class TransientAuxAxis1D(AbstractAuxAxis1D, TransientVariable):
80100

81-
def __init__(self, data, typecode=None, copy=0, savespace=0, mask=None, fill_value=None,
101+
def __init__(
102+
self, data, typecode=None, copy=0, savespace=0, mask=None, fill_value=None,
82103
axes=None, attributes=None, id=None, copyaxes=1, bounds=None):
83104
"""Create a transient, auxiliary 1-D axis.
84105
All arguments are as for TransientVariable.
85106
'bounds' is the bounds array, having shape (m,nvert) where data.shape is (m,) and
86107
nvert is the max number of vertices per cell.
87108
"""
88109
AbstractAuxAxis1D.__init__(self, None, None, bounds=bounds)
89-
TransientVariable.__init__(self, data, typecode=typecode, copy=copy, savespace=savespace,
110+
TransientVariable.__init__(
111+
self, data, typecode=typecode, copy=copy, savespace=savespace,
90112
mask=mask, fill_value=fill_value, axes=axes, attributes=attributes,
91113
id=id, copyaxes=copyaxes)
92114
if axes is not None:
93115
self.setBounds(bounds)
94116

95-
## internattr.initialize_internal_attributes(TransientAuxAxis1D) # Copy internal attrs from parents
96-
117+
# internattr.initialize_internal_attributes(TransientAuxAxis1D) # Copy
118+
# internal attrs from parents

0 commit comments

Comments
 (0)