diff --git a/Lib/MV2.py b/Lib/MV2.py index ee69b74d..f5991ee9 100644 --- a/Lib/MV2.py +++ b/Lib/MV2.py @@ -76,8 +76,13 @@ def _extractMetadata(a, axes=None, attributes=None, class var_unary_operation: def __init__(self, mafunc): - """ var_unary_operation(mafunc) - mafunc is an numpy.ma masked_unary_function. + """ + Parameters + ---------- + + var_unary_operation(mafunc) + + mafunc is an numpy.ma masked_unary_function. """ self.mafunc = mafunc self.__doc__ = mafunc.__doc__ @@ -91,8 +96,13 @@ def __call__(self, a, **kwargs): class var_unary_operation_with_axis: def __init__(self, mafunc): - """ var_unary_operation(mafunc) - mafunc is an numpy.ma masked_unary_function. + """ + Parameters + ---------- + + var_unary_operation(mafunc) + + mafunc is an numpy.ma masked_unary_function. """ self.mafunc = mafunc self.__doc__ = mafunc.__doc__ @@ -108,14 +118,24 @@ def __call__(self, a, axis=0, **kwargs): def commonDomain(a, b, omit=None): - """commonDomain(a,b) tests that the domains of variables/arrays a and b are equal, - and returns the common domain if equal, or None if not equal. + """ + Parameters + ---------- + + commonDomain(a,b) + tests that the domains of variables/arrays a and b are equal, + and - The domains may differ in that one domain may have leading axes not common - to the other; the result domain will contain those axes. + Returns + ------- - If is specified, as an integer i, skip comparison of the ith dimension - and return None for the ith (common) dimension. + the common domain if equal, or None if not equal. + + The domains may differ in that one domain may have leading + axes not common to the other; the result domain will contain those axes. + + If is specified, as an integer i, skip comparison of the ith dimension + and return None for the ith (common) dimension. """ if isinstance(b, AbstractVariable): @@ -126,8 +146,14 @@ def commonDomain(a, b, omit=None): def commonAxes(a, bdom, omit=None): - """Helper function for commonDomain. 'a' is a variable or array, - 'b' is an axislist or None. + """Helper function for commonDomain. + + Parameters + ---------- + + 'a' is a variable or array, + + 'b' is an axislist or None. """ if isinstance(a, AbstractVariable) and bdom is not None: adom = a.getAxisList() @@ -181,9 +207,18 @@ def commonAxes(a, bdom, omit=None): def commonGrid(a, b, axes): - """commonGrid(a,b,axes) tests if the grids associated with variables a, b are equal, - and consistent with the list of axes. If so, the common grid is returned, else None - is returned. a and b can be numpy arrays, in which case the result is None. + """ + Parameters + ---------- + + commonGrid(a,b,axes) + + tests if the grids associated with variables a, b are equal + and consistent with the list of axes. + + If so, the common grid is returned, else None is returned. + + a and b can be numpy arrays, in which case the result is None. The common grid is 'consistent' with axes if the grid axes (e.g., the axes of latitude and longitude coordinate variables) are members of the list 'axes'. @@ -232,8 +267,13 @@ def commonGrid1(a, gb, axes): class var_binary_operation: def __init__(self, mafunc): - """ var_binary_operation(mafunc) - mafunc is an numpy.ma masked_binary_function. + """ + Parameters + ---------- + + var_binary_operation(mafunc) + + mafunc is an numpy.ma masked_binary_function. """ self.mafunc = mafunc self.__doc__ = mafunc.__doc__ @@ -1015,7 +1055,12 @@ def reshape(a, newshape, axes=None, attributes=None, id=None, grid=None): def resize(a, new_shape, axes=None, attributes=None, id=None, grid=None): - """resize(a, new_shape) returns a new array with the specified shape. + """resize(a, new_shape) + + Returns + ------- + a new array with the specified shape. + The original array's total size can be any size.""" ignore, attributes, id, ignore = _extractMetadata(a, axes, attributes, id) if axes is not None: @@ -1031,9 +1076,13 @@ def resize(a, new_shape, axes=None, attributes=None, id=None, grid=None): def masked_array(a, mask=None, fill_value=None, axes=None, attributes=None, id=None): - """masked_array(a, mask=None) = - array(a, mask=mask, copy=0, fill_value=fill_value) - Use fill_value(a) if None. + """ + Parameters + ---------- + masked_array(a, mask=None) = + array(a, mask=mask, copy=0, fill_value=fill_value) + + Use fill_value(a) if None. """ maresult = numpy.ma.masked_array( _makeMaskedArg(a), @@ -1048,10 +1097,14 @@ def masked_array(a, mask=None, fill_value=None, def masked_values(data, value, rtol=1.e-5, atol=1.e-8, copy=1, savespace=0, axes=None, attributes=None, id=None): """ - masked_values(data, value, rtol=1.e-5, atol=1.e-8) - Create a masked array; mask is None if possible. - May share data values with original array, but not recommended. - Masked where abs(data-value)<= atol + rtol * abs(value) + Parameters + ---------- + + masked_values(data, value, rtol=1.e-5, atol=1.e-8) + + Create a masked array; mask is None if possible. + May share data values with original array, but not recommended. + Masked where abs(data-value)<= atol + rtol * abs(value) """ maresult = numpy.ma.masked_values(_makeMaskedArg( data), value, rtol=rtol, atol=atol, copy=copy) @@ -1078,8 +1131,13 @@ def isMaskedVariable(x): def set_default_fill_value(value_type, value): """Set the default fill value for value_type to value. - value_type is a string: 'real','complex','character','integer',or 'object'. - value should be a scalar or single-element array. + + Parameters + ---------- + value_type is a string: + 'real','complex','character','integer',or 'object'. + + value should be a scalar or single-element array. """ if value_type == 'real': numpy.ma.default_real_fill_value = value @@ -1099,8 +1157,15 @@ def fromfunction(f, dimensions): def diagonal(a, offset=0, axis1=0, axis2=1): - """diagonal(a, offset=0, axis1=0, axis2 = 1) returns the given - diagonals defined by the two dimensions of the array. + """ + Parameters + ---------- + diagonal(a, offset=0, axis1=0, axis2 = 1) + + Returns + ------- + + the given diagonals defined by the two dimensions of the array. """ F = getattr(a, "fill_value", 1.e20) return TransientVariable(numpy.ma.diagonal(_makeMaskedArg(a), diff --git a/Lib/avariable.py b/Lib/avariable.py index a2fed304..236d2efb 100644 --- a/Lib/avariable.py +++ b/Lib/avariable.py @@ -177,8 +177,8 @@ def __call__(self, *args, **kwargs): """ Selection of a subregion using selectors. - **Parameters:** - + Parameters + ---------- raw: if set to 1, return numpy.ma only squeeze: @@ -188,8 +188,8 @@ def __call__(self, *args, **kwargs): order: if given, result is permuted into this order - **Returns:** - + Returns + ------- Subregion selected """ # separate options from selector specs @@ -429,12 +429,16 @@ def getConvention(self): # A child class may want to override this def getAxis(self, n): """Get the n-th axis. + Parameters ---------- + n: Axis number + Returns ------- + if n < 0: n = n + self.rank() self.getDomain()[n][0]""" if n < 0: @@ -472,25 +476,24 @@ def hasCellData(self): return False def getAxisListIndex(self, axes=None, omit=None, order=None): - """Return a list of indices of axis objects; - - Note - ---- - If axes is **not** `None`, include only certain axes. - less the ones specified in omit. + """ + Returns + ------- + a list of indices of axis objects - If axes is `None`, use all axes of this variable. + Note + ---- + If axes is **not** `None`, include only certain axes. + less the ones specified in omit. - Other specificiations are as for axisMatchIndex. + If axes is `None`, use all axes of this variable. - Returns - ------- - a list of indices of axis objects; + Other specificiations are as for axisMatchIndex. """ return axisMatchIndex(self.getAxisList(), axes, omit, order) def getAxisList(self, axes=None, omit=None, order=None): - """Get the list of axis objects; + """Get the list of axis objects Note ---- @@ -524,9 +527,10 @@ def getMissing(self, asarray=0): asarray : '0' : scalar '1' : numpy array - Return - ------ - the missing value as a scalar, or as a numpy array if asarray==1""" + + Returns + ------- + the missing value as a scalar, or as a numpy array if asarray==1""" if hasattr(self, 'missing_value'): try: @@ -695,16 +699,19 @@ def getLongitude(self): # Get an order string, such as "tzyx" def getOrder(self, ids=0): """ - parameters + Parameters ---------- - id: - 0 or 1 - returns + + id: + 0 or 1 + + Returns ------- - the order string, such as t, z, y, x (time, level, lat, lon). + + the order string, such as t, z, y, x (time, level, lat, lon). Note - ---- + * if ids == 0 (the default) for an axis that is not t,z,x,y the order string will contain a (-) character in that location. The result string will be of the same length as the number @@ -1176,9 +1183,10 @@ def subRegion(self, *specs, **keys): def getValue(self, squeeze=1): """Get the entire set of values. + Returns ------- - All values and elimite the 1-D dimension. + All values and elimite the 1-D dimension. """ return self.getSlice(Ellipsis, squeeze=squeeze) diff --git a/Lib/axis.py b/Lib/axis.py index 41c37c1a..ef051886 100644 --- a/Lib/axis.py +++ b/Lib/axis.py @@ -608,16 +608,17 @@ def lookupArray(ar, value): Parameters ---------- - ar: - Input array - value: - Value to search + ar: + Input array + value: + Value to search + Returns ------- - index: - * ar is monotonically increasing. - * value <= ar[index], index==0..len(ar)-1 - * value > ar[index], index==len(ar) + index: + * ar is monotonically increasing. + * value <= ar[index], index==0..len(ar)-1 + * value > ar[index], index==len(ar) * ar is monotonically decreasing: * value >= ar[index], index==0..len(ar)-1 * value < ar[index], index==len(ar) @@ -1252,7 +1253,10 @@ def mapInterval(self, interval, indicator='ccn', cycle=None): same meaning for the right-hand point. Set cycle to a nonzero value to force wraparound. - Returns the corresponding index interval (i,j), where iN, the interval wraps around, and is equivalent to the two consecutive intervals [i,N), [0,j-N) - For example, if the vector is [0,2,4,...,358] of length 180, - and the coordinate interval is [-5,5), the return index interval is - [178,183). This is equivalent to the two intervals [178,180) and [0,3). + Example: + if the vector is [0,2,4,...,358] of length 180,and the coordinate + interval is [-5,5), the return index interval is[178,183). This is + equivalent to the two intervals [178,180) and [0,3). -.. note:: + Note: if the interval is interior to the axis, but does not span any axis element, a singleton (i,i+1) indicating an adjacent index is returned. """ @@ -2677,16 +2682,17 @@ def concatenate(axes, id=None, attributes=None): Parameters ---------- - axes: - Axes to concatenate - id: - New axis identification (default None) - attributes: - Attributes to attached to the new Axis + axes : + Axes to concatenate + id : + New axis identification (default None) + attributes : + Attributes to attached to the new Axis Returns ------- - Transient axis.""" + Transient axis. + """ data = numpy.ma.concatenate([ax[:] for ax in axes]) boundsArray = [ax.getBounds() for ax in axes] @@ -2699,12 +2705,14 @@ def concatenate(axes, id=None, attributes=None): def take(ax, indices): """Take elements form an array along an axis + Parameters ---------- ax: The source array. indices: The indices of the values to extract. + Returns ------- axis: TransientAxis diff --git a/Lib/cache.py b/Lib/cache.py index 7b4a761f..b24d4844 100644 --- a/Lib/cache.py +++ b/Lib/cache.py @@ -299,9 +299,10 @@ def __init__(self): def get(self, filekey): """ Get the path associated with , or None if not present. -Parameters ----------- - + + Parameters + ---------- + filekey for cache """ filekey = str(filekey) @@ -322,9 +323,10 @@ def get(self, filekey): def put(self, filekey, path): """ cache[filekey] = path -Parameters ----------- - + + Parameters + ---------- + filekey for cache """ @@ -373,8 +375,8 @@ def copyFile(self, fromURL, filekey, lcpath=None, For request manager transfers, lcpath is the logical collection path, -Parameters ----------- + Parameters + ---------- is the string user ID, @@ -428,30 +430,32 @@ def getFile(self, fromURL, filekey, naptime=5, maxtries=60, Parameters - --------- + ---------- - is the number of seconds between retries, + is the number of seconds between retries, - is the maximum number of retries. Otherwise, copy it from the remote file. + is the maximum number of retries. Otherwise, copy it from the remote file. - is the cache index key. A good choice is (datasetDN, filename) + is the cache index key. A good choice is (datasetDN, filename) where datasetDN is the distinguished name of the dataset, and filename is the name of the file within the dataset. For request manager transfers, - is the logical collection path, + is the logical collection path, - is the user string ID, + is the user string ID, - is true iff the request manager should search the replica catalog for the actual file to transfer. + is true iff the request manager should search the replica catalog for the actual file to transfer. - Returns the path of a file in the cache. + Returns + ------- + the path of a file in the cache. Note: The function does not guarantee that the file is still in the cache by the time it returns. diff --git a/Lib/cudsinterface.py b/Lib/cudsinterface.py index fdc68339..9c435bac 100644 --- a/Lib/cudsinterface.py +++ b/Lib/cudsinterface.py @@ -382,24 +382,28 @@ def getattribute(self, vname, attribute): def getslab(self, vname, *args, **keys): """ + Parameters + ---------- + getslab ('name', arg1, arg2, ....) - getslab ('name', arg1, arg2, ....) + Returns + ------- - returns a cdms variable containing the data. + a cdms variable containing the data. - Arguments for each dimension can be: - (1) : or None -- selected entire dimension - (2) Ellipsis -- select entire dimensions between the ones given. - (3) a pair of successive arguments giving an interval in - world coordinates. - (4) a cdms-style tuple of world coordinates e.g. (start, stop, 'cc') + Arguments for each dimension can be: + (1) : or None -- selected entire dimension + (2) Ellipsis -- select entire dimensions between the ones given. + (3) a pair of successive arguments giving an interval in + world coordinates. + (4) a cdms-style tuple of world coordinates e.g. (start, stop, 'cc') - Options + Options - args - (*tuple/*cdms2.selectors.Selector) () tuple of type (val1,val2,'cob') - for any given dimension or cdms selector + args + (*tuple/*cdms2.selectors.Selector) () tuple of type (val1,val2,'cob') + for any given dimension or cdms selector Keys squeeze diff --git a/Lib/database.py b/Lib/database.py index b96f4118..8df37044 100644 --- a/Lib/database.py +++ b/Lib/database.py @@ -52,11 +52,11 @@ def connect(uri=None, user="", password=""): Returns ------- - Database instance. + Database instance Example - ------- - db = cdms.connect("ldap://dbhost.llnl.gov/database=CDMS,ou=PCMDI,o=LLNL,c=US") + + db = cdms.connect("ldap://dbhost.llnl.gov/database=CDMS,ou=PCMDI,o=LLNL,c=US") """ if uri is None: try: @@ -312,7 +312,7 @@ def openDataset(self, dsetid, mode='r'): Dataset instance. Example - ------- + dset = db.openDataset('ncep_reanalysis_mo') """ dn = "dataset=%s,%s" % (dsetid, self.path) @@ -416,7 +416,7 @@ def searchFilter(self, filter=None, tag=None, relbase=None, Entries can be refined with searchPredicate(). Example - ------- + (1) Find all variables named "cli": result = db.searchFilter(filter="id=cli",tag="variable") @@ -529,7 +529,7 @@ def searchPredicate(self, predicate, tag=None): Entries can be refined with searchPredicate(). Example - ------- + (1) Find all variables on a 73x96 grid newresult = result.searchPredicate(lambda obj: obj.getGrid().shape==(73,96),"variable") @@ -561,11 +561,11 @@ def __init__(self, db): def getObject(self): """ Method - ------ + getObject() Description - ----------- + Get the CDMS object associated with this entry. Returns diff --git a/Lib/dataset.py b/Lib/dataset.py index 902aa438..301bdc8d 100644 --- a/Lib/dataset.py +++ b/Lib/dataset.py @@ -149,10 +149,11 @@ def setCompressionWarnings(value=None): def setNetcdfUseNCSwitchModeFlag(value): """Tells cdms2 to switch constantly between netcdf define/write modes. + Parameters ---------- - value: - 0/1, False/True. + value: + 0/1, False/True. Returns ------- @@ -268,6 +269,7 @@ def setNetcdfShuffleFlag(value): ---------- value: 0/1, False/True. + Returns ------- No return value. @@ -287,6 +289,7 @@ def setNetcdfDeflateFlag(value): ---------- value: 0/1, False/True. + Returns ------- No return value. @@ -333,7 +336,8 @@ def getNetcdfUseParallelFlag(): Parameters ---------- value: - 0/1, False/True. + 0/1, False/True + Returns ------- No return value. @@ -384,9 +388,10 @@ def getNetcdfDeflateLevelFlag(): def useNetcdf3(): """ Turns off (0) NetCDF flags for shuffle/cuDa/deflatelevel Output files are generated as NetCDF3 Classic after that + Returns ------- - No return value. + No return value. """ setNetcdfShuffleFlag(0) setNetcdfDeflateFlag(0) @@ -467,6 +472,7 @@ def openDataset(uri, mode='r', template=None, Default set to 1 dpath: (str) Destination path. + Returns ------- file handle. @@ -580,6 +586,7 @@ def parselist(text, f): Input String. f: function which parses A and returns (A, nconsumed). + Returns ------- Parser results. @@ -619,10 +626,11 @@ def parseIndexList(text): text: i,j,k,l,... are indices or '-', and path is a filename. Coerce the indices to integers. + Returns ------- - Parser results. - n number of matches. + Parser results. + n number of matches. """ m = _IndexList4.match(text) nindices = 4 @@ -1718,14 +1726,16 @@ def copyGrid(self, grid, newname=None): Parameters ---------- - newname: (str/None) - new name for grid (default None) - grid: - file grid (cdms2.grid.FileRectGrid/cdms2.hgrid.FileCurveGrid/cdms2.gengrid.FileGenericGrid) + newname: (str/None) + new name for grid (default None) + + grid: file grid + (cdms2.grid.FileRectGrid/cdms2.hgrid.FileCurveGrid/cdms2.gengrid.FileGenericGrid) Returns ------- - file grid (cdms2.grid.FileRectGrid/cdms2.hgrid.FileCurveGrid/cdms2.gengrid.FileGenericGrid) + file grid + (cdms2.grid.FileRectGrid/cdms2.hgrid.FileCurveGrid/cdms2.gengrid.FileGenericGrid) """ if newname is None: @@ -2337,6 +2347,7 @@ def getVariable(self, id): def getVariables(self, spatial=0): """Get a list of variable objects. + Parameters ---------- spatial: @@ -2364,6 +2375,7 @@ def getAxis(self, id): ---------- id: id of the axis to get + Returns -------- file axis diff --git a/Lib/forecast.py b/Lib/forecast.py index 3f973992..141b445e 100644 --- a/Lib/forecast.py +++ b/Lib/forecast.py @@ -17,14 +17,14 @@ def two_times_from_one(t): """ Parameters ---------- - Input - is a time representation, either as the long int used in the cdscan - script, or a string in the format "2010-08-25 15:26:00", or as a cdtime comptime - (component time) object. + is a time representation, either as the long int used in the + cdscan script, or a string in the format "2010-08-25 15:26:00", or + as a cdtime comptime (component time) object. Output - is the same time, both as a long _and_ as a comptime.""" + is the same time, both as a long _and_ as a comptime. + """ if t == 0: t = 0 if isinstance(t, string_types): @@ -60,7 +60,8 @@ def two_times_from_one(t): def comptime(t): """ Parameters - --------- + ---------- + Input is a time representation, either as the long int used in the cdscan script, or a string in the format "2010-08-25 15:26:00", or as a cdtime comptime @@ -138,7 +139,7 @@ def available_forecasts(dataset_file, path="."): through the specified cdscan-generated dataset xml file. Note - ---- + The forecasts are given in 64-bit integer format, but can be converted to component times with the function two_times_from_one. This function may help in choosing the right arguments for initializing @@ -152,11 +153,11 @@ def available_forecasts(dataset_file, path="."): class forecasts(): - """represents a set of forecasts + """ + Represents a set of forecasts + Example - Example - ------- Creates a set of forecasts. Normally you do it by something like f = forecasts( 'file.xml', (min_time, max_time) ) @@ -255,7 +256,7 @@ def time_interval_to_list(self, tlo, thi, openclosed='co'): def reduce_inplace(self, min_time, max_time, openclosed='co'): """ Example - ------- + For a forecasts object f, f( min_time, max_time ) will reduce the scope of f, to forecasts whose start time t has min_time<=t`__. See also the\n", - "documentation of the Python Numpy and MA modules, on which ``cdms.MV``\n", - "is based, at\n", - "\n", - "`https://www.numpy.org/ `__." + "[https://www.numpy.org/](https://www.numpy.org/)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "File Variables\n", + "## File Variables\n", "\n", "A variable can be obtained either from a file, a collection of files, or\n", "as the result of computation. Correspondingly there are three types of\n", @@ -478,9 +923,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(1, 2, 80, 97)" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "u = f.getVariable('u') # or u=f['u']\n", "u.shape \n" @@ -504,7 +960,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -536,24 +992,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "MV2.get_print_limit() # Current limit 1000\n", "\n", - "smallvar \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "MV2.set_print_limit(100)\n", - "largevar " + "MV2.set_print_limit(100)\n" ] }, { @@ -565,9 +1010,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'f'" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "u.typecode()" ] @@ -576,7 +1032,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Dataset Variables\n", + "## Dataset Variables\n", "\n", "The third type of variable, a *dataset variable*, is associated with a\n", "*dataset*, a collection of files that is treated as a single file. A\n", @@ -602,25 +1058,11 @@ "The metafile **cdsample.xml** is then used like an ordinary data file:" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "os.system(\"cdscan -x cdsample.xml [uv]*.nc\")\n", - "\n", - "f = cdms2.open('cdsample.xml')\n", - "u = f('u')\n", - "u.shape" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Grids\n", + "## Grids\n", "\n", "A latitude-longitude grid represents the coordinate information\n", "associated with a variable. A grid encapsulates:\n", @@ -669,71 +1111,75 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 25, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(32, 48)\n", + "[[-76.08465554167911 -76.08465554167911 -76.08465554167911 ...\n", + " -76.08465554167911 -76.08465554167911 -76.08465554167911]\n", + " [-73.9264184725605 -73.9264184725605 -73.9264184725605 ...\n", + " -73.9264184725605 -73.9264184725605 -73.9264184725605]\n", + " [-71.44420823116856 -71.44420823116856 -71.44420823116856 ...\n", + " -71.44420823116856 -71.44420823116856 -71.44420823116856]\n", + " ...\n", + " [42.32854942878924 42.65822090474772 43.3199021098036 ...\n", + " 43.31990190153133 42.658220876191656 42.32854942851401]\n", + " [42.70106428805028 43.057314984924034 43.76927818341599 ...\n", + " 43.769277959957755 43.057314954110254 42.70106428775246]\n", + " [43.03073409838211 43.41264382746999 44.172341649201826 ...\n", + " 44.17234141149318 43.412643794488375 43.03073409806216]]\n", + "[[-1.3279277494480501 -1.3279277494480501 -1.3279277494480501 ...\n", + " -1.3279277494480501 -1.3279277494480501 -1.3279277494480501]\n", + " [-1.290259406553338 -1.290259406553338 -1.290259406553338 ...\n", + " -1.290259406553338 -1.290259406553338 -1.290259406553338]\n", + " [-1.2469366651143254 -1.2469366651143254 -1.2469366651143254 ...\n", + " -1.2469366651143254 -1.2469366651143254 -1.2469366651143254]\n", + " ...\n", + " [0.7387725551255372 0.744526407830922 0.756074923457711 ...\n", + " 0.7560749198226742 0.7445264073325248 0.7387725551207336]\n", + " [0.7452741659322457 0.751491913555217 0.7639180155219315 ...\n", + " 0.7639180116218496 0.7514919130174151 0.7452741659270478]\n", + " [0.7510279895669614 0.7576935717849446 0.7709528000943938 ...\n", + " 0.7709527959455953 0.7576935712093067 0.7510279895613773]]\n" + ] + } + ], "source": [ - "f = cdms2.open('sampleCurveGrid4.nc')\n", - "\n", + "# uncomment the line below to donwload \"clt.nc\"\n", + "# wget \"https://cdat.llnl.gov/cdat/sample_data/sampleCurveGrid4.nc\"\n", "\n", + "f = cdms2.open('sampleCurveGrid4.nc')\n", "# lat and lon are coordinate axes, but are grouped with data variables\n", "f.variables.keys()\n", - "\n", - "\n", "# y and x are index coordinate axes\n", "f.axes.keys()\n", - "\n", - "\n", "# Read data for variable sample\n", "sample = f('sample')\n", - "\n", "# The associated grid g is curvilinear\n", "g = sample.getGrid()\n", - "\n", "# The domain of the variable consfigists of index axes\n", "sample.getAxisIds()\n", - "\n", - "\n", "# Get the coordinate axes associated with the grid\n", "lat = g.getLatitude() # or sample.getLatitude()\n", "lon = g.getLongitude() # or sample.getLongitude()\n", - "\n", "# lat and lon have the same domain, a subset of the domain of 'sample'\n", "lat.getAxisIds()\n", - "\n", - "\n", "# lat and lon are variables ...\n", - "lat.shape\n", - "\n", - "\n", - "lat \n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "lat_in_radians = lat*MV2.pi/180.0" + "print(lat.shape)\n", + "print(lat)\n", + "lat_in_radians = lat*MV2.pi/180.0\n", + "print(lat_in_radians)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Example: A Generic Grid\n", + "# Example: A Generic Grid\n", "\n", "In this example variable zs is defined on a generic grid. Figure 2\n", "illustrates the grid, in this case a geodesic grid:" @@ -741,9 +1187,20 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 26, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "cdms2.coord.TransientAxis2D" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "f.variables.keys()\n", "\n", @@ -778,7 +1235,6 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " Figure 2: Generic Grid\n", "\n", "Generic grids can be used to represent any of the grid types. The method\n", "toGenericGrid can be applied to any grid to convert it to a generic\n", @@ -789,27 +1245,37 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 29, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('rectgrid:', (46, 72))\n", + "('curvegrid:', )\n", + "('genericgrid: ', )\n" + ] + } + ], "source": [ - "f = cdms2.open(cdat_info.get_sampledata_path()+'/clt.nc')\n", + "f = cdms2.open('clt.nc')\n", "clt = f('clt')\n", "rectgrid = clt.getGrid()\n", - "rectgrid.shape\n", + "print(\"rectgrid:\", rectgrid.shape)\n", "\n", "curvegrid = rectgrid.toCurveGrid()\n", - "curvegrid\n", + "print(\"curvegrid:\", curvegrid)\n", "\n", "genericgrid = curvegrid.toGenericGrid()\n", - "genericgrid" + "print(\"genericgrid: \", genericgrid)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Regridding\n", + "## Regridding\n", "\n", "Regridding is the process of mapping variables from one grid to another.\n", "CDMS supports two forms of regridding. Which one you use depends on the\n", @@ -827,7 +1293,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "CDMS Regridder\n", + "### CDMS Regridder\n", "\n", "The built-in CDMS regridder is used to transform data from one\n", "rectangular grid to another. For example, to regrid variable ``u`` (from\n", @@ -836,17 +1302,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 31, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('u.shape:', (1, 2, 80, 97))\n", + "('U63.shape', (1, 2, 96, 192))\n" + ] + } + ], "source": [ "f = cdms2.open('clt.nc')\n", "u = f('u')\n", - "u.shape\n", + "print(\"u.shape:\", u.shape)\n", "\n", "t63_grid = cdms2.createGaussianGrid(96)\n", "u63 = u.regrid(t63_grid)\n", - "u63.shape" + "print(\"U63.shape\",u63.shape)" ] }, { @@ -858,17 +1333,28 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 32, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "NameError", + "evalue": "name 'f2' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcdms2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'clt.nc'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0muold\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'u'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0munew\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'uwnd'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 4\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"uold.shape\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0muold\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mNameError\u001b[0m: name 'f2' is not defined" + ] + } + ], "source": [ "f = cdms2.open('clt.nc')\n", "uold = f('u')\n", "unew = f2('uwnd')\n", - "uold.shape\n", - "\n", + "print(\"uold.shape\", uold.shape)\n", "unew.shape\n", - "\n", + "print(\"unew.shape\", unew.shape)\n", "t63_grid = unew.getGrid() # Obtain the grid for vnew\n", "u63 = uold.regrid(t63_grid)\n", "u63.shape" @@ -878,7 +1364,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "SCRIP Regridder\n", + "### SCRIP Regridder\n", "\n", "To interpolate between any lat-lon grid types, the SCRIP regridder may\n", "be used. The SCRIP package was developed at [Los Alamos National\n", @@ -901,17 +1387,28 @@ "\n", "Steps 1 and 2 need only be done once. The regridder can be used as often\n", "as necessary.\n", - "\n", - "#For example, suppose the source data on a T42 grid is to be mapped to a\n", - "#POP curvilinear grid. Assume that SCRIP generated a remapping file named\n", - "#rmp_T42_to_POP43_conserv.nc:\n" + "\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "CDMSError", + "evalue": "Cannot open file /software/cdms22/sampleT42Grid.nc (Variable not found)", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mCDMSError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m# Get the source variable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcdms2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sampleT42Grid.nc'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mdat\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'src_array'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mclose\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/software/anaconda53/envs/sphynx/lib/python2.7/site-packages/cdms2/dataset.pyc\u001b[0m in \u001b[0;36mopenDataset\u001b[0;34m(uri, mode, template, dods, dpath, hostObj)\u001b[0m\n\u001b[1;32m 491\u001b[0m \u001b[0;31m# rank\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 492\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexists\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 493\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mCdmsFile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmpiBarrier\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mCdMpi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 494\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mmode\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"w\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 495\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/software/anaconda53/envs/sphynx/lib/python2.7/site-packages/cdms2/dataset.pyc\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, path, mode, hostObj, mpiBarrier)\u001b[0m\n\u001b[1;32m 1273\u001b[0m \u001b[0m_fileobj_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCdunif\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mCdunifFile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1274\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1275\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mCDMSError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Cannot open file %s (%s)'\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0merr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1276\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_file_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_fileobj_\u001b[0m \u001b[0;31m# Cdunif file object\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1277\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvariables\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mCDMSError\u001b[0m: Cannot open file /software/cdms22/sampleT42Grid.nc (Variable not found)" + ] + } + ], "source": [ "# Import regrid package for regridder functions\n", "import regrid2, cdms2\n", diff --git a/docs/source/_static/agogo.css_t b/docs/source/_static/agogo.css_t index 52d4f74e..1c28bb89 100644 --- a/docs/source/_static/agogo.css_t +++ b/docs/source/_static/agogo.css_t @@ -19,10 +19,11 @@ table { } tr:nth-child(even){background-color: #f2f2f2} +tr td:first-child { font-weight: bold } -th { - background-color: #4CAF50; - color: white; +th { + background-color: #01796F; + color: #f8f8ba; } body { @@ -98,7 +99,7 @@ h2 { a.headerlink { visibility: hidden; - color: #dddddd; + color: #dddddd; padding-left: .3em; } @@ -143,6 +144,7 @@ table.field-list th.field-name { display: inline-block; padding: 1px 8px 1px 5px; white-space: nowrap; + color: darkblue; background-color: rgb(238, 238, 238); } @@ -212,7 +214,8 @@ div.header .headertitle { } div.header .headertitle a { - color: white; + color: #f8f8ba; +/* color: white; */ } div.header div.rel { @@ -361,8 +364,9 @@ div.sidebar a:hover, div.header a:hover { } div.sidebar h3 { - color: #2e3436; + color: #2e3436; text-transform: uppercase; + font-weight: bold; font-size: 130%; letter-spacing: .1em; } @@ -375,14 +379,17 @@ div.sidebar li.toctree-l1 a { display: block; padding: 1px; border: 1px solid #dddddd; - background-color: #eeeeec; +/* background-color: #eeeeec; */ + background-color: #01796F; margin-bottom: .4em; padding-left: 3px; - color: #2e3436; + /* color: #2e3436; */ + color: #f8f8ba; } div.sidebar li.toctree-l2 a { background-color: transparent; + color: #01796F; border: none; margin-left: 1em; border-bottom: 1px solid #dddddd; @@ -390,6 +397,7 @@ div.sidebar li.toctree-l2 a { div.sidebar li.toctree-l3 a { background-color: transparent; + color: #01796F; border: none; margin-left: 2em; border-bottom: 1px solid #dddddd; diff --git a/docs/source/conf.py b/docs/source/conf.py index 4bcbd3c2..a7fe858f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -186,6 +186,7 @@ # further. For a list of options available for each theme, see the # documentation. #html_theme_options = { "stickysidebar" : "true" } +html_theme_options = { "headerbg" : "#01796F" } # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] @@ -194,7 +195,7 @@ # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +html_title = "CDMS Documentation" # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None diff --git a/docs/source/index.rst b/docs/source/index.rst index 8092b80a..a02825da 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,14 +3,8 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -CDMS documentation -================== - - **Version :** |release| -**Table of content:** - .. toctree:: :numbered: 4 @@ -26,7 +20,6 @@ CDMS documentation API - Indices and tables ================== diff --git a/docs/source/manual/cdms_1.rst b/docs/source/manual/cdms_1.rst index 743cb5e1..a30bfdcf 100644 --- a/docs/source/manual/cdms_1.rst +++ b/docs/source/manual/cdms_1.rst @@ -256,7 +256,7 @@ In general internal attributes should not be modified directly. One exception is the id attribute, the name of the variable. It is used in plotting and I/O, and can be set directly. -Masked values +Masked Values ^^^^^^^^^^^^^ Optionally, variables have a mask that represents where data are @@ -710,7 +710,7 @@ rmp_T42_to_POP43_conserv.nc: Regridding is discussed in `Chapter 4 `__. -Time types +Time Types ^^^^^^^^^^ CDMS provides extensive support for time values in the cdtime module. @@ -791,7 +791,7 @@ or string representations can be used: Time types are described in Chapter 3. -Plotting data +Plotting Data ^^^^^^^^^^^^^ Data read via the CDMS Python interface can be plotted using the vcs diff --git a/docs/source/manual/cdms_2.rst b/docs/source/manual/cdms_2.rst index 339d77ef..151c0647 100644 --- a/docs/source/manual/cdms_2.rst +++ b/docs/source/manual/cdms_2.rst @@ -324,8 +324,6 @@ external attributes are written, but not the internal attributes. .. doctest:: -Attributes Common to All CDMS Objects -------------------------------------- Attributes Common to All CDMS Objects ------------------------------------- @@ -1031,7 +1029,7 @@ ResultEntry Methods "``CdmsObj``", "``getObject()``", "Return the CDMS object associated with this entry. **Note:** For many search applications it is unnecessary to access the associated CDMS object. For best performance this function should be used only when necessary, for example, to retrieve data associated with a variable." -Accessing data +Accessing Data -------------------- To access data via CDMS: @@ -1713,7 +1711,7 @@ Variable Methods * In ``(a)-(c)`` and (f), negative numbers are treated as offsets from the end of that dimension, as in normal Python indexing. * String ``typecode()`` The Numpy datatype identifier." -Example Get a Region of Data. +Example Get a Region of Data ----------------------------- Variable ta is a function of (time, latitude, longitude). Read data diff --git a/docs/source/manual/cdms_4.rst b/docs/source/manual/cdms_4.rst index 0ad2da33..90e6d379 100644 --- a/docs/source/manual/cdms_4.rst +++ b/docs/source/manual/cdms_4.rst @@ -350,8 +350,8 @@ convexity, and ‘repaired’ if necessary. Grid cells may appear to be nonconvex if they cross a ``0 / 2pi`` boundary. The repair consists of shifting the cell vertices to the same side modulo 360 degrees. -_`CDMS Regridder Functions` -^^^^^^^^^^^^^^^^^^^^^^^^^^^ +CDMS Regridder Functions +^^^^^^^^^^^^^^^^^^^^^^^^ A CDMS regridder function is an instance of the CDMS ``Regridder`` class. The function is associated with rectangular input and output @@ -422,7 +422,8 @@ CDMS Regridder Function * A value of 1 or 1.0 indicates that the corresponding data value is to be ignored for purposes of regridding. * A value of 0 or 0.0 indicates that the corresponding data value is valid. This is consistent with the convention for masks used by the MV2 module. * A fractional value between 0.0 and 1.0 indicates the fraction of the data value (e.g., the corresponding cell) to be ignored when regridding. This is useful if a variable is regridded first to grid A and then to another grid B; the mask when regridding from A to B would be (1.0 - f) where f is the maskArray returned from the initial grid operation using the ``returnTuple`` argument. - * If ``mask`` is two-dimensional of the same shape as the input grid, it overrides the mask of the input grid. If the mask has more than two dimensions, it must have the same shape as ``array``. In this case, the ``missing`` data value is also ignored. Such an ndimensional mask is useful if the pattern of missing data varies with level (e.g., ocean data) or time. + * If ``mask`` is two-dimensional of the same shape as the input grid, it overrides the mask of the input grid. + * If the ``mask`` has more than two dimensions, it must have the same shape as ``array``. In this case, the ``missing`` data value is also ignored. Such an ndimensional mask is useful if the pattern of missing data varies with level (e.g., ocean data) or time. **Note:** If neither ``missing`` or ``mask`` is set, the default mask is obtained from the mask of the array if any." "Array, Array", "``regridFunction(ar, missing=None, order=None, mask=None, returnTuple=1)``", "If called with the optional ``returnTuple`` argument equal to 1, the function returns a tuple ``dataArray``, ``maskArray``). * ``dataArray`` is the result data array. @@ -595,18 +596,14 @@ Generate an array of zonal mean values. >>> f.close() +.. csv-table:: + :header: "Line", "Notes" + :widths: 8, 45 -+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Line | Notes | -+========+===================================================================================================================================================================================================+ -| 3 | Get the input grid. Return the area fraction of the source (input) grid cell that participates in the regridding. The array is 1-D, with length equal to the number of cells in the input grid. | -+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 4 | Create a zonal grid. outgrid has the same latitudes as ingrid, and a singleton longitude dimension. createGlobalMeanGrid could be used here to generate a global mean array. | -+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 5 | Generate the regridder function. | -+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| 6 | Generate the zonal mean array | -+--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ + "3", "Open a netCDF file for inputGet the input grid. Return the area fraction of the source (input) grid cell that participates in the regridding. The array is 1-D, with length equal to the number of cells in the input grid." + "4", "Create a zonal grid. outgrid has the same latitudes as ingrid, and a singleton longitude dimension. createGlobalMeanGrid could be used here to generate a global mean array." + "5", "Generate the regridder function." + "6", "Generate the zonal mean array." **Example:** @@ -634,31 +631,22 @@ of the result. >>> outmean = add.reduce(ravel(outmask*outweights*outsample)) / add.reduce(ravel(outmask*outweights)) -+--------+----------------------------------------------------------------------------------------------------------+ -| Line | Notes | -+========+==========================================================================================================+ -| 2 | Create a uniform target grid. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 3 | Get the latitude and longitude weights. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 4 | Generate a 2-D weights array. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 5 | Get the input grid. ``var`` is a 4-D variable. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 6 | Get the first horizontal slice from ``var``. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 7-8 | Get the input weights, and generate a 2-D weights array. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 9 | Set the 2-D input mask. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 10 | Calculate the input array area-weighted mean. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 11 | Create the regridder function. | -+--------+----------------------------------------------------------------------------------------------------------+ -| 12 | Regrid. Because returnTuple is set to 1, the result is a tuple (dataArray, maskArray). | -+--------+----------------------------------------------------------------------------------------------------------+ -| 13 | Calculate the area-weighted mean of the regridded data. mean and outmean should be approximately equal | -+--------+----------------------------------------------------------------------------------------------------------+ +.. csv-table:: + :header: "Line", "Notes" + :widths: 8, 45 + + "2", "Create a uniform target grid." + "3", "Get the latitude and longitude weights." + "4", "Generate a 2-D weights array." + "5", "Get the input grid. ``var`` is a 4-D variable." + "6", "Get the first horizontal slice from ``var``." + "7-8", "Get the input weights, and generate a 2-D weights array." + "9", "Set the 2-D input mask." + "10", "Calculate the input array area-weighted mean." + "11", "Create the regridder function." + "12", "Regrid. Because returnTuple is set to 1, the result is a tuple (dataArray, maskArray)." + "13", "Calculate the area-weighted mean of the regridded data. mean and outmean should be approximately equal." + SCRIP Regridder ~~~~~~~~~~~~~~~ diff --git a/docs/source/manual/cdms_6.rst b/docs/source/manual/cdms_6.rst index 733a7289..2bb8458e 100644 --- a/docs/source/manual/cdms_6.rst +++ b/docs/source/manual/cdms_6.rst @@ -51,24 +51,18 @@ The CDML elements are: CDML Tags ^^^^^^^^^ +.. csv-table:: + :header: "Tag", "Description" + :widths: 30,80 + + "attr", "Extra attribute" + "axis", "Coordinate axis" + "domain", "Axes on which a variable is defined" + "domElem", "Element of a variable domain" + "linear", "Linearly-spaced axis values" + "rectGrid", "Rectilinear Grid" + "variable", "Variable" -+------------+---------------------------------------+ -| Tag | Description | -+============+=======================================+ -| attr | Extra attribute | -+------------+---------------------------------------+ -| axis | Coordinate axis | -+------------+---------------------------------------+ -| domain | Axes on which a variable is defined | -+------------+---------------------------------------+ -| domElem | Element of a variable domain | -+------------+---------------------------------------+ -| linear | Linearly-spaced axis values | -+------------+---------------------------------------+ -| rectGrid | Rectilinear Grid | -+------------+---------------------------------------+ -| variable | Variable | -+------------+---------------------------------------+ Special Characters ~~~~~~~~~~~~~~~~~~ @@ -78,8 +72,6 @@ they must be encoded to avoid confusion with markup: Special Character Encodings ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - +-------------+------------+ | Character | Encoding | +=============+============+ diff --git a/docs/source/manual/cdms_7.rst b/docs/source/manual/cdms_7.rst index 16d17804..0c03d617 100644 --- a/docs/source/manual/cdms_7.rst +++ b/docs/source/manual/cdms_7.rst @@ -1,7 +1,7 @@ CDMS Utilities -------------- -CdScan: Importing datasets into CDMS +CdScan: Importing Datasets into CDMS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Overview diff --git a/docs/source/manual/cdms_appendix.rst b/docs/source/manual/cdms_appendix.rst index 2b665fbf..da920791 100644 --- a/docs/source/manual/cdms_appendix.rst +++ b/docs/source/manual/cdms_appendix.rst @@ -165,7 +165,7 @@ Dataset - The function open is synonymous with openDataset. -cdms module +Cdms Module ''''''''''' - The following functions were added: diff --git a/docs/source/manual/docs/cdms_quick_start.pdf b/docs/source/manual/docs/cdms_quick_start.pdf index b87cbcf9..40ba390f 100644 Binary files a/docs/source/manual/docs/cdms_quick_start.pdf and b/docs/source/manual/docs/cdms_quick_start.pdf differ diff --git a/docs/source/manual/images/cdms_quick_start.jpg b/docs/source/manual/images/cdms_quick_start.jpg index 7669fc20..2fe343be 100644 Binary files a/docs/source/manual/images/cdms_quick_start.jpg and b/docs/source/manual/images/cdms_quick_start.jpg differ diff --git a/regrid2/Lib/crossSection.py b/regrid2/Lib/crossSection.py index 39ad338e..b5ed2641 100644 --- a/regrid2/Lib/crossSection.py +++ b/regrid2/Lib/crossSection.py @@ -545,21 +545,21 @@ def rgrd(self, dataIn, missingValueIn, missingMatch, logYes='yes', def checkdimension(x, name): """ - **Purpose:** + Purpose: - dimension checks - 1. has a len method - 2. data type is float32 - 3. monotonically increasing vectors + dimension checks + 1. has a len method + 2. data type is float32 + 3. monotonically increasing vectors - **Parameters:** - - x - coordinate vector - - name - coordinate vector ID + Parameters + ---------- + x - coordinate vector - **Returns:** + name - coordinate vector ID + Returns + ------- x, xsize -- dimension vector and its size """ @@ -709,15 +709,15 @@ def get_latitude_wts_bnds(checklatpass): def latitude_bounds(lat_bnds): """ - **Purpose:** + **Purpose:** set up the shape and bounds for use by maparea **Usage:** - **Returns:** - - tuple ( bn,bs ) + Returns + ------- + tuple ( bn,bs ) """ @@ -751,9 +751,9 @@ def get_region_latitude_wts_bnds(latRegionpass, latType, latSize): wts,bnds = get_region_latitude_wts_bnds(latRegion, latType, latSize) where latRegion is the regional grid to check - **Returns:** - - wts, bnds - tuple with weights and bounds + Returns + ------- + wts, bnds - tuple with weights and bounds """ @@ -837,9 +837,9 @@ def sectionmask(dataIn, positionIn, maskIn, missingValueIn, missingMatch): amskin = mask(dataIn, positionIn, maskIn, missingValueIn, missingValueOut, flag2D) - **Returns:** - - amskin + Returns + ------- + amskin """ # Logic outline @@ -1019,9 +1019,9 @@ def sendmsg(msg, value1=None, value2=None): value - the number associated with the string - **Returns:** - - return + Returns + ------- + return """ @@ -1048,9 +1048,9 @@ def section(latvals, levvals): the grid coordinate vectors - **Returns:** - - xsection -- a temerature like cross section + Returns + ------- + xsection -- a temerature like cross section """ @@ -1086,9 +1086,9 @@ def rmserror(data1, data2): the two data sets - **Returns:** - - rms error + Returns + ------- + rms error """ diff --git a/regrid2/Lib/esmf.py b/regrid2/Lib/esmf.py index f6d49656..c9fd363c 100644 --- a/regrid2/Lib/esmf.py +++ b/regrid2/Lib/esmf.py @@ -702,15 +702,15 @@ def getSrcAreas(self, rootPe): """ Get the src grid areas as used by conservative interpolation - **Parameters:** - - rootPe - None is local areas are returned, otherwise provide rootPe and the data will be gathered - + Parameters + ---------- + rootPe : + None is local areas are returned, otherwise provide rootPe and the data will be gathered - **Returns:** - numpy array or None if interpolation is not conservative + Returns + ------- + numpy array or None if interpolation is not conservative """ if self.srcAreaField is not None: return self.srcAreaField.data.T @@ -720,15 +720,15 @@ def getDstAreas(self, rootPe): """ Get the dst grid areas as used by conservative interpolation - **Parameters:** - - rootPe - None is local areas are returned, otherwise provide rootPe and the data will be gathered - + Parameters + ---------- + rootPe + None is local areas are returned, otherwise provide rootPe and the data will be gathered - **Returns:** - numpy array or None if interpolation is not conservative + Returns + ------- + numpy array or None if interpolation is not conservative """ if self.srcAreaField is not None: return self.dstAreaField.data.T @@ -738,15 +738,15 @@ def getSrcAreaFractions(self, rootPe): """ Get the source grid fraction areas as used by conservative interpolation - **Parameters:** - - rootPe - None is local areas are returned, otherwise provide rootPe and the data will be gathered - + Parameters + ---------- + rootPe + None is local areas are returned, otherwise provide rootPe and the data will be gathered - **Returns:** - numpy array + Returns + ------- + numpy array """ if self.srcFracField is not None: # self.srcFracField.get_area() @@ -757,15 +757,15 @@ def getDstAreaFractions(self, rootPe): """ Get the destination grid fraction areas as used by conservative interpolation - **Parameters:** - - rootPe - None is local areas are returned, otherwise provide rootPe and the data will be gathered - + Parameters + ---------- + rootPe + None is local areas are returned, otherwise provide rootPe and the data will be gathered - **Returns:** - numpy array + Returns + ------- + numpy array """ if self.dstFracField is not None: # self.dstFracField.get_area() diff --git a/regrid2/Lib/mvGenericRegrid.py b/regrid2/Lib/mvGenericRegrid.py index 23786c12..a8ac7b22 100644 --- a/regrid2/Lib/mvGenericRegrid.py +++ b/regrid2/Lib/mvGenericRegrid.py @@ -22,13 +22,13 @@ def guessPeriodicity(srcBounds): """ Guess if a src grid is periodic - **Parameters:** - - srcBounds - the nodal src set of coordinates - - **Returns:** + Parameters + ---------- + srcBounds + the nodal src set of coordinates + Returns + ------- 1 if periodic, warp around, 0 otherwise """ res = 0 @@ -196,10 +196,10 @@ def apply(self, srcData, dstData, """ Regrid source to destination - **Parameters:** - - srcData - array (input) + Parameters + ---------- + srcData + array (input) dstData array (output) @@ -343,8 +343,8 @@ def getDstGrid(self): Return the destination grid, may be different from the dst grid provided to the constructor due to domain decomposition - **Returns:** - + Returns + ------- local grid on this processor """ return self.tool.getDstGrid() @@ -353,8 +353,8 @@ def fillInDiagnosticData(self, diag, rootPe=None): """ Fill in diagnostic data - **Parameters:** - + Parameters + ---------- diag a dictionary whose entries, if present, will be filled entries are tool dependent diff --git a/regrid2/Lib/pressure.py b/regrid2/Lib/pressure.py index 42b632f2..3fe830d9 100644 --- a/regrid2/Lib/pressure.py +++ b/regrid2/Lib/pressure.py @@ -443,8 +443,8 @@ def checkorder(positionIn): positionIn -- array with location of longitude, latitude. level and time respectively in the sense of the python shape of the data - **Returns:** - + Returns + ------- newOrder -- tuple to transpose data to the order (t,z,y,x) inverseOrder -- tuple to transpose data to back to the original order @@ -490,9 +490,9 @@ def sendmsg(msg, value1=None, value2=None): value - the number associated with the string - **Returns:** - - return + Returns + ------- + return """ diff --git a/regrid2/Lib/scrip.py b/regrid2/Lib/scrip.py index ae08e76b..93d364df 100644 --- a/regrid2/Lib/scrip.py +++ b/regrid2/Lib/scrip.py @@ -371,14 +371,15 @@ def regrid(self, input): def readRegridder(fileobj, mapMethod=None, checkGrid=1): """Read a regridder from an open fileobj. - **Parameters:** + Parameters + ---------- - mapMethod - is one of "conservative", "bilinear", "bicubic", or "distwgt". + mapMethod + is one of "conservative", "bilinear", "bicubic", or "distwgt". - If unspecified, it defaults to the method defined in the file. + If unspecified, it defaults to the method defined in the file. - If 'checkGrid' is 1 (default), the grid cells are checked for convexity, and 'repaired' if necessary. + If 'checkGrid' is 1 (default), the grid cells are checked for convexity, and 'repaired' if necessary. """