I read netCDF files through netCDF4
into python
.
I get arrays with invalid values that print as --
, for example:
[[[-- -- -- ..., 0.0 0.0 0.0]
[-- -- -- ..., 0.0 0.0 0.0]
[-- -- -- ..., 0.0 0.0 0.0]]
[[-- -- -- ..., 0.0 0.0 0.0]
[-- -- -- ..., 0.0 0.0 0.0]
[-- -- -- ..., 0.0 0.0 0.0]]]
Where do these values originate from, and how could I identify (and replace) them? Things such as numpy.isnan
would return me --
as result, too. I can use these arrays with --
later without crash (I can for example plot them), but they seem to be problematic for some operations.
For example, I used to do something like
numpy.mean(myarray, axis=(1,2)) # the tuple for `axis` is not very regular
on myarray
originating from my netCDF files before without any problem, but I get TypeError: tuple indices must be integers, not tuple
and a crash with these weird --
-filled arrays...
I am using python 2.7.9
(and, in case relevant for the printing to screen format, PyCharm
for code editing).