Skip to content

Commit

Permalink
fix #984
Browse files Browse the repository at this point in the history
criteriaargclim was messing up criteriaarg and useless
commented out, probably should take all code out, but in case of 'custom' criteria func it might be usefull
so letting it in
  • Loading branch information
doutriaux1 committed Jan 28, 2015
1 parent 45d9879 commit 4386f6a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Packages/cdutil/Lib/times.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 3 additions & 0 deletions testing/cdutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions testing/cdutil/test_djf_criteria.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit 4386f6a

Please sign in to comment.