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.
> > Two questions for you: > > > > 1. In the new version of the library, what is the proper way to read > > Variable data? In the previous version, I got a Variable object and > > called toArray() to grab the data for a variable. Is this still the > > same, or is there a better way to grab large datasets in a high > > performance way? > > Here's an example fragment of how to read variable data in the version > 2 interface: > > try { > NetcdfFile nc = new NetcdfFile(fileName); // open it readonly > Variable v = nc.findVariable(varName); // get variable by name > Array varMa = v.read(); > ... > } copyout() in the version 1 library will give similar performance to the code above. toArray() will add an extra data copy. it will be much slower if you call Variable.getDouble(), which will read only one number from the file at a time. This is no longer possible in the version 2 library.