Due to the current gap in continued funding from the U.S. National Science Foundation (NSF), the NSF Unidata Program Center has temporarily paused most operations. See NSF Unidata Pause in Most Operations for details.
You are mixing NetcdfFile and NetcdfFileWriteable. You can only write Netcdf-3 files with NetcdfFileWriteable. You notice there are no groups there, because you cant do groups with netcdf-3. You can only read files with NetcdfFile. This is the interface to a number of file formats, including HDF5, which does have groups. Unfortunately a number of methods got made public that are confusing, like NetcdfFile.addVariable(). Generally, these should only be used by system level routines. I hear you about getting a good user manual out to explain all this. Michael Tiller wrote:
I was trying to understand the group functionality. It isn't clear to me how to create groups and then how to put variables in them. Here is some sample code... Group root = file.getRootGroup(); // Seems pretty obvious Group child = new Group(file, root, "child"); file.addGroup(root, child); OK, I'm not sure about this line. It seems strange that to add a group you have to already have created the group. child.addAttribute(new Attribute("testAttr", "testValue")); Group grand = new Group(file, child, "grand"); //file.addGroup(child, grand); This line is commented out because it causes a null pointer exception if it isn't (although it isn't clear why it should cause any problems).Variable x = new Variable(file, grand, null, "x");file.addVariable(grand, x); Hmmm...the constructor to Variable requires a group and the file.addVariable method requires a group? This seems redundant. My example actually runs (generates a netCDF file) but if I open it with the ToolsUI tool, I don't see any groups?!? Whenever the user's guide is updated, it would be nice to have an example of the proper method for creating groups. -- Mike
netcdf-java
archives: