Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
When I read data for a lon/lat point from a NetCDF variable I get a MaskedArray if all values are missing and an ndarray if all values are present. I'd like to instead get it returned in one way or the other in either case, preferably as a MaskedArray so I can check if all values are masked and skip to the next lon/lat point. Can someone advise as to how I can best go about this? I'm using the netCDF4 Python module from here: https://code.google.com/p/netcdf4-python/ My code looks like this: # get a "chunk" of data from the NetCDF variable precipChunk = inputPrecipVariable[0:len(inputTimeDimension):1, lonChunkOffset:lonChunkOffset + lonChunkSize:lonChunkSize, latChunkOffset:latChunkOffset + latChunkSize:latChunkSize] # skip this entire chunk if all values are masked if (precipChunk.mask.all()): continue The above works fine if the data (precipChunk) is returned as a MaskedArray, but it bombs out if it's returned as an ndarray. Maybe I should do some sort of type check on the returned array before checking to see if all values are masked? Is data only returned as a MaskedArray if *all* values are missing/fill values, or can it happen that a section of data which does contain valid values is also returned as MaskedArray with the valid data values unmasked? Thanks in advance for any suggestions and/or insight. --James
netcdfgroup
archives: