<div dir="ltr"><div>Hello,</div><div><br></div><div>I recently installed the 1.5.0 beta versions of PyNGL and PyNIO (using 64-bit binaries for CentOS6) and attempted to run some existing code, but encountered an issue when numpy functions (e.g. numpy.ma.masked_equal()) are called with NioVariable object arguments.</div><div><br></div><div>At PyNIO v1.4.1/numpy1.6.1 I was able to do the following:</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>>>> import Nio</div><div><div>>>> Nio.__version__</div><div>'1.4.1'</div></div><div>>>> import numpy</div><div>>>> numpy.__version__</div><div>'1.6.1'</div><div>>>> f = Nio.open_file("<a href="http://glofs.leofs.fields.nowcast.20151229.t12z.nc">glofs.leofs.fields.nowcast.20151229.t12z.nc</a>", "r")</div><div>>>> m = f.variables["mask"]</div><div>>>> numpy.ma.masked_equal(m, 1.0)</div><div>masked_array(data =</div><div> [[0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> ...,</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]],</div><div> mask =</div><div> [[False False False ..., False False False]</div><div> [False False False ..., False False False]</div><div> [False False False ..., False False False]</div><div> ...,</div><div> [False False False ..., False False False]</div><div> [False False False ..., False False False]</div><div> [False False False ..., False False False]],</div><div> fill_value = 1.0)</div></blockquote></div><div><br></div><div><br></div><div>However at PyNIO 1.5.0 beta/numpy 1.9.2, the numpy function call hangs, and the process begins consuming memory at an exponential rate until the call is interrupted.</div><div><br></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>>>> import Nio<br></div><div>>>> Nio.__version__</div><div>'1.5.0-beta'</div><div>>>> import numpy</div><div>>>> numpy.__version__</div><div>'1.9.2'</div></div><div><div>>>> f = Nio.open_file("<a href="http://glofs.leofs.fields.nowcast.20151229.t12z.nc">glofs.leofs.fields.nowcast.20151229.t12z.nc</a>", "r")</div><div>>>> m = f.variables["mask"]</div></div><div><div>>>> numpy.ma.masked_equal(m, 1.0)</div><div>^C^CTraceback (most recent call last):</div><div> File "<stdin>", line 1, in <module></div><div> File "/opt/pyngl/python/lib/python2.7/site-packages/numpy/ma/core.py", line 1982, in masked_equal</div><div> output = masked_where(equal(x, value), x, copy=copy)</div><div> File "/opt/pyngl/python/lib/python2.7/site-packages/numpy/ma/core.py", line 928, in __call__</div><div> (da, db) = (getdata(a, subok=False), getdata(b, subok=False))</div><div> File "/opt/pyngl/python/lib/python2.7/site-packages/numpy/ma/core.py", line 667, in getdata</div><div> data = np.array(a, copy=False, subok=subok)</div><div> File "/opt/pyngl/python/lib/python2.7/site-packages/PyNIO/Nio.py", line 325, in __getitem__</div><div> ret = get_variable(self.file, self.varname, xsel)</div><div> File "/opt/pyngl/python/lib/python2.7/site-packages/PyNIO/coordsel.py", line 60, in get_variable</div><div> ret = file.file.variables[varname][xsel]</div><div>KeyboardInterrupt</div></div></blockquote><div><br></div><div>But if I change the call to use numpy indexing, it works:</div><br><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><div>>>> m.shape</div><div>(24, 81)</div></div><div>>>> numpy.ma.masked_equal(m[:,:], 1.0)</div><div>masked_array(data =</div><div> [[0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> ...,</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]</div><div> [0.0 0.0 0.0 ..., 0.0 0.0 0.0]],</div><div> mask =</div><div> [[False False False ..., False False False]</div><div> [False False False ..., False False False]</div><div> [False False False ..., False False False]</div><div> ...,</div><div> [False False False ..., False False False]</div><div> [False False False ..., False False False]</div><div> [False False False ..., False False False]],</div><div> fill_value = 1.0)</div></div></blockquote><br></div><div>Was this change in functionality intentional? </div><div><br></div><div>The NetCDF files I used are available at:</div><div><br></div><div> <a href="ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nos/prod/glofs.20151229/">ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/nos/prod/glofs.20151229/</a><br></div><div><br></div>(directory will change based on date)<div><br></div><div>Thanks,</div><div>Jason</div><div><div><div class="gmail_signature"><div dir="ltr"><div>--</div>Jason Greenlaw<div>Software Developer, ERT, Inc.<br><div>NOAA/NOS/OCS/CSDL<div><a href="http://nowcoast.noaa.gov" target="_blank">http://nowcoast.noaa.gov</a></div><div><a href="mailto:Jason.Greenlaw@noaa.gov" target="_blank">Jason.Greenlaw@noaa.gov</a></div><div><br></div></div></div></div></div></div>
</div></div>