Re: Arrays with null entries?

Hi Simon, Gabriella:

NJ22 default fill values should match ncdump;
older versions of nj22 had the default to not fill (for efficiency). Call

 NetcdfFileWriteable.createNew(String location, boolean fill)

with fill = true to be sure.

However, if you write the array values yourself, it will write whatever is in 
the array, eg zeroes. Typically you only write the data values that exist, using

 NetcdfFileWriteable.write(String varName, int [] origin, Array values)

If you want to write the entire Variable, using

 NetcdfFileWriteable.write(String varName, Array values)

you need to pre-fill the values Array with your fill value. If you do that, you 
dont need fill values to be prewritten to disk, so you can speed things up by 
2X if you set fill=false.

John

Simon Wood wrote:
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



  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: