Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress numpy warnings? #1580

Closed
durack1 opened this issue Oct 1, 2015 · 3 comments
Closed

Suppress numpy warnings? #1580

durack1 opened this issue Oct 1, 2015 · 3 comments

Comments

@durack1
Copy link
Member

durack1 commented Oct 1, 2015

I've just started seeing these warnings:

import cdms2 as cdm
import MV2 as MV
# Set nc classic as outputs
cdm.setNetcdfShuffleFlag(0)
cdm.setNetcdfDeflateFlag(0)
cdm.setNetcdfDeflateLevelFlag(0)

os.chdir('/work/durack1/Shared/131118_PaperPlots_SaltyVariability/151001_NOEMP02_IPSL-CM6')
domains = ['glo','atl','pac','ind']
for i in domains:
    var = 'zosal' + i
    infile = ''.join(['NOEMP02_1850_1899_1Y_',var,'.nc'])
    print '** Processing: ',infile
    f_h = cdm.open(infile)
    var1850to1899 = f_h(var) ; f_h.close()
    infile = replace(infile,'1850_1899','1900_1949')
    f_h = cdm.open(infile)
    var1900to1949 = f_h(var) ; f_h.close()
    vars()[i] = MV.concatenate([var1850to1899,var1900to1949])
    del(var1850to1899,var1900to1949,var,infile) ; gc.collect()
del(i,domains) ; gc.collect()

>>> glo_1850to1899.shape
(50, 31, 149, 1)
>>> glo_1900to1949.shape
(50, 31, 149, 1)
>>> glo = MV.concatenate([glo_1850to1899,glo_1900to1949])
/usr/local/uvcdat/2.4.0rc1/lib/python2.7/site-packages/cdms2/axis.py:2266: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if None in boundsArray:

It will likely disappear in planned numpy/cdms updates #885 (and has already been noted before #576), but wondering whether this should be cleaned up before 2.4.0?

@dnadeau4
Copy link
Contributor

dnadeau4 commented Oct 1, 2015

@durack1 I get no warnings!! Can you try this code?

import cdms2
import numpy
aa=cdms2.MV.array(numpy.ma.ones([50,31,149,1]))
bb=cdms2.MV.array(numpy.ma.ones([50,31,149,1]))
cc=cdms2.MV.array(numpy.ma.ones([50,31,149,1]))
aa.shape
(50, 31, 149, 1)
bb.shape
(50, 31, 149, 1)
cc.shape
(50, 31, 149, 1)
dd=cdms2.MV.concatenate([aa,bb,cc])
dd.shape
(150, 31, 149, 1)

@durack1
Copy link
Member Author

durack1 commented Oct 2, 2015

@dnadeau4 it seems it has something to do with the input data (and the coordinate bounds), I'm guessing as I got similar results to you below:

In [1]: import cdms2
In [2]: import numpy
In [3]: aa=cdms2.MV.array(numpy.ma.ones([50,31,149,1]))
In [4]: bb=cdms2.MV.array(numpy.ma.ones([50,31,149,1]))
In [5]: cc=cdms2.MV.array(numpy.ma.ones([50,31,149,1]))
In [6]: aa.shape
Out[6]: (50, 31, 149, 1)
In [7]: bb.shape
Out[7]: (50, 31, 149, 1)
In [8]: cc.shape
Out[8]: (50, 31, 149, 1)
In [9]: dd=cdms2.MV.concatenate([aa,bb,cc])
In [10]: import MV2 as MV
In [11]: ee = MV.concatenate([aa,bb,cc])

For completeness I updated my code snippet above..

@dnadeau4
Copy link
Contributor

Fixed using new numpy and with new releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants