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.
Hi Yu-Long, > Sorry to bother you. I am a new user of netcdf. Now I am using gmt > to plot topographic image which needs 2-d netCDF grd file. And we do have > etopo5 data. Here are my questions. 1) how can we transfer etopo file > into 2-d netcdf grd file? Is there any utility to do this in netcdf > package? No, sorry, I don't know what "etopo5 data" is, and the netCDF package doesn't include any utilities for conversion from other data formats. If no one else has written such a utility, you may have to write it. We don't follow the GMT uses of netCDF closely, but there may be a GMT mailing list where you could ask others about conversion from etopo format. You might also ask the developers of GMT if they know of such a utility. > if there is no exist utility to do this > 2) I have written one class (c++) to read etopo file and sort data which I > want. My problem is where I can get the detail header information of > netcdf so that I can write my own program to output my data set except for > etopo into 2-d netcdf grd file. Here is only header informat I got from > gmt manual. Creation of netCDF files and writing data to netCDF files is done through one of the netCDF library interfaces, which now include C, Fortran, C++, and perl. To use the netCDF C++ interface, you will need to consult the NetCDF C++ Interface documentation that is available in the netcdf/c++/ directory of the current release, in the files nc.txn preliminary class documentation for the experimental C++ interface, in Texinfo form. This can be used to generate Postscript for printing with TeX. See the ../doc/Makefile for how to generate Postscript from Texinfo. nc.info preliminary class documentation for the experimental C++ interface, in info form, as generated from the Texinfo source file. The commented example program nctst.cc may also be useful for understanding the interface You can also look at the example programs in the netcdf/c++/ directory, example.cc and nctst.cc, to the intended use of the C++ interface for creating and writing netCDF files. GMT may require that the netCDF files it uses follow some specific GMT-specific conventions for the names of netCDF dimensions, variables, and attributes. I don't know what specific conventions GMT requires, but you will probably need to also know this to convert your data into netCDF files acceptable to GMT. ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu