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.
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 lengthvalid_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