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.
> Thank you very much for making the newer version of the > NetCDF package available. The RemoteNetCDF class alone will save me much > time and effort. You are welcome. > I was wondering if I could ask you a question. I'm > eventually trying to write an applet that will read and plot data from a > NetCDF file, but at the moment I'm not not having any success figuring > out how to grab data from the NetCDF file. Here is one of the variables > called Power: > > dimensions: > Time = UNLIMITED ; // (1486 currently) > Channels = 2 ; > Heights = 192 ; > variables: > float Power(Time, Heights, Channels) ; > Power:TITLE = "Power" ; > > How would I go about fetching pieces of data, say Power(23, 14, 1) Netcdf nc = new NetcdfFile(Myfile, true); Variable p = nc.get("Power"); int [] index = {23, 14, 1} float value = p.getFloat(index); > and > also how could I retrieve the Power data for each instant of time for a > fixed Height and Channel? There are several ways to do this. The way that would probably be most familiar to netcdf C or FORTRAN users looks like this ('p' is the Power variable as above.) int nheights = 192; // should be discovered dynamically int nchannels = 2; // should be discovered dynamically int [] origin = {time_index, 0, 0}; int [] shape = {1, nheights, nchannels}; MultiArray aSlice = p.copyout(origin, shape);