diff --git a/.travis.yml b/.travis.yml index 3513f16..5e3c289 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,13 @@ os: - - linux + - linux + +language: python + +python: + - "2.7" + sudo: false + before_install: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then wget https://repo.continuum.io/miniconda/Miniconda2-4.3.21-Linux-x86_64.sh -O miniconda.sh; fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then wget https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh -O miniconda.sh; fi @@ -10,7 +17,8 @@ before_install: - conda update -y -q conda #- conda install gcc script: -- conda create -n py2 -c uvcdat/label/nightly -c conda-forge genutil nose flake8 "numpy=1.13" netcdf-fortran=4.4.4=3 +# ======= +- conda create -n py2 -c uvcdat/label/nightly -c conda-forge genutil nose flake8 "numpy=1.13" - export UVCDAT_ANONYMOUS_LOG=False - echo $TRAVIS_BRANCH - export TRAVIS_PR_BRANCH=$TRAVIS_BRANCH @@ -20,7 +28,8 @@ script: - python setup.py install - python run_tests.py -v2 - rm -rf build -- conda create -n py3 -c uvcdat/label/nightly -c conda-forge -c nesii/channel/dev-esmf genutil nose flake8 "python>3" "numpy=1.13" netcdf-fortran=4.4.4=3 +# netcdf-fortran 4.4.4=6 (3 is no longer avail) +- conda create -n py3 -c uvcdat/label/nightly -c conda-forge -c nesii/channel/dev-esmf genutil nose flake8 "python>3" "numpy=1.13" - source activate py3 - python setup.py install - python run_tests.py -v2 diff --git a/Lib/region.py b/Lib/region.py index 3c967c4..af97d44 100644 --- a/Lib/region.py +++ b/Lib/region.py @@ -1,6 +1,7 @@ # Adapted for numpy/ma/cdms2 by convertcdms.py from cdms2.selectors import SelectorComponent import cdat_info +import warnings class DomainComponent(SelectorComponent): @@ -61,6 +62,9 @@ def specify(self, slab, axes, specification, confined_by, aux): confined_by[i] = self # How do we want to confine this dim ? self.aux[i] = specs = list(self.args[i]) + if len(specs) > 2: + warnings.warn( + "Only axis bounds (min, max) can be specified for axis, other arguments are ignored.") if isinstance(specs, type(slice(0))): specification[i] = specs # If it's a slicing nothing to do else: # But if it's not... @@ -133,6 +137,9 @@ def specify(self, slab, axes, specification, confined_by, aux): confined_by[axis] = self myconfined[axis] = 1 self.aux[axis] = specs = list(self.kargs[kw]) + if len(specs) > 2: + warnings.warn( + "Only axis bounds (min, max) can be specified for axis, other arguments are ignored.") if not isinstance(specs, type(slice(0))): if specs[0] is None: tmp = axes[axis].getBounds() diff --git a/Lib/times.py b/Lib/times.py index 82f6258..542ba91 100644 --- a/Lib/times.py +++ b/Lib/times.py @@ -1024,9 +1024,9 @@ def dayBasedSlicer(tim, arg=None): def weekday(a, calendar=None): if calendar is None: - b = a.torel('days since 0') + b = a.torel('days since 1') else: - b = a.torel('days since 0', calendar) + b = a.torel('days since 1', calendar) d = (b.value - 3) % 7 if d == 1: return 'monday' @@ -1565,11 +1565,11 @@ def climatology(self, slab, criteriaarg=None, months[0] = months[0] - 12 v1 = cdtime.reltime( months[0] - 1, - 'months since 0').torel( - 'days since 0', + 'months since 1').torel( + 'days since 1', timecalendar) v2 = cdtime.reltime(months[-1], - 'months since 0').torel('days since 0', + 'months since 1').torel('days since 1', timecalendar) vals[i] = float(v1.value + v2.value) / 2. bnds[i] = [v1.value, v2.value] @@ -1608,7 +1608,7 @@ def climatology(self, slab, criteriaarg=None, statusbar.pop(0) t = cdms2.createAxis(vals, bounds=bnds) t.id = 'time' - t.units = 'days since 0' + t.units = 'days since 1' t.designateTime() t.setCalendar(tim.getCalendar()) ax = slab.getAxisList() diff --git a/ci-support/circleci_mac_dep.sh b/ci-support/circleci_mac_dep.sh index fe4057c..afc9cd2 100644 --- a/ci-support/circleci_mac_dep.sh +++ b/ci-support/circleci_mac_dep.sh @@ -2,8 +2,8 @@ ls pwd export PATH=${HOME}/miniconda/bin:${PATH} -conda create -n py3 -c uvcdat/label/nightly -c conda-forge -c nadeau1 genutil nose flake8 "python>3" "numpy=1.13" netcdf-fortran=4.4.4=3 -conda create -n py2 -c uvcdat/label/nightly -c conda-forge genutil nose flake8 "numpy=1.13" netcdf-fortran=4.4.4=3 +conda create -n py3 -c nesii/label/dev-esmf -c uvcdat/label/nightly -c conda-forge genutil nose flake8 "python>3" "numpy=1.13" +conda create -n py2 -c nesii/label/dev-esmf -c uvcdat/label/nightly -c conda-forge genutil nose flake8 "numpy=1.13" export UVCDAT_ANONYMOUS_LOG=False source activate py3 python setup.py install diff --git a/ci-support/conda_upload.sh b/ci-support/conda_upload.sh index ed86243..7628de4 100755 --- a/ci-support/conda_upload.sh +++ b/ci-support/conda_upload.sh @@ -4,15 +4,14 @@ USER=uvcdat VERSION="2.12" export PATH="$HOME/miniconda/bin:$PATH" echo "Trying to upload conda" +ESMF_CHANNEL="nesii/label/dev-esmf" if [ $(uname) == "Linux" ]; then OS=linux-64 echo "Linux OS" conda update -y -q conda - ESMF_CHANNEL="nesii/label/dev-esmf" else echo "Mac OS" OS=osx-64 - ESMF_CHANNEL="nadeau1" fi mkdir ~/conda-bld diff --git a/tests/test_cdutil_selectRegion.py b/tests/test_cdutil_selectRegion.py new file mode 100644 index 0000000..b3a523c --- /dev/null +++ b/tests/test_cdutil_selectRegion.py @@ -0,0 +1,27 @@ +import cdutil +import cdat_info +import cdms2 +import cdms2,cdutil,sys,MV2,numpy,os,cdat_info +import unittest +import numpy +import tempfile + +class CDUTIL(unittest.TestCase): + + def testRegions(self): + + regionNA = cdutil.region.domain(latitude=(-50.,50.,'ccb')) + f=cdms2.open(cdat_info.get_sampledata_path()+'/clt.nc') + d=f('u', regionNA) + + # -------------------------------------------------------- + # makesure the warning has been displayed for the 3rd args + # -------------------------------------------------------- + + bounds = d.getLatitude().getBounds() + self.assertTrue(numpy.allclose(bounds[0], numpy.array([-50., -49.19124603]))) + self.assertTrue(numpy.allclose(bounds[-1], numpy.array([49.19124603, 50.]))) + +if __name__ == "__main__": + unittest.main() +