Re: Code to produce opendap sequence



Bob Simons wrote:


John Caron wrote:

Hi Bob:

Bob Simons wrote:

Thank you for your email.

John Caron wrote:

Hi Bob:

Bob Simons wrote:

Ultimately, I want to use the java netcdf 2.2 library to generate an .nc file which, when viewed with opendap, appears to have a sequence.

My reading of the netcdf java library leads me to believe I need to create a Structure. Does anyone have sample code showing how to create a .nc file with a Structure using the java netcdf library?





Netcdf-3 files are limited in what they can represent; Netcdf-4, when available will be able to represent the entire CDM.

The only possible structure in a Netcdf-3 file is by using the unlimited dimension. See this doc for details:

http://www.unidata.ucar.edu/software/netcdf-java/formats/RecordsInNetcdf3.html







There are no programming details there. That document is filled with examples of the what the NCDUMP of the resulting file is, but there is no Java code showing how to make the files. In other words, it says what can be done, not how to do it. I ask again: can you point me to sample Java code to write files with structures?



Really, netcdf-3 files dont support structures. Nj22 will recognize the "record" structure, which you get by using unlimited dimensions. The example in the nj22 manual appendix "Create a netCDF file" shows creating a file with unlimited dimension. Its a bit out of date, im afraid to say, you need to use
 Dimension timeDim = ncfile.addDimension("time", -1, true, true, false);

instead of

 Dimension timeDim = ncfile.addDimension("time", -1);


Thank you. Thank you. Thank you.


But this wont be useful within an arbitrary opendap server/client. So if we rewind a few steps, I guess it would help me to know what opendap server you want to use, and perhaps a bit more of the context.


After learning that I can't make files that appear as sequences and hence be subjected to constraints on an OPeNDAP server (eek! maybe I shouldn't have chosen NetCDF files at all!), I have gone back to an approach that just needs limited row access to individual variables e.g., WSPD[5:1:9]. So just making the standard variables is enough for my main purposes.

But I do want to know how to work with records and unlimited dimensions, for experiments if nothing else. It is nice to know what tools one has at one's disposal. I was unable to get them working. I spent a chunk of time trying. It is very difficult to find out how to actually do things given the out-of-date code, mixed in with the working code, mixed in with the not-yet working code, and using the out-of-date documentation, mixed in with the correct documentation, mixed in (if you can call it that) with the non-existent documentation. Given that programmers are your clients, documentation is as much a part of your product as the code. It would be really nice if you documented as you went along, if things were labeled "out-of-date, use ... instead" or "This class/method is not finished yet.", if all class documentation had a simple but realistic example, and if all method documentation existed and wasn't trivialized (along the lines of "isEnhanced indicates if it is enhanced" but what is 'enhanced'?). But thanks for all that you do. The things that I've gotten working are nice and work well.

Thank you. I totally agree with you about the documentation. I'm hoping to get 
an updated manual done in the next month or two. Thanks for your patience.


  • 2006 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: