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

Re: Arrays with null entries?



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
===============================================================================