[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arrays with null entries?

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: Re: Arrays with null entries?
  • Date: Tue, 30 Jan 2007 11:55:11 +1300

Hi Gaby,

I am new to NetCDF format, so please bear with me...
When I currently instantiate an array it
zeros out all entries, is there a way to avoid that? I don't see
anything in the javadocs that allows me to do this.
When I write out the array to a file, what I'd like to see in the output
file when I invoke ncdump is entries like _, _, _, ...  where there is
no data.
I guess this must be something to do with fill mode and the value of 
_FillValue.  How are you creating the file?  if 
NetcdfFileWriteable.createNew() or openExisting() what fill mode are you 
using?  With fill mode enabled the array should get pre-filled with 
whatever '_FillValue' is set to for the variable in question.  If you 
don't want this behavior then set fill mode to false.
according to ncdump man page:
  ncdump uses ‘_’ to represent data values that are equal to the
  _FillValue’ attribute for a variable, intended  to  represent  data
  that  has  not  yet been written.  If a variable has no ‘_FillValue’
  attribute, the default fill value for the variable type is used if the
  variable is not of byte type.

I would infer from that that if you do want '_' used to represent missing data then you need fill mode enabled. Further the _FillValue used will have to match ncdump's defaults (or be stated explicitly in your netCDF file).
I'm not sure what NJ22 uses as default _FillValues (NaN for floats?, not 
sure about ints), but it is possible that NJ22's defaults do not match 
ncdump's expected values (being the C defaults defined in netcdf.h, I 
assume).
Better practice might be to explicitly define a fill value outside the 
valid range for your data and add the _FillValue attribute to the 
variable.  That way ncdump should always recognise it whatever value you 
use.
Hope this helps

Simon

--
Simon Wood
Scientific Programmer (Remote Sensing)
National Institute of Water and Atmospheric Research, Wellington, NZ    
address@hidden
http://www.niwa.co.nz

===============================================================================
To unsubscribe netcdf-java, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
===============================================================================