diff --git a/Packages/cdutil/Lib/times.py b/Packages/cdutil/Lib/times.py index 14d56da969..05b4ef92a1 100644 --- a/Packages/cdutil/Lib/times.py +++ b/Packages/cdutil/Lib/times.py @@ -1356,7 +1356,7 @@ def climatology(self,slab,criteriaarg=None,criteriaargclim=None,statusbar=None,s ''' cdat_info.pingPCMDIdb("cdat","cdutil.times.Seasons.climatology -%s-" % self.seasons) u=self.month_fix(slab) - if criteriaargclim is None: criteriaargclim=criteriaarg + #if criteriaargclim is None: criteriaargclim=criteriaarg order=slab.getOrder(ids=1) initialgrid = slab.getGrid() diff --git a/testing/cdutil/CMakeLists.txt b/testing/cdutil/CMakeLists.txt index 359550bf22..defc104f7c 100644 --- a/testing/cdutil/CMakeLists.txt +++ b/testing/cdutil/CMakeLists.txt @@ -49,6 +49,9 @@ if(CDAT_DOWNLOAD_SAMPLE_DATA) add_test("test_years" "${PYTHON_EXECUTABLE}" ${cdat_SOURCE_DIR}/testing/cdutil/test_years.py) + add_test("test_djf_criteria" + "${PYTHON_EXECUTABLE}" + ${cdat_SOURCE_DIR}/testing/cdutil/test_djf_criteria.py) endif() # Tests which should fail diff --git a/testing/cdutil/test_djf_criteria.py b/testing/cdutil/test_djf_criteria.py new file mode 100644 index 0000000000..7cefc49a90 --- /dev/null +++ b/testing/cdutil/test_djf_criteria.py @@ -0,0 +1,34 @@ +import cdms2 +import numpy + +data = [1,]*12+[2,]*12 + +print data + +months = range(24) + +t=cdms2.createAxis(months) +t.designateTime() +t.units="months since 2014" + +import cdutil + +cdutil.setTimeBoundsMonthly(t) +import MV2,numpy +data = numpy.array(data) +data=MV2.array(data) +data.setAxis(0,t) +print t.asComponentTime() +djf = cdutil.times.DJF(data) +djfc = cdutil.times.DJF.climatology(data) +print djf +assert(numpy.allclose(djf[0],1.) and numpy.allclose(djf[1],1.6666667) and numpy.allclose(djf[2],2.)) +print djfc +assert(numpy.allclose(djfc,1.625)) +djf = cdutil.times.DJF(data,criteriaarg=[.5,None]) +djfc = cdutil.times.DJF.climatology(data,criteriaarg=[.5,None]) + +print djf +assert(numpy.ma.allclose(djf[0],1.) and numpy.ma.allclose(djf[1],1.6666667) and numpy.ma.allclose(djf[2],numpy.ma.masked)) +print djfc +assert(numpy.allclose(djfc,1.4))