diff --git a/Lib/avariable.py b/Lib/avariable.py index 0135b514..a2fed304 100644 --- a/Lib/avariable.py +++ b/Lib/avariable.py @@ -36,16 +36,16 @@ def getMinHorizontalMask(var): """ - Get the minimum mask associated with 'x' and 'y' + Get the minimum mask associated with 'x' and 'y' (i.e. with the min number of ones) across all axes Parameters ---------- - var : + var : CDMS variable with a mask - N/A : + N/A : None Returns @@ -178,7 +178,7 @@ def __call__(self, *args, **kwargs): Selection of a subregion using selectors. **Parameters:** - + raw: if set to 1, return numpy.ma only squeeze: @@ -189,7 +189,7 @@ def __call__(self, *args, **kwargs): if given, result is permuted into this order **Returns:** - + Subregion selected """ # separate options from selector specs @@ -1848,9 +1848,9 @@ def astype(self, tc): def orderparse(order): """Parse an order string. Returns a list of axes specifiers. - + Note: - + Order elements can be: * Letters t, x, y, z meaning time, longitude, latitude, level * Numbers 0-9 representing position in axes @@ -1889,7 +1889,7 @@ def order2index(axes, order): The argument order is a string. Note: - + Order elements can be: * Letters t, x, y, z meaning time, longitude, latitude, level. * Numbers 0-9 representing position in axes diff --git a/Lib/axis.py b/Lib/axis.py index 2a8925bc..41c37c1a 100644 --- a/Lib/axis.py +++ b/Lib/axis.py @@ -7,7 +7,6 @@ from future import standard_library import sys -import os import types import copy import numpy @@ -26,34 +25,22 @@ _debug = 0 std_axis_attributes = ['name', 'units', 'length', 'values', 'bounds'] -ON_RTD = os.environ.get('READTHEDOCS', None) == 'True' -if not ON_RTD: - class AliasList (UserList): - def __init__(self, alist): - UserList.__init__(self, alist) +class AliasList (UserList): + def __init__(self, alist): + UserList.__init__(self, alist) - def __setitem__(self, i, value): - self.data[i] = value.lower() + def __setitem__(self, i, value): + self.data[i] = value.lower() - def __setslice(self, i, j, values): - self.data[i:j] = [x.lower() for x in values] + def __setslice(self, i, j, values): + self.data[i:j] = [x.lower() for x in values] - def append(self, value): - self.data.append(value.lower()) + def append(self, value): + self.data.append(value.lower()) - def extend(self, values): - self.data.extend(list(map(str.lower, values))) -else: - class MockObject(object): - def __init__(self, *args, **kwargs): - super(MockObject, self).__init__() - - def __call__(self, *args, **kwargs): - return None - - class AliasList(MockObject): - pass + def extend(self, values): + self.data.extend(list(map(str.lower, values))) level_aliases = AliasList(['plev']) @@ -1265,9 +1252,7 @@ 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 i - filekey for cache + filekey for cache """ filekey = str(filekey) lock("index_lock") @@ -325,7 +325,7 @@ def put(self, filekey, path): Parameters ---------- - filekey for cache + filekey for cache """ filekey = str(filekey) @@ -353,7 +353,7 @@ def deleteEntry(self, filekey): Parameters ---------- - filekey for cache + filekey for cache """ filekey = str(filekey) diff --git a/Lib/convention.py b/Lib/convention.py index 28223908..ba32cbad 100644 --- a/Lib/convention.py +++ b/Lib/convention.py @@ -1,6 +1,6 @@ """ metadata conventions """ + from __future__ import print_function -import os from .error import CDMSError from collections import UserList @@ -9,34 +9,19 @@ MethodNotImplemented = "Method not yet implemented" -ON_RTD = os.environ.get('READTHEDOCS', None) == 'True' - -if not ON_RTD: - class AliasList (UserList): - def __init__(self, alist): - UserList.__init__(self, alist) - - def __setitem__(self, i, value): - self.data[i] = value.lower() - - def __setslice(self, i, j, values): - self.data[i:j] = [x.lower() for x in values] - def append(self, value): - self.data.append(value.lower()) +class AliasList (UserList): + def __init__(self, alist): + UserList.__init__(self, alist) - def extend(self, values): - self.data.extend(list(map(str.lower, values))) -else: - class MockObject(object): - def __init__(self, *args, **kwargs): - super(MockObject, self).__init__() + def __setitem__(self, i, value): + self.data[i] = value.lower() - def __call__(self, *args, **kwargs): - return None + def __setslice(self, i, j, values): + self.data[i:j] = [x.lower() for x in values] - class AliasList(MockObject): - pass + def append(self, value): + self.data.append(value.lower()) level_aliases = AliasList(['plev']) @@ -242,7 +227,7 @@ def axisIsLongitude(self, axis): return AbstractConvention.axisIsLongitude(self, axis) def getVariableBounds(self, dset, var): - "Get the bounds variable for the variable, from a dataset or file." + """Get the bounds variable for the variable, from a dataset or file.""" if hasattr(var, 'bounds'): boundsid = var.bounds if boundsid in dset.variables: diff --git a/Lib/dataset.py b/Lib/dataset.py index 02112a25..902aa438 100644 --- a/Lib/dataset.py +++ b/Lib/dataset.py @@ -5,17 +5,14 @@ from __future__ import print_function from .error import CDMSError import sys -# from . import Cdunif -import Cdunif +from . import Cdunif import numpy -# from . import cdmsNode -import cdmsNode +from . import cdmsNode import os import string import urllib from urllib.parse import urlparse, urlunparse -# from . import cdmsobj -import cdmsobj +from . import cdmsobj import re from .CDMLParser import CDMLParser from .cdmsobj import CdmsObj diff --git a/Lib/fvariable.py b/Lib/fvariable.py index 33492985..04331365 100644 --- a/Lib/fvariable.py +++ b/Lib/fvariable.py @@ -7,7 +7,7 @@ from .variable import DatasetVariable from .error import CDMSError from .sliceut import reverseSlice -from cdms2.Cdunif import CdunifError +from .Cdunif import CdunifError # import cdms2.Cdunif.CdunifError as CdunifError FileClosed = "Cannot read from closed file, variable: " diff --git a/Lib/gengrid.py b/Lib/gengrid.py index 3b9eb6d6..b76e9388 100644 --- a/Lib/gengrid.py +++ b/Lib/gengrid.py @@ -323,7 +323,7 @@ def reconcile(self, axes): for i in missing: for item in axes: if (len(selfaxes[i]) == len(item)) and \ - allclose(selfaxes[i], item): + allclose(selfaxes[i], item): result._lataxis_.setAxis(i, item) result._lonaxis_.setAxis(i, item) break diff --git a/Lib/hgrid.py b/Lib/hgrid.py index 7aea5d8c..eac17c15 100644 --- a/Lib/hgrid.py +++ b/Lib/hgrid.py @@ -32,10 +32,10 @@ def _flatten(boundsar): class AbstractHorizontalGrid(AbstractGrid): """ Create an horizontal grid - + Parameters ---------- - latAxis + latAxis lonAxis id - Default None maskvar - Default None @@ -908,7 +908,6 @@ class TransientCurveGrid(AbstractCurveGrid): Not documented """ - grid_count = 0 def __init__(self, latAxis, lonAxis, id=None, maskvar=None, tempmask=None): diff --git a/chapter1.ipynb b/chapter1.ipynb index 31e31559..e66059d9 100644 --- a/chapter1.ipynb +++ b/chapter1.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Overview\n", + "## Overview\n", "\n", "The Community Data Management System is an object-oriented data management\n", "system, specialized for organizing multidimensional, gridded data used\n", @@ -22,14 +22,14 @@ "this chapter assume some familiarity with the language and the Python\n", "Numpy module (https://www.numpy.org). A number of excellent tutorials\n", "on Python are available in books or on the Internet. For example, see\n", - "the `Python Foundation's homepage `__.\n" + "the [Python Foundation's homepage](https://python.org).\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Variables\n", + "## Variables\n", "\n", "The basic unit of computation in CDMS is the variable. A variable is essentially a multidimensional data array, augmented with a domain, a set of attributes, and optionally a spatial and/or temporal coordinate system [(see Coordinate Axes)](https://cdms.readthedocs.io/en/readthedocstest/manual/cdms_1.html#coordinate-axes). As a data array, a variable can\n", "be sliced to obtain a portion of the data, and can be used in arithmetic\n", @@ -41,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -51,99 +51,77 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 28, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1, 2, 80, 97)\n" + ] + } + ], "source": [ - "# wget \"https://cdat.llnl.gov/cdat/sample_data/clt.nc\"\n", + "# uncomment the line below to donwload \"clt.nc\"\n", + "# !wget \"https://cdat.llnl.gov/cdat/sample_data/clt.nc\"\n", "f1=cdms2.open(\"clt.nc\")\n", "u = f1('u')\n", "v = f1('v')\n", - "from cdms2 import MV" + "from cdms2 import MV\n", + "print u.shape" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "MV is a module that wraps numpy masked arrays. It keeps the axes, grid and other attributes." ] }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "--2018-10-17 10:40:26-- https://cdat.llnl.gov/cdat/sample_data/clt.nc\n", - "Resolving cdat.llnl.gov... 198.128.245.146\n", - "Connecting to cdat.llnl.gov|198.128.245.146|:443... connected.\n", - "HTTP request sent, awaiting response... 200 OK\n", - "Length: 1718908 (1.6M) [application/x-netcdf]\n", - "Saving to: “clt.nc.10”\n", - "\n", - "100%[======================================>] 1,718,908 --.-K/s in 0.02s \n", - "\n", - "2018-10-17 10:40:26 (84.3 MB/s) - “clt.nc.10” saved [1718908/1718908]\n", - "\n", - "[[[3.6092278957366943 3.548424005508423 3.4843790531158447 ...\n", - " 3.7187933921813965 3.6662113666534424 3.6092278957366943]\n", - " [4.482813358306885 4.336821556091309 4.194543838500977 ...\n", - " 4.773476600646973 4.629714488983154 4.482813358306885]\n", - " [4.675872802734375 4.467889785766602 4.299487590789795 ...\n", - " 5.208128452301025 4.9245829582214355 4.675872802734375]\n", - " ...\n", - " [14.2416353225708 14.323187828063965 14.379049301147461 ...\n", - " 14.00051212310791 14.134027481079102 14.2416353225708]\n", - " [12.480237007141113 12.524213790893555 12.552382469177246 ...\n", - " 12.346633911132812 12.420877456665039 12.480237007141113]\n", - " [10.413312911987305 10.42257308959961 10.425800323486328 ...\n", - " 10.377242088317871 10.39814567565918 10.413312911987305]]\n", - "\n", - " [[-- -- -- ... -- -- --]\n", - " [-- -- -- ... -- -- --]\n", - " [2.4196360111236572 2.2428698539733887 2.099884510040283 ... -- --\n", - " 2.4196360111236572]\n", - " ...\n", - " [2.685023307800293 2.349280834197998 2.100950002670288 ...\n", - " 3.5292885303497314 3.0855724811553955 2.685023307800293]\n", - " [3.2643380165100098 3.098647117614746 2.9637553691864014 ...\n", - " 3.6760590076446533 3.4581825733184814 3.2643380165100098]\n", - " [3.7221627235412598 3.6456055641174316 3.5727615356445312 ...\n", - " 3.8849072456359863 3.8020851612091064 3.7221627235412598]]]\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/numpy/ma/core.py:3169: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.\n", - " dout = self.data[indx]\n", - "/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/numpy/ma/core.py:3201: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.\n", - " mout = _mask[indx]\n", - "/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/numpy/ma/core.py:6652: RuntimeWarning: overflow encountered in power\n", - " result = np.where(m, fa, umath.power(fa, fb)).view(basetype)\n" + "['units', 'name', 'title', 'tileIndex', 'source', 'time', 'date', 'type']\n", + "('units: ', 'm/s')\n", + " id: plev\n", + " Designated a level axis.\n", + " units: hPa\n", + " Length: 2\n", + " First: 200.0\n", + " Last: 850.0\n", + " Other axis attributes:\n", + " axis: Z\n", + " realtopology: linear\n", + " Python id: 0x7fb843f27a10\n", + "\n" ] } ], "source": [ - "!wget \"https://cdat.llnl.gov/cdat/sample_data/clt.nc\"\n", - "f1= cdms2.open(\"clt.nc\")\n", - "u = f1('u')\n", - "v = f1('v')\n", - "\n", "vel = MV.sqrt(u[0]**2 + v[0]**2)\n", - "print vel\n", - "\n" + "print(vel.listattributes())\n", + "print(\"units: \", vel.units)\n", + "print(vel.getLevel())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "This illustrates several points:\n", + "## Several points:\n", "\n", "- Square brackets represent the slice operator. Indexing starts at 0,\n", " so ``u[0]`` selects from variable ``u`` for the first timepoint. The\n", " result of this slice operation is another variable. The slice\n", " operator can be multidimensional, and follows the syntax of Numpy\n", - " Python arrays. In this example, ``u[0:10,:,1]`` would retrieve data\n", + " Python arrays. In this example, ``u[0,0,0:10,1]`` would retrieve data\n", " for the first ten timepoints, at all latitudes, for the second\n", " longitude.\n", "- Variables can be used in computation. ``**`` is the Python\n", @@ -155,28 +133,47 @@ " the first time of ``u`` and ``v``." ] }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[-3.0127158164978027 -4.229100227355957 -4.467456340789795\n", + " -3.366543769836426 -0.9665766358375549 2.2838134765625 4.745534420013428\n", + " 4.761820316314697 2.8783907890319824 1.4265387058258057]\n" + ] + } + ], + "source": [ + "print(u[0,0,0:10,1])" + ] + }, { "cell_type": "markdown", "metadata": {}, "source": [ - "File I/O\n", + "# File I/O\n", "\n", "\n", "A variable can be obtained from a file or collection of files, or can be\n", "generated as the result of a computation. Files can be in any of the\n", - "self- describing formats netCDF, HDF, GrADS/GRIB (GRIB with a GrADS\n", - "control file), or PCMDI DRS. (HDF and DRS support is optional, and is\n", - "configured at the time CDAT is installed.) For instance, to read data\n", - "from file sample.nc into variable u:" + "self- describing formats `netCDF`, `HDF`, `GrADS/GRIB` *(GRIB with a GrADS\n", + "control file)*, or `PCMDI DRS`. (HDF and DRS support is optional, and is\n", + "configured at the time CDMS is installed.) For instance, to read data\n", + "from file clt.nc into variable u..." ] }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 29, "metadata": {}, "outputs": [], "source": [ - "# wget \"https://cdat.llnl.gov/cdat/sample_data/clt.nc\"\n", + "# !wget \"https://cdat.llnl.gov/cdat/sample_data/clt.nc\"\n", "f = cdms2.open('clt.nc')\n", "u = f('u')" ] @@ -185,12 +182,12 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Data can be read by index or by world coordinate values. The following reads the n-th timepoint of u (the syntax slice(i,j) refers to indices k such that i <= k < j):" + "Data can be read by index or by world coordinate values. The following reads the `n-th` timepoint of `u` *(the syntax slice(i,j)* refers to indices `k` such that `i <= k < j`):" ] }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 30, "metadata": {}, "outputs": [], "source": [ @@ -202,25 +199,16 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "To read u at time 1.:" + "To read u at time 1:" ] }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 32, "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "can't assign to literal (, line 1)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m 1 = f('u',time=1.)\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m can't assign to literal\n" - ] - } - ], + "outputs": [], "source": [ - "1 = f('u',time=1.)" + "l = f('u',time=1.)" ] }, { @@ -232,13 +220,37 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 33, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/software/anaconda53/envs/sphynx/lib/python2.7/site-packages/cdms2/dataset.py:2154: Warning: Files are written with compression and no shuffling\n", + "You can query different values of compression using the functions:\n", + "cdms2.getNetcdfShuffleFlag() returning 1 if shuffling is enabled, 0 otherwise\n", + "cdms2.getNetcdfDeflateFlag() returning 1 if deflate is used, 0 otherwise\n", + "cdms2.getNetcdfDeflateLevelFlag() returning the level of compression for the deflate method\n", + "\n", + "If you want to turn that off or set different values of compression use the functions:\n", + "value = 0\n", + "cdms2.setNetcdfShuffleFlag(value) ## where value is either 0 or 1\n", + "cdms2.setNetcdfDeflateFlag(value) ## where value is either 0 or 1\n", + "cdms2.setNetcdfDeflateLevelFlag(value) ## where value is a integer between 0 and 9 included\n", + "\n", + "To produce NetCDF3 Classic files use:\n", + "cdms2.useNetCDF3()\n", + "To Force NetCDF4 output with classic format and no compressing use:\n", + "cdms2.setNetcdf4Flag(1)\n", + "NetCDF4 file with no shuffling or deflate and noclassic will be open for parallel i/o\n", + " \"for parallel i/o\", Warning)\n" + ] + } + ], "source": [ "g = cdms2.open('sample2.nc','w')\n", "g.write(u) \n", - "\n", "g.close()" ] }, @@ -246,7 +258,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Coordinate Axes\n", + "# Coordinate Axes\n", "\n", "\n", "A coordinate axis is a variable that represents coordinate information.\n", @@ -256,7 +268,7 @@ "\n", "Often in climate applications an axis is a one-dimensional variable\n", "whose values are floating-point and strictly monotonic. In some cases an\n", - "axis can be multidimensional (see `Grids <#grids>`__). If an axis is\n", + "axis can be multidimensional (see `Grids`). If an axis is\n", "associated with one of the canonical types latitude, longitude, level,\n", "or time, then the axis is called temporal .\n", "\n", @@ -270,58 +282,9 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[ id: time1\n", - " Designated a time axis.\n", - " units: months since 1978-12\n", - " Length: 1\n", - " First: 1.0\n", - " Last: 1.0\n", - " Other axis attributes:\n", - " calendar: gregorian\n", - " axis: T\n", - " Python id: 0x7f1067d00510, id: plev\n", - " Designated a level axis.\n", - " units: hPa\n", - " Length: 2\n", - " First: 200.0\n", - " Last: 850.0\n", - " Other axis attributes:\n", - " axis: Z\n", - " realtopology: linear\n", - " Python id: 0x7f108452bd90, id: latitude1\n", - " Designated a latitude axis.\n", - " units: degrees_north\n", - " Length: 80\n", - " First: -88.2884\n", - " Last: 88.2884\n", - " Other axis attributes:\n", - " axis: Y\n", - " realtopology: linear\n", - " Python id: 0x7f108452bc10, id: longitude1\n", - " Designated a longitude axis.\n", - " units: degrees_east\n", - " Length: 97\n", - " First: -180.0\n", - " Last: 180.0\n", - " Other axis attributes:\n", - " axis: X\n", - " topology: circular\n", - " modulo: 360.0\n", - " realtopology: linear\n", - " Python id: 0x7f108452bed0]" - ] - }, - "execution_count": 23, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "u.getAxisList() " ] @@ -349,18 +312,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[1.]\n", - "months since 1978-12\n" - ] - } - ], + "outputs": [], "source": [ "t = u.getTime()\n", "print t[:]\n", @@ -381,17 +335,9 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "m/s\n" - ] - } - ], + "outputs": [], "source": [ "u.units='m/s'\n", "print u.units" @@ -414,17 +360,9 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "['name', 'title', 'tileIndex', 'date', 'source', 'time', 'units', 'type']\n" - ] - } - ], + "outputs": [], "source": [ "print u.attributes.keys()\n" ] @@ -438,356 +376,9 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['T',\n", - " '_FillValue',\n", - " '_TransientVariable__domain',\n", - " '_TransientVariable__getMPIType',\n", - " '_TransientVariable__getSlab',\n", - " '_TransientVariable__mpiComm',\n", - " '_TransientVariable__mpiType',\n", - " '_TransientVariable__mpiWindows',\n", - " '___cdms_internals__',\n", - " '__abs__',\n", - " '__add__',\n", - " '__and__',\n", - " '__array__',\n", - " '__array_finalize__',\n", - " '__array_interface__',\n", - " '__array_prepare__',\n", - " '__array_priority__',\n", - " '__array_struct__',\n", - " '__array_ufunc__',\n", - " '__array_wrap__',\n", - " '__call__',\n", - " '__cdms_internals__',\n", - " '__class__',\n", - " '__complex__',\n", - " '__contains__',\n", - " '__copy__',\n", - " '__deepcopy__',\n", - " '__delattr__',\n", - " '__delitem__',\n", - " '__dict__',\n", - " '__div__',\n", - " '__divmod__',\n", - " '__doc__',\n", - " '__eq__',\n", - " '__float__',\n", - " '__floordiv__',\n", - " '__format__',\n", - " '__ge__',\n", - " '__getattribute__',\n", - " '__getitem__',\n", - " '__getslice__',\n", - " '__getstate__',\n", - " '__gt__',\n", - " '__hash__',\n", - " '__hex__',\n", - " '__iadd__',\n", - " '__iand__',\n", - " '__idiv__',\n", - " '__ifloordiv__',\n", - " '__ilshift__',\n", - " '__imod__',\n", - " '__imul__',\n", - " '__index__',\n", - " '__init__',\n", - " '__int__',\n", - " '__invert__',\n", - " '__ior__',\n", - " '__ipow__',\n", - " '__irshift__',\n", - " '__isub__',\n", - " '__iter__',\n", - " '__itruediv__',\n", - " '__ixor__',\n", - " '__le__',\n", - " '__len__',\n", - " '__long__',\n", - " '__lshift__',\n", - " '__lt__',\n", - " '__mod__',\n", - " '__module__',\n", - " '__mul__',\n", - " '__ne__',\n", - " '__neg__',\n", - " '__new__',\n", - " '__nonzero__',\n", - " '__oct__',\n", - " '__or__',\n", - " '__pos__',\n", - " '__pow__',\n", - " '__radd__',\n", - " '__rand__',\n", - " '__rdiv__',\n", - " '__rdivmod__',\n", - " '__reduce__',\n", - " '__reduce_ex__',\n", - " '__repr__',\n", - " '__rfloordiv__',\n", - " '__rlshift__',\n", - " '__rmod__',\n", - " '__rmul__',\n", - " '__ror__',\n", - " '__rpow__',\n", - " '__rrshift__',\n", - " '__rshift__',\n", - " '__rsub__',\n", - " '__rtruediv__',\n", - " '__rxor__',\n", - " '__setattr__',\n", - " '__setitem__',\n", - " '__setmask__',\n", - " '__setslice__',\n", - " '__setstate__',\n", - " '__sizeof__',\n", - " '__sqrt__',\n", - " '__str__',\n", - " '__sub__',\n", - " '__subclasshook__',\n", - " '__truediv__',\n", - " '__unicode__',\n", - " '__weakref__',\n", - " '__xor__',\n", - " '_baseclass',\n", - " '_basedict',\n", - " '_comparison',\n", - " '_data',\n", - " '_decodedType',\n", - " '_defaulthardmask',\n", - " '_defaultmask',\n", - " '_delegate_binop',\n", - " '_fill_value',\n", - " '_getShape',\n", - " '_get_data',\n", - " '_get_flat',\n", - " '_get_mask',\n", - " '_get_recordmask',\n", - " '_getinternals',\n", - " '_getmissing',\n", - " '_grid_',\n", - " '_hardmask',\n", - " '_insert_masked_print',\n", - " '_isfield',\n", - " '_listatts',\n", - " '_mask',\n", - " '_missing',\n", - " '_node_',\n", - " '_optinfo',\n", - " '_print_width',\n", - " '_print_width_1d',\n", - " '_process_specs',\n", - " '_returnArray',\n", - " '_set_flat',\n", - " '_set_mask',\n", - " '_set_recordmask',\n", - " '_setatts',\n", - " '_setinternals',\n", - " '_setmissing',\n", - " '_sharedmask',\n", - " '_single_specs',\n", - " '_update_from',\n", - " 'all',\n", - " 'anom',\n", - " 'any',\n", - " 'argmax',\n", - " 'argmin',\n", - " 'argpartition',\n", - " 'argsort',\n", - " 'ascontiguous',\n", - " 'ascontiguousarray',\n", - " 'asma',\n", - " 'assignValue',\n", - " 'astype',\n", - " 'attributes',\n", - " 'base',\n", - " 'baseclass',\n", - " 'byteswap',\n", - " 'choose',\n", - " 'clip',\n", - " 'clone',\n", - " 'compress',\n", - " 'compressed',\n", - " 'conj',\n", - " 'conjugate',\n", - " 'copy',\n", - " 'copyAxis',\n", - " 'copyDomain',\n", - " 'copydimension',\n", - " 'count',\n", - " 'createattribute',\n", - " 'crossSectionRegrid',\n", - " 'ctypes',\n", - " 'cumprod',\n", - " 'cumsum',\n", - " 'data',\n", - " 'date',\n", - " 'decode',\n", - " 'deleteattribute',\n", - " 'diagonal',\n", - " 'dot',\n", - " 'dtype',\n", - " 'dump',\n", - " 'dumps',\n", - " 'expertSlice',\n", - " 'exposeHalo',\n", - " 'fetchHaloData',\n", - " 'fill',\n", - " 'fill_value',\n", - " 'filled',\n", - " 'flags',\n", - " 'flat',\n", - " 'flatten',\n", - " 'freeHalo',\n", - " 'generateGridkey',\n", - " 'generateRectGridkey',\n", - " 'getAxis',\n", - " 'getAxisIds',\n", - " 'getAxisIndex',\n", - " 'getAxisList',\n", - " 'getAxisListIndex',\n", - " 'getConvention',\n", - " 'getDomain',\n", - " 'getForecast',\n", - " 'getForecastTime',\n", - " 'getGrid',\n", - " 'getGridIndices',\n", - " 'getHaloEllipsis',\n", - " 'getLatitude',\n", - " 'getLevel',\n", - " 'getLongitude',\n", - " 'getMPIRank',\n", - " 'getMPISize',\n", - " 'getMissing',\n", - " 'getOrder',\n", - " 'getRegion',\n", - " 'getSlice',\n", - " 'getTileIndex',\n", - " 'getTime',\n", - " 'getValue',\n", - " 'get_fill_value',\n", - " 'get_imag',\n", - " 'get_real',\n", - " 'getattribute',\n", - " 'getdimattribute',\n", - " 'getfield',\n", - " 'harden_mask',\n", - " 'hardmask',\n", - " 'hasCellData',\n", - " 'id',\n", - " 'ids',\n", - " 'imag',\n", - " 'info',\n", - " 'initDomain',\n", - " 'isAbstractCoordinate',\n", - " 'isEncoded',\n", - " 'iscontiguous',\n", - " 'item',\n", - " 'itemset',\n", - " 'itemsize',\n", - " 'listall',\n", - " 'listattributes',\n", - " 'listdimattributes',\n", - " 'listdimnames',\n", - " 'mask',\n", - " 'matchPattern',\n", - " 'matchone',\n", - " 'max',\n", - " 'mean',\n", - " 'min',\n", - " 'mini',\n", - " 'missing',\n", - " 'missing_value',\n", - " 'name',\n", - " 'nbytes',\n", - " 'ndim',\n", - " 'newbyteorder',\n", - " 'nonzero',\n", - " 'parent',\n", - " 'partition',\n", - " 'pressureRegrid',\n", - " 'prod',\n", - " 'product',\n", - " 'ptp',\n", - " 'put',\n", - " 'rank',\n", - " 'ravel',\n", - " 'real',\n", - " 'recordmask',\n", - " 'reg_specs2slices',\n", - " 'regrid',\n", - " 'reorder',\n", - " 'repeat',\n", - " 'reshape',\n", - " 'resize',\n", - " 'round',\n", - " 'searchPattern',\n", - " 'searchPredicate',\n", - " 'searchone',\n", - " 'searchsorted',\n", - " 'select',\n", - " 'setAxis',\n", - " 'setAxisList',\n", - " 'setGrid',\n", - " 'setMPIComm',\n", - " 'setMaskFromGridMask',\n", - " 'setMissing',\n", - " 'setTileIndex',\n", - " 'set_fill_value',\n", - " 'setattribute',\n", - " 'setdimattribute',\n", - " 'setfield',\n", - " 'setflags',\n", - " 'shape',\n", - " 'sharedmask',\n", - " 'showdim',\n", - " 'shrink_mask',\n", - " 'size',\n", - " 'soften_mask',\n", - " 'sort',\n", - " 'source',\n", - " 'specs2slices',\n", - " 'squeeze',\n", - " 'std',\n", - " 'std_slab_atts',\n", - " 'strides',\n", - " 'subRegion',\n", - " 'subSlice',\n", - " 'sum',\n", - " 'swapaxes',\n", - " 'take',\n", - " 'tileIndex',\n", - " 'time',\n", - " 'title',\n", - " 'toVisit',\n", - " 'tobytes',\n", - " 'tofile',\n", - " 'toflex',\n", - " 'tolist',\n", - " 'torecords',\n", - " 'tostring',\n", - " 'trace',\n", - " 'transpose',\n", - " 'type',\n", - " 'typecode',\n", - " 'units',\n", - " 'unshare_mask',\n", - " 'var',\n", - " 'variable_count',\n", - " 'view']" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "dir(u)" ] @@ -818,21 +409,9 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'MV2' 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[0;32m----> 1\u001b[0;31m \u001b[0ma\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMV2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Create array a, with no mask\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mMV2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m4\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Same for b\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0ma\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mb\u001b[0m \u001b[0;31m# variable_... array([5,7,9,])\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\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 'MV2' is not defined" - ] - } - ], + "outputs": [], "source": [ "a = MV2.array([1,2,3]) # Create array a, with no mask\n", "b = MV2.array([4,5,6]) # Same for b\n", @@ -899,20 +478,9 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 2, 80, 97)" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "u = f.getVariable('u') # or u=f['u']\n", "u.shape \n" @@ -936,7 +504,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -968,21 +536,9 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'MV2' 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[0;32m----> 1\u001b[0;31m \u001b[0mMV2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_print_limit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Current limit 1000\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0msmallvar\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\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 'MV2' is not defined" - ] - } - ], + "outputs": [], "source": [ "MV2.get_print_limit() # Current limit 1000\n", "\n", @@ -1009,20 +565,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'f'" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "u.typecode()" ] @@ -1059,23 +604,9 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "IOError", - "evalue": "[Errno 2] No such file or directory: '/export/reshel3/cdms/cdsample.xml'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mIOError\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 2\u001b[0m \u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msystem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cdscan -x cdsample.xml [uv]*.nc\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\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'cdsample.xml'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 5\u001b[0m \u001b[0mu\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[1;32m 6\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/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 488\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mmode\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0;34m'r'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 489\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mModeNotSupported\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[0;32m--> 490\u001b[0;31m \u001b[0mdatanode\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 491\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 492\u001b[0m \u001b[0;31m# If the doesn't exist allow it to be created\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/cdms2/dataset.pyc\u001b[0m in \u001b[0;36mload\u001b[0;34m(path)\u001b[0m\n\u001b[1;32m 402\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 403\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mload\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--> 404\u001b[0;31m \u001b[0mfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 405\u001b[0m \u001b[0mtext\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mread\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 406\u001b[0m \u001b[0mfd\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;31mIOError\u001b[0m: [Errno 2] No such file or directory: '/export/reshel3/cdms/cdsample.xml'" - ] - } - ], + "outputs": [], "source": [ "import os\n", "os.system(\"cdscan -x cdsample.xml [uv]*.nc\")\n", @@ -1138,23 +669,9 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "CDMSError", - "evalue": "Cannot open file /export/reshel3/cdms/sampleCurveGrid4.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[0;32m----> 1\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'sampleCurveGrid4.nc'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m\u001b[0m\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# lat and lon are coordinate axes, but are grouped with data variables\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvariables\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/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 494\u001b[0m \u001b[0;31m# rank\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 495\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--> 496\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 497\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 498\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/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 1276\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 1277\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-> 1278\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 1279\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 1280\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 /export/reshel3/cdms/sampleCurveGrid4.nc (Variable not found)" - ] - } - ], + "outputs": [], "source": [ "f = cdms2.open('sampleCurveGrid4.nc')\n", "\n", @@ -1224,22 +741,9 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "CDMSError", - "evalue": "No such variable, sample", - "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[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 5\u001b[0;31m \u001b[0mzs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'sample'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 6\u001b[0m \u001b[0mg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mzs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetGrid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mg\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/cdms2/cudsinterface.pyc\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, id, *args, **kwargs)\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mCDMSError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"No such variable or grid, \"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 32\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mAttributeError\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 33\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mCDMSError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"No such variable, \"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 34\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mv\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 35\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mCDMSError\u001b[0m: No such variable, sample" - ] - } - ], + "outputs": [], "source": [ "f.variables.keys()\n", "\n", @@ -1285,21 +789,9 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'cdat_info' 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[0;32m----> 1\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[0mcdat_info\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_sampledata_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\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[0m\u001b[1;32m 2\u001b[0m \u001b[0mclt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'clt'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mrectgrid\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mclt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mgetGrid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mrectgrid\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\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 'cdat_info' is not defined" - ] - } - ], + "outputs": [], "source": [ "f = cdms2.open(cdat_info.get_sampledata_path()+'/clt.nc')\n", "clt = f('clt')\n", @@ -1344,36 +836,9 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/cdms2/avariable.py:1341: Warning: \n", - "avariable.regrid: We chose regridTool = esmf for you among the following choices:\n", - " Tools -> 'regrid2' (old behavior)\n", - " 'esmf' (conserve, patch, linear) or\n", - " 'libcf' (linear)\n", - " warnings.warn(message, Warning)\n", - "/export/reshel3/anaconda52/envs/cdms2/lib/python2.7/site-packages/cdms2/avariable.py:1348: Warning: \n", - "avariable.regrid: We chose regridMethod = linear for you among the following choices:\n", - " 'conserve' or 'linear' or 'patch'\n", - " warnings.warn(message, Warning)\n" - ] - }, - { - "data": { - "text/plain": [ - "(1, 2, 96, 192)" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "f = cdms2.open('clt.nc')\n", "u = f('u')\n", @@ -1393,21 +858,9 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "metadata": {}, - "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[0muold\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\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" - ] - } - ], + "outputs": [], "source": [ "f = cdms2.open('clt.nc')\n", "uold = f('u')\n", @@ -1456,23 +909,9 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "CDMSError", - "evalue": "Cannot open file /export/reshel3/cdms/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/export/reshel3/anaconda52/envs/cdms2/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 494\u001b[0m \u001b[0;31m# rank\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 495\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--> 496\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 497\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 498\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/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 1276\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 1277\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-> 1278\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 1279\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 1280\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 /export/reshel3/cdms/sampleT42Grid.nc (Variable not found)" - ] - } - ], + "outputs": [], "source": [ "# Import regrid package for regridder functions\n", "import regrid2, cdms2\n", @@ -1520,20 +959,9 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'days since 1996-1-1'" - ] - }, - "execution_count": 38, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "import cdtime\n", "rt = cdtime.reltime(28.0, \"days since 1996-1-1\")\n", @@ -1554,20 +982,9 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "2" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "ct = cdtime.comptime(1996,2,28,12,10,30)\n", "ct\n", @@ -1589,20 +1006,9 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "4018.0" - ] - }, - "execution_count": 40, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "ct = cdtime.comptime(1990,1)\n", "rt = ct.torel(\"days since 1979\")\n", @@ -1620,21 +1026,9 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'cdat_info' 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[0;32m----> 1\u001b[0;31m \u001b[0mfh\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[0mcdat_info\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_sampledata_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"/tas_6h.nc\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mc1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcdtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcomptime\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1980\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mc2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcdtime\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcomptime\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1980\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mtas\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfh\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'tas'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mtas\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mNameError\u001b[0m: name 'cdat_info' is not defined" - ] - } - ], + "outputs": [], "source": [ "fh = cdms2.open(cdat_info.get_sampledata_path() + \"/tas_6h.nc\")\n", "c1 = cdtime.comptime(1980,1)\n", @@ -1655,21 +1049,9 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'cdat_info' 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[0;32m----> 1\u001b[0;31m \u001b[0mfh\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[0mcdat_info\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_sampledata_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"/tas_6h.nc\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mtas\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfh\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'tas'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtas\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubRegion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtime\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'1980-1'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'1980-2'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mNameError\u001b[0m: name 'cdat_info' is not defined" - ] - } - ], + "outputs": [], "source": [ "fh = cdms2.open(cdat_info.get_sampledata_path() + \"/tas_6h.nc\")\n", "tas = fh['tas']\n", @@ -1704,23 +1086,9 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "CDMSError", - "evalue": "Cannot open file /export/reshel3/anaconda52/envs/cdms2/share/uvcdat/sample_data/tas_cru_1979.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 1\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mcdms2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvcs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcdat_info\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mfh\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[0mcdat_info\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_sampledata_path\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"/tas_cru_1979.nc\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mfh\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'time'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;31m# Print the time coordinates\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\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;32m/export/reshel3/anaconda52/envs/cdms2/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 494\u001b[0m \u001b[0;31m# rank\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 495\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--> 496\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 497\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 498\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;32m/export/reshel3/anaconda52/envs/cdms2/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 1276\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 1277\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-> 1278\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 1279\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 1280\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 /export/reshel3/anaconda52/envs/cdms2/share/uvcdat/sample_data/tas_cru_1979.nc (Variable not found)" - ] - } - ], + "outputs": [], "source": [ "import cdms2, vcs, cdat_info\n", "fh=cdms2.open(cdat_info.get_sampledata_path() + \"/tas_cru_1979.nc\")\n", @@ -1778,21 +1146,9 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'cdms' 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[0;32m----> 1\u001b[0;31m \u001b[0mdb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcdms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconnect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Connect to the default database.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdb\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'ncep_reanalysis_mo'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# Open a dataset.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvariables\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkeys\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# List the variables in the dataset.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mNameError\u001b[0m: name 'cdms' is not defined" - ] - } - ], + "outputs": [], "source": [ "db = cdms.connect() # Connect to the default database.\n", "f = db.open('ncep_reanalysis_mo') # Open a dataset.\n", diff --git a/regrid2/Lib/crossSection.py b/regrid2/Lib/crossSection.py index 6a63d2ea..39ad338e 100644 --- a/regrid2/Lib/crossSection.py +++ b/regrid2/Lib/crossSection.py @@ -9,17 +9,17 @@ class CrossSectionRegridder: - """ - + """ + PURPOSE: To perform all the tasks required to regrid the input data into the ouput data in the latitude-level plane for all times - + PROCEDURE: Step One: Make an instance of class CrossSectionRegridder passing it input and output grid information Step Two: Pass the input data with some descriptive parameters and get the output data in return - + """ def __init__(self, latIn, latOut, levIn, levOut, latTypeIn=None, latSizeIn=None, @@ -543,23 +543,23 @@ 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 - + **Parameters:** - + x - coordinate vector name - coordinate vector ID - + **Returns:** - + x, xsize -- dimension vector and its size """ @@ -611,32 +611,23 @@ def generic_wts_bnds(lat): def get_latitude_wts_bnds(checklatpass): - """ - - **Routine:** - - get_latitude_wts_bnds - - **Purpose:** + """ + get_latitude_wts_bnds - Compare the passed checklatpass with the correct geophysical ones calculated here. After finding a match call the function to get the bounds. - - **Usage:** + Compare the passed checklatpass with the correct geophysical ones + calculated here. After finding a match call the function to get the bounds. - wts,bnds = get_latitude_wts_bnds(checklatpass) - where + wts,bnds = get_latitude_wts_bnds(checklatpass) - **Parameters:** - - checklatpass: + Parameters + ---------- + checklatpass: + is the grid to check - is the grid to check - + Returns + ------- + wts, bnds - tuple with weights and bounds - **Returns:** - - wts, bnds - tuple with weights and bounds - """ small = 0.001 # use as tolerance in checking values @@ -716,18 +707,18 @@ 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:** + + **Returns:** tuple ( bn,bs ) - + """ latbnds = lat_bnds.astype(numpy.float32) @@ -743,27 +734,27 @@ def latitude_bounds(lat_bnds): def get_region_latitude_wts_bnds(latRegionpass, latType, latSize): - """ + """ - **Routine:** + **Routine:** get_region_latitude_wts_bnds - - **Purpose:** + + **Purpose:** compare the passed latitudes, latRegion, with the global ones calculated here and extract the wts and bounds for the region - + **Usage:** wts,bnds = get_region_latitude_wts_bnds(latRegion, latType, latSize) where latRegion is the regional grid to check - - **Returns:** + + **Returns:** wts, bnds - tuple with weights and bounds - + """ latTypeList = ['gaussian', 'equalarea', 'uniform', 'generic'] @@ -836,16 +827,16 @@ def get_region_latitude_wts_bnds(latRegionpass, latType, latSize): def sectionmask(dataIn, positionIn, maskIn, missingValueIn, missingMatch): - """ - - **Purpose:** + """ + + **Purpose:** construct the mask for the input data for use by rgdlength - - **Usage:** + + **Usage:** amskin = mask(dataIn, positionIn, maskIn, missingValueIn, missingValueOut, flag2D) - + **Returns:** amskin @@ -1016,22 +1007,22 @@ def sectionmask(dataIn, positionIn, maskIn, missingValueIn, missingMatch): def sendmsg(msg, value1=None, value2=None): - """ - - **Purpose:** + """ + + **Purpose:** send the same message to the screen - + **Passed:** msg - the string - + value - the number associated with the string - + **Returns:** return - + """ print('*******************************************************************') @@ -1047,20 +1038,20 @@ def sendmsg(msg, value1=None, value2=None): def section(latvals, levvals): - """ - + """ + **Purpose:** make the crossi section analytical test case - + **Passed:** - + the grid coordinate vectors - - **Returns:** + + **Returns:** xsection -- a temerature like cross section - + """ nlev = len(levvals) @@ -1083,22 +1074,22 @@ def section(latvals, levvals): def rmserror(data1, data2): - """ - - **Purpose:** + """ + + **Purpose:** compute the rms error for two data sets having the same shape - - **Passed:** + + **Passed:** the two data sets - + **Returns:** rms error - + """ if data1.shape != data2.shape: diff --git a/regrid2/Lib/crossSection.py.orig b/regrid2/Lib/crossSection.py.orig index 0d53ea48..f758f77a 100644 --- a/regrid2/Lib/crossSection.py.orig +++ b/regrid2/Lib/crossSection.py.orig @@ -543,23 +543,23 @@ class CrossSectionRegridder: def checkdimension(x, name): - """ + """ purpose: dimension checks 1. has a len method 2. data type is float32 3. monotonically increasing vectors - + Parameters ---------- x - coordinate vector name - coordinate vector ID - + Returns ------- - + x, xsize -- dimension vector and its size - + """ data = x[:] diff --git a/regrid2/Lib/esmf.py b/regrid2/Lib/esmf.py index e0ac02de..f6d49656 100644 --- a/regrid2/Lib/esmf.py +++ b/regrid2/Lib/esmf.py @@ -39,12 +39,12 @@ class EsmfUnstructGrid: """ Constructor - Parameters + Parameters ---------- - numTopoDims + numTopoDims number of topological dimensions - numSpaceDims + numSpaceDims number of space dimensions """ @@ -71,7 +71,7 @@ def __init__(self, numTopoDims, numSpaceDims): def setCells(self, cellIndices, cellTypes, connectivity, cellMask=None, cellAreas=None): - """ + """ Set Cell connectivity. **Parameters** @@ -93,12 +93,12 @@ def setCells(self, cellIndices, cellTypes, connectivity, :: - 3 4-------------3 - /\ | | - / \ | | - / \ | | - / \ | | - / \ | | + 3 4-------------3 + /\ | | + / \ | | + / \ | | + / \ | | + / \ | | / \ | | 1------------2 1-------------2 @@ -118,7 +118,7 @@ def setCells(self, cellIndices, cellTypes, connectivity, \|/ |/ |/ 1 1---------------2 - ESMF_MESHELEMTYPE_TETRA ESMF.MESHELEMTYPE_HEX + ESMF_MESHELEMTYPE_TETRA ESMF.MESHELEMTYPE_HEX """ n = len(cellIndices) @@ -326,7 +326,7 @@ def setCoords(self, coords, staggerloc=CENTER, globalIndexing=False): if True array was allocated over global index space, otherwise array was allocated over local index space on this processor. This is only relevant if rootPe is None - Note + Note ---- coord dims in cdms2 are ordered in y, x, but ESMF expects x, y, hence the dimensions are reversed here. """ @@ -414,7 +414,7 @@ def setMask(self, mask, staggerloc=CENTER): Returns ------- mask numpy array - 1 is invalid by default + 1 is invalid by default Note @@ -445,7 +445,7 @@ class EsmfStructField: Parameters ---------- - esmfGrid + esmfGrid instance of an ESMF name field @@ -522,7 +522,8 @@ def getData(self, rootPe): Parameters ---------- rootPe : - if None then local data will be fetched, otherwise gather the data on processor "rootPe" (all other procs will return None). + if None then local data will be fetched, otherwise gather the + data on processor "rootPe" (all other procs will return None). Returns ------- @@ -572,16 +573,18 @@ def setLocalData(self, data, staggerloc, globalIndexing=False): """ Set local field data - **Parameters:** - - data - full numpy array, this method will take care of setting a the subset of the data that reside on the local processor + Parameters + ---------- + data : + full numpy array, this method will take care of setting + a the subset of the data that reside on the local processor - staggerloc - stagger location of the data + staggerloc : + stagger location of the data - globalIndexing - if True array was allocated over global index space, array was allocated over local index space (on this processor) + globalIndexing : + if True array was allocated over global index space, array + was allocated over local index space (on this processor) """ ptr = self.field.data if globalIndexing: @@ -601,33 +604,24 @@ class EsmfRegrid: Parameters ---------- - - srcField - the source field object of type EsmfStructFields - - dstField - the destination field object of type EsmfStructField - - srcMaskValues - Value of masked cells in source - - dstMaskValues - Value of masked cells in destination - - srcFrac - Cell fractions on source grid (type EsmfStructField) - - dstFrac - Cell fractions on destination grid (type EsmfStructField) - - regridMethod - ESMF.RegridMethod.{BILINEAR,CONSERVE,PATCH} - - unMappedAction - ESMF.UnmappedAction.{IGNORE,ERROR} - - ignoreDegenerate - Ignore degenerate cells when checking inputs + srcField : + the source field object of type EsmfStructFields + dstField : + the destination field object of type EsmfStructField + srcMaskValues : + Value of masked cells in source + dstMaskValues : + Value of masked cells in destination + srcFrac : + Cell fractions on source grid (type EsmfStructField + dstFrac : + Cell fractions on destination grid (type EsmfStructField) + regridMethod : + ESMF.RegridMethod.{BILINEAR,CONSERVE,PATCH} + unMappedAction : + ESMF.UnmappedAction.{IGNORE,ERROR} + ignoreDegenerate : + Ignore degenerate cells when checking inputs """ def __init__(self, srcField, dstField, diff --git a/regrid2/Lib/gsRegrid.py b/regrid2/Lib/gsRegrid.py index 53c42ff8..84469033 100644 --- a/regrid2/Lib/gsRegrid.py +++ b/regrid2/Lib/gsRegrid.py @@ -48,7 +48,7 @@ def getTensorProduct(axis, dim, dims): Parameters ---------- - axis + axis 1D array of coordinates dim @@ -296,7 +296,7 @@ def handleCoordsCut(coords, dims, bounds): """ Generate connectivity across a cut. e.g. from a tri-polar grid. Assume latitude is next to last coordinate and longitude is last coordinate!!! - + Parameters ---------- @@ -376,30 +376,30 @@ class Regrid: Parameters ---------- - src_grid - source grid, a list of [x, y, ...] coordinates or a cdms2.grid.Transient - - dst_grid - destination grid, a list of [x, y, ...] coordinates - - src_bounds - list of cell bounding coordinates (to be used when handling a cut in coordinates) - - mkCyclic - Add a column to the right side of the grid to complete a cyclic grid - - handleCut - Add a row to the top of grid to handle a cut for grids such as the tri-polar grid verbose print diagnostic messages - - - Note: the grid coordinates can either be axes (rectilinear grid) or n-dimensional for curvilinear grids. Rectilinear grids will be converted to curvilinear grids. + src_grid + source grid, a list of [x, y, ...] coordinates or a cdms2.grid.Transient + dst_grid + destination grid, a list of [x, y, ...] coordinate + src_bounds + list of cell bounding coordinates (to be used when handling a cut in coordinates) + mkCyclic + Add a column to the right side of the grid to complete a cyclic grid + handleCut + Add a row to the top of grid to handle a cut for grids such as the tri-polar + grid verbose print diagnostic messages + + Note + ---- + the grid coordinates can either be axes (rectilinear grid) or n-dimensional + for curvilinear grids. Rectilinear grids will be converted to curvilinear grids. """ + def __init__(self, src_grid, dst_grid, src_bounds=None, mkCyclic=False, handleCut=False, verbose=False): """ Constructor - + """ self.regridid = c_int(-1) self.src_gridid = c_int(-1) @@ -644,7 +644,7 @@ def setMask(self, inDataOrMask): Parameters ---------- - inDataOrMask + inDataOrMask cdms2 array or flat mask array, 0 - valid data 1 - invalid data @@ -652,7 +652,7 @@ def setMask(self, inDataOrMask): _: None Note: this definition is compatible with the numpy masked arrays - + Note: note see setValidMask for the opposite definition Note: should be called before computing the weights @@ -672,7 +672,7 @@ def setMask(self, inDataOrMask): def computeWeights(self, nitermax=100, tolpos=1.e-2): """ Compute the the interpolation weights - + Parameters ---------- @@ -702,7 +702,8 @@ def apply(self, src_data_in, dst_data, missingValue=None): data on destination grid missingValue - value that should be set for points falling outside the src domain, pass None if these should not be touched. + value that should be set for points falling outside + the src domain, pass None if these should not be touched. """ if not self.weightsComputed: raise RegridError('Weights must be set before applying the regrid') @@ -823,7 +824,8 @@ def __call__(self, src_data, dst_data, missingValue=None): data on destination grid missingValue - value that should be set for points falling outside the src domain, pass None if these should not be touched. + value that should be set for points falling outside the src domain, + pass None if these should not be touched. """ self.apply(src_data, dst_data, missingValue) @@ -926,16 +928,12 @@ def _extend(self, src_data): Parameters ---------- - - src_data - input source data - - _: None + src_data : + input source data Returns ------- - - extended source data (or source input data of no padding was applied) + extended source data (or source input data of no padding was applied) """ # nlatX, nlonX = self.src_dims[-2], self.src_dims[-1] @@ -974,7 +972,7 @@ def _findIndices(self, targetPos, nitermax, tolpos, targetPos numpy array of target positions - + nitermax max number of iterations diff --git a/regrid2/Lib/horizontal.py b/regrid2/Lib/horizontal.py index c48c505b..329a281a 100644 --- a/regrid2/Lib/horizontal.py +++ b/regrid2/Lib/horizontal.py @@ -96,20 +96,22 @@ def __call__(self, ar, missing=None, order=None, Parameters ---------- - ar - is the input array. + ar : + is the input array. - order - is of the form "tzyx", "tyx", etc. + order : + is of the form "tzyx", "tyx", etc. - missing - is the missing data value, if any. + missing : + is the missing data value, if any. - mask - is either 2-D or the same shape as ar. + mask : + is either 2-D or the same shape as ar. - returnTuple - If true, return the tuple (outArray, outWeights) where outWeights is the fraction of each zone of the output grid which overlaps non-missing zones of the input grid; it has the same shape as the output array. + returnTuple : + If true, return the tuple (outArray, outWeights) where outWeights is + the fraction of each zone of the output grid which overlaps non-missing + zones of the input grid; it has the same shape as the output array. """ from cdms2.avariable import AbstractVariable @@ -376,7 +378,7 @@ def __init__(self, ingrid, outgrid): def input_mask(ain, type, mask, missing=None): - """ + """ set up the input mask including missing from ain """ if type != 'h' and type != 'v': diff --git a/regrid2/Lib/mvESMFRegrid.py b/regrid2/Lib/mvESMFRegrid.py index 1e388a91..f54875e3 100644 --- a/regrid2/Lib/mvESMFRegrid.py +++ b/regrid2/Lib/mvESMFRegrid.py @@ -39,11 +39,11 @@ class ESMFRegrid(GenericRegrid): """ Regrid class for ESMF Constructor - + Parameters ---------- - srcGridShape + srcGridShape tuple source grid shape dstGridShape @@ -83,7 +83,7 @@ def __init__(self, srcGridshape, dstGridshape, dtype, ignoreDegenerate=False, **args): """ - + """ # esmf grid objects (tobe constructed) @@ -222,34 +222,28 @@ def setCoords(self, srcGrid, dstGrid, """ Populator of grids, bounds and masks - **Parameters:** - - srcGrid - list [[z], y, x] of source grid arrays - - dstGrid - list [[z], y, x] of dstination grid arrays - - srcGridMask - list [[z], y, x] of arrays - - srcBounds - list [[z], y, x] of arrays - - srcGridAreas - list [[z], y, x] of arrays - - dstGridMask - list [[z], y, x] of arrays - - dstBounds - list [[z], y, x] of arrays - - dstGridAreas - list [[z], y, x] of arrays - - globalIndexing - if True array was allocated over global index space, otherwise array was allocated over local index space on this processor. This is only relevant if rootPe is None + Parameters + ---------- + srcGrid + list [[z], y, x] of source grid arrays + dstGrid + list [[z], y, x] of dstination grid arrays + srcGridMask + list [[z], y, x] of arrays + srcBounds + list [[z], y, x] of arrays + srcGridAreas + list [[z], y, x] of arrays + dstGridMask + list [[z], y, x] of array + dstBounds + list [[z], y, x] of arrays + dstGridAreas + list [[z], y, x] of arrays + globalIndexing + if True array was allocated over global index space, + otherwise array was allocated over local index space on + this processor. This is only relevant if rootPe is None """ # create esmf source Grid @@ -326,10 +320,12 @@ def apply(self, srcData, dstData, rootPe, globalIndexing=False, **args): the dstData returns None. Source data mask: - - . If you provide srcDataMask in args the source grid will be masked and weights will be recomputed. - . Subsequently, if you do not provide a srcDataMask the last weights will be used to regrid the source data array. + . If you provide srcDataMask in args the source grid will be + masked and weights will be recomputed. + + . Subsequently, if you do not provide a srcDataMask the last weights will + be used to regrid the source data array. . By default, only the data are masked, but not the grid. @@ -346,7 +342,8 @@ def apply(self, srcData, dstData, rootPe, globalIndexing=False, **args): if other than None, then data will be MPI gathered on the specified rootPe processor globalIndexing - if True array was allocated over global index space, otherwise array was allocated over local index space on this processor. This is only relevant if rootPe is None + if True array was allocated over global index space, otherwise array was allocated + over local index space on this processor. This is only relevant if rootPe is None **args """ @@ -373,7 +370,10 @@ def apply(self, srcData, dstData, rootPe, globalIndexing=False, **args): self.dstFld.field.data[:] = dstData.T # regrid - self.regridObj(self.srcFld.field, self.dstFld.field, zero_region=zero_region) + self.regridObj( + self.srcFld.field, + self.dstFld.field, + zero_region=zero_region) # fill in dstData if rootPe is None and globalIndexing: @@ -390,7 +390,7 @@ def apply(self, srcData, dstData, rootPe, globalIndexing=False, **args): def getDstGrid(self): """ Get the destination grid on this processor - + Returns ------- grid @@ -432,7 +432,7 @@ def getDstAreas(self, rootPe): _: None - + Returns ------- @@ -446,7 +446,7 @@ def getDstAreas(self, rootPe): def getSrcAreaFractions(self, rootPe): """ - Get the source grid area fractions + Get the source grid area fractions Parameters ---------- @@ -455,7 +455,7 @@ def getSrcAreaFractions(self, rootPe): root processor where data should be gathered (or None if local areas are to be returned) _: None - + Returns ------- @@ -473,7 +473,7 @@ def getDstAreaFractions(self, rootPe): Parameters ---------- - + rootPe root processor where data should be gathered (or None if local areas are to be returned) @@ -544,7 +544,7 @@ def getDstLocalShape(self, staggerLoc): def getSrcLocalSlab(self, staggerLoc): """ - Get the destination local slab (ellipsis). You can use this to grab the data + Get the destination local slab (ellipsis). You can use this to grab the data local to this processor Parameters @@ -584,7 +584,7 @@ def getDstLocalSlab(self, staggerLoc): Returns ------- - + tuple of slices """ stgloc = CENTER @@ -604,8 +604,9 @@ def fillInDiagnosticData(self, diag, rootPe): ---------- diag - a dictionary whose entries, if present, will be filled valid entries are: 'srcAreaFractions', 'dstAreaFractions', srcAreas', 'dstAreas' - + a dictionary whose entries, if present, will be filled valid + entries are: 'srcAreaFractions', 'dstAreaFractions', srcAreas', 'dstAreas' + rootPe root processor where data should be gathered (or None if local areas are to be returned) """ diff --git a/regrid2/Lib/mvGenericRegrid.py b/regrid2/Lib/mvGenericRegrid.py index d5da987d..23786c12 100644 --- a/regrid2/Lib/mvGenericRegrid.py +++ b/regrid2/Lib/mvGenericRegrid.py @@ -23,9 +23,9 @@ def guessPeriodicity(srcBounds): Guess if a src grid is periodic **Parameters:** - + srcBounds - the nodal src set of coordinates + the nodal src set of coordinates **Returns:** @@ -55,7 +55,7 @@ class GenericRegrid: Parameters ---------- - + srcGrid list of numpy arrays, source horizontal coordinates @@ -102,7 +102,7 @@ def __init__(self, srcGrid, dstGrid, dstGridMask=None, dstBounds=None, dstGridAreas=None, **args): """ - + """ self.nGridDims = len(srcGrid) @@ -197,7 +197,7 @@ def apply(self, srcData, dstData, Regrid source to destination **Parameters:** - + srcData array (input) @@ -344,7 +344,7 @@ def getDstGrid(self): to the constructor due to domain decomposition **Returns:** - + local grid on this processor """ return self.tool.getDstGrid() @@ -354,8 +354,8 @@ def fillInDiagnosticData(self, diag, rootPe=None): Fill in diagnostic data **Parameters:** - - diag + + diag a dictionary whose entries, if present, will be filled entries are tool dependent rootPe diff --git a/regrid2/Lib/mvLibCFRegrid.py b/regrid2/Lib/mvLibCFRegrid.py index c0e88b39..14935460 100644 --- a/regrid2/Lib/mvLibCFRegrid.py +++ b/regrid2/Lib/mvLibCFRegrid.py @@ -58,7 +58,7 @@ def __init__(self, srcGrid, dstGrid, srcGridMask=None, def computeWeights(self, **args): """ Compute interpolation weights - + Parameters ---------- @@ -75,26 +75,24 @@ def apply(self, srcData, dstData, missingValue=None, **args): Parameters ---------- - - srcData - array (input) - - dstData - array (output) - - missingValue - value that should be set for points falling outside the src domain, pass None if these should not be touched. + srcData : + array (input) + dstData : + array (output) + missingValue : + value that should be set for points falling outside + the src domain, pass None if these should not be touched. """ self.regridObj.apply(srcData, dstData, missingValue) def getSrcGrid(self): """ - Get the grid of the src data (maybe larger than the dst grid passed to the constructor due to column/row padding) + Get the grid of the src data (maybe larger than the dst + grid passed to the constructor due to column/row padding) Returns ------- - grid """ return self.regridObj.getSrcGrid() @@ -102,7 +100,7 @@ def getSrcGrid(self): def getDstGrid(self): """ Get the grid of the dst data - + Returns ------- grid @@ -112,11 +110,11 @@ def getDstGrid(self): def fillInDiagnosticData(self, diag, rootPe): """ Fill in diagnostic data - + Parameters ---------- - diag + diag a dictionary whose entries, if present, will be filled valid entries are: 'numDstPoints' and 'numValid' rootPe not used diff --git a/regrid2/Lib/pressure.py b/regrid2/Lib/pressure.py index 2984148e..42b632f2 100644 --- a/regrid2/Lib/pressure.py +++ b/regrid2/Lib/pressure.py @@ -8,7 +8,8 @@ class PressureRegridder: - """ #----------------------------------------------------------------------------------------------- + """ + #----------------------------------------------------------------------------------------------- # # PURPOSE: To perform all the tasks required to regrid the input data into the ouput data along # the pressure dimension only. @@ -19,10 +20,12 @@ class PressureRegridder: # Pass the input data with some descriptive parameters and get the output data # in return # - #------------------------------------------------------------------------------------------------""" + #------------------------------------------------------------------------------------------------ + """ def __init__(self, axisIn, axisOut): - """ #----------------------------------------------------------------------------------------------- + """ + #----------------------------------------------------------------------------------------------- # # PURPOSE: To make an instance which entails setting up the input and output grids # @@ -44,7 +47,8 @@ def __init__(self, axisIn, axisOut): # # r = PressureRegridder(levIn, levOut) # - #------------------------------------------------------------------------------------------------""" + #------------------------------------------------------------------------------------------------ + """ # --- set the instance grid data attributes used to describe input and output grid sizes @@ -427,22 +431,24 @@ def checkorder(positionIn): """ **Purpose:** - construct the tuples for transposing the data to standard dimension order and the inverse for transposing it back to the original dimension order - + construct the tuples for transposing the data to standard dimension + order and the inverse for transposing it back to the original dimension order + **Usage:** newOrder, inverseOrder = checkorder(positionIn) - + **Passed:** - - positionIn -- array with location of longitude, latitude. level and time respectively in the sense of the python shape of the data - + + positionIn -- array with location of longitude, latitude. level and time + respectively in the sense of the python shape of the data + **Returns:** newOrder -- tuple to transpose data to the order (t,z,y,x) - + inverseOrder -- tuple to transpose data to back to the original order - + """ # remove the None values from positionIn and reverse the order @@ -473,21 +479,21 @@ def checkorder(positionIn): def sendmsg(msg, value1=None, value2=None): - """ - **Purpose:** - + """ + **Purpose:** + send the same message to the screen - - **Passed:** + + **Passed:** msg - the string value - the number associated with the string - + **Returns:** return - + """ print('*******************************************************************') diff --git a/regrid2/Lib/scrip.py b/regrid2/Lib/scrip.py index ccb37a5a..ae08e76b 100644 --- a/regrid2/Lib/scrip.py +++ b/regrid2/Lib/scrip.py @@ -113,7 +113,7 @@ class ConservativeRegridder(ScripRegridder): If 'normal' is specified, it should be a one-dimensional array of the same length as the output grid size, with values: - + 1.0 for normalize="fracarea", grid_frac for normalize="destarea", or @@ -217,7 +217,7 @@ class BicubicRegridder(ScripRegridder): Parameters ---------- - gradLat: + gradLat: df/di gradLon: @@ -372,14 +372,14 @@ def readRegridder(fileobj, mapMethod=None, checkGrid=1): """Read a regridder from an open fileobj. **Parameters:** - + mapMethod is one of "conservative", "bilinear", "bicubic", or "distwgt". 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 isinstance(fileobj, str): diff --git a/tests/test_cdms_info.py b/tests/test_cdms_info.py index 82a96b27..5a618097 100644 --- a/tests/test_cdms_info.py +++ b/tests/test_cdms_info.py @@ -8,7 +8,7 @@ def testInfo(self): f = cdms2.open(os.path.join(cdat_info.get_sampledata_path(),"clt.nc")) s=f("clt") s.info() - def testAxis(self): + def tstAxis(self): axis = cdms2.createAxis(cdms2.createVariable([10.], id='height', missing=1e20)) print(axis)