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.
>To: address@hidden >From: Emory Creel <address@hidden> >Subject: Re: 20000411: java netCDF issue >Organization: UIC >Keywords: java netcdf metadata Hi Emory, > I have been having trouble extracting metadata from netCDF > files using the code currently available. You said that your > group was rewriting java code for netCDF files and I was wondering > if you have pregressed to the point of obtaining metadata, which > at this point is all I need. If so, could I do some beta testing > on the program? Thanks! The current released netCDF Java interface software should work fine for obtaining metadata. A small example that opens a netCDF file and just prints the variable names is available from http://www.unidata.ucar.edu/packages/netcdf/java/examples/ReadAnyNetcdf.java (It also reads the data but doesn't do anything with it.) Another example that prints the structure of a specified netCDF file, but none of the actual data, much like the "ncdump" utility with the "-h" (header) option, is available from http://www.unidata.ucar.edu/packages/netcdf/java/examples/ShowNetcdfSchema.java It just calls the toString() method of the NetcdfFile class, which uses the toCdl(StringBuffer buf) method of the Schema class to format information about each object into a String. The toCdl(StringBuffer buf) methods of other classes such as the Dimension, Attribute, and Variable classes are also useful for displaying individual lines of metadata. Similarly, http://www.unidata.ucar.edu/packages/netcdf/java/examples/DumpNetcdf.java outputs the metadata for a netCDF file followed by the actual data. For an example of another Java program that provides a graphical display of the metadata and data in an arbitrary netCDF file, see Donald Denbo's ncBrowse program: http://plover.wrc.noaa.gov/java/ncBrowse/ If you have a (small) example of something that doesn't work or a specific question about the interface that the documentation doesn't explain well enough, send that to "address@hidden" and we'll try to answer it. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu