Skip to content

Commit

Permalink
Issue#231 (#232)
Browse files Browse the repository at this point in the history
* fix #225 passing transiant variable as axis

* Fix macOSX

* fix ESMF and NPY_STRING

* fix data._mask comparison for numpy 1.14
  • Loading branch information
dnadeau4 committed Jun 20, 2018
1 parent a473fe3 commit c2d8bd3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
12 changes: 6 additions & 6 deletions Lib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1932,20 +1932,20 @@ def __init__(self, data, bounds=None, id=None,
self._data_ = data[:]
else:
self._data_ = numpy.array(data[:])
elif isinstance(data, numpy.ndarray):
if copy == 0:
self._data_ = data
else:
self._data_ = numpy.array(data)
elif isinstance(data, numpy.ma.MaskedArray):
if numpy.ma.getmask(data) is not numpy.ma.nomask:
if numpy.ma.getmask(data).any() is numpy.bool_(True):
raise CDMSError(
'Cannot construct an axis with a missing value.')
data = data.data
if copy == 0:
self._data_ = data
else:
self._data_ = numpy.array(data)
elif isinstance(data, numpy.ndarray):
if copy == 0:
self._data_ = data
else:
self._data_ = numpy.array(data)
elif data is None:
self._data_ = None
else:
Expand Down
9 changes: 1 addition & 8 deletions tests/test_EsmfMask.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import unittest
import cdms2
import vcs
import ESMF
import cdat_info
import os
Expand Down Expand Up @@ -61,16 +60,10 @@ def testMask2(self):
data2 = cdms2.MV2.masked_where(cdms2.MV2.less(sft,50.),data)

tGrid = cdms2.createUniformGrid(-88.875, 72, 2.5, 0, 144, 2.5)
x=vcs.init()

for mthd in ["conservative", "linear"]:
print("USING REGRID METHOD:",mthd)
data3 = data2.regrid(tGrid, regridTool="esmf", regridMethod=mthd, mask=data2.mask)
print("pltting")
x.plot(data3)
print("pnging")
x.png("masked_{}".format(mthd))
print("clearing")
x.clear()



Expand Down
2 changes: 1 addition & 1 deletion tests/test_cdms_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 tstAxis(self):
def testAxis(self):
axis = cdms2.createAxis(cdms2.createVariable([10.], id='height', missing=1e20))
print(axis)

Expand Down

0 comments on commit c2d8bd3

Please sign in to comment.