Re: Problems with Java NetCDF examples

Craig Mattocks wrote:

On Aug 5, 2005, at 6:36 PM, John Caron wrote:

ncfile.addVariableAttribute("rh", "valid_range", "0., 100."); // <--- Problem quotes!

which adds a string-valued attribute. You probably want to create an integer valued attribute, since rh is an integer.

normally you could go:

  ncfile.addVariableAttribute("rh", "valid_range", new Integer(0) );
but since you need an array, its more convoluted:

ArrayInt.D1 valid_range = new ArrayInt.D1(2); // create a 1-d integer array of length
   valid_range.set(0, 0);  // set the firsst element
   valid_range.set(1,100);  // set the second element
   ncfile.addVariableAttribute("rh", "valid_range", valid_range);


Thank you for your quick response and for your patient explanation, John!

Guess I could also use:

ncfile.addVariableAttribute( "rh", "valid_range", Array.factory(new double[] {0d, 100d}) );

Seems to work... Izzat okay?

Craig

yep, that will also work


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